Kubernetes has formed a dominant position in the field of container orchestration. Whether it is development, operation and maintenance, or testing, it has become very necessary to master kubernetes.
This article builds a simple kubernetes operating environment through minikube.
Install virtual machine
All mainstream operating systems support kubernetes, but when installing kubernetes on a windows operating system, it cannot be directly accessed through the local network. You must use another machine. It is more convenient to install an additional virtual machine.
Installing a virtual machine may require higher computer configurations. Kubernetes itself requires that the computer configuration must have at least 2G of memory and more than 2 cores. The virtual machine also needs to occupy certain resources, which may cause the computer to operate at full capacity.
I installed an ubuntu system on vmware and the interface looks good.
Install minikube
The official management tool of kubernetes is kubeadmin, which is suitable for building clusters in production environments. You can also use third-party management tools such as rancher or k9s. If this is your first contact, it is better to use minikube first to smoothly adjust the environment.
Installing minikube in Ubuntu is relatively simple. First download the installation package to the local through the first line of commands, and then complete the installation through the second line of commands.
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb
sudo dpkg -i minikube_latest_amd64.deb
After the installation is complete, try to start the environment through minikube start:
If it is started on a new system, it may prompt that there is no container execution engine and therefore cannot be started. Kubernetes supports many container engines, including:
-
virtualbox
-
vmwarefusion
-
kvm2
-
vmware
-
docker
-
subman
You can check it through minikube start --help. I just used docker directly.
Install docker
For docker installation, you can directly refer to the official documentation for instructions.
(Click to read the official document to jump to the original text)
1. Uninstall the original dependencies first:
sudo apt-get remove docker docker-engine docker.io containerd runc
2. Set rep
sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
3. Add docker’s official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
4. Set up a stable version
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
5. Install dockeer
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
6. Set up user groups
sudo usermod -aG docker $USER && newgrp docker
Well, after docker is installed, re-run minikube start. If a successful startup prompt appears, it means that minikube can be used normally.
Deploy application
To manage and deploy containers, you need to use the kubectl tool provided by kubernetes. When starting, minikube prompts you to spell minikube kubectl -- if you want to use kubectl. This is very cumbersome, so you can define a shortcut command:
alias k="minikube kubectl --"
Create an nginx-dp.yaml file in the directory:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
Then run the following command:
minikube kubectl -- apply -f nginx-dp.yaml
After starting, run the following command to view the running deployments:
However, the deployed project is currently not accessible from the outside. If external access is required, the port needs to be exposed:
kubectl expose deployment nginx-deployment --type=LoadBalancer --port 80
View all service ports
minikube node list # 查看节点IP
kubectl get svc -A
Or view all services through minikube:
minikube service list
Now you can access the nginx service through the network.
Finally: The complete software testing video tutorial below has been compiled and uploaded. Friends who need it can get it by themselves [guaranteed 100% free]
Software Testing Interview Document
We must study to find a high-paying job. The following interview questions are from the latest interview materials from first-tier Internet companies such as Alibaba, Tencent, Byte, etc., and some Byte bosses have given authoritative answers. After finishing this set I believe everyone can find a satisfactory job based on the interview information.