Article Directory
Preconditions
K8S installation process nine: Kubernetes Worker node installation process has been completed .
To install CNI viewing and CoreDNS services, you need to execute the following operation commands on the Kubernetes Master node. The reason is that the command-line tool kubectl is used to deploy the Calico plug-in and CoreDNS service. This command-line tool relies on
~/.kube/config
this configuration file. Currently, this file is only generated in the kubernetes master node.
1. Install the CNI plugin
1.1 Download the CNI plugin
mkdir -p /opt/kubernetes/cni
cd /opt/kubernetes/cni
wget https://docs.projectcalico.org/manifests/calico.yaml
1.2 Modify calico.yaml configuration information
- Add the following content after the name: IP configuration
# Auto-detect the BGP IP address.
- name: IP
value: "autodetect"
# append IP_AUTODETECTION_METHOD env
- name: IP_AUTODETECTION_METHOD
value: "interface=eth0"
- Remove the comment in front of the variable below and modify the value
- name: CALICO_IPV4POOL_CIDR
value: "172.16.0.0/16"
The value of CALICO_IPV4POOL_CIDR must be consistent with the value in Chapter 5.3 of K8S installation process eight: Kubernetes Master node installation .--cluster-cidr
1.3 Execute the installation operation
kubectl apply -f calico.yaml
1.4 View the deployment status of the calico service
kubectl get pods -A
In the figure above, 1 calico-kube-controllers service is started, which means it is normal, and there are 3 calico-node services, which means that the kubernetes cluster has 3 kubernetes worker nodes, and each kubernetes worker node has successfully deployed the calico-node service. Tip: As many kubernetes worker nodes as there are in the kubernetes cluster, how many calico-node services will be automatically deployed.
2. Install CoreDNS service
2.1 Get the CoreDNS installation file
cd /opt
git clone https://github.com/coredns/deployment
2.2 Deploy CoreDNS service
cd /opt/deployment/kubernetes
./deploy.sh -r 10.255.0.0/16 -i 10.255.0.2 > coredns.yaml
kubectl apply -f coredns.yaml
-r
: Set the kubernetes service IP range. This value must be consistent with the value in K8S installation process 8: Kubernetes Master node installation--service-cluster-ip-range
4.1 .-i
: Set the IP address of CoreDNS. This value must be consistent with the variable value in K8S installation process 9: Kubernetes Worker node installation 2.1.clusterDNS
2.3 View the CoreDNS service after successful deployment
kubectl get pods -A
The coredns service status is running and READY is 1/1, which means the service starts normally.
3. Check the kubernetes cluster worker nodes
kubectl get nodes -A
In the figure above, k8s-master1 and k9s-master2 nodes not only perform K8S installation process eight: Kubernetes Master node installation , but also perform K8S installation process nine: Kubernetes Worker node installation , so k8s-master1 and k8s-master2 nodes are not only used as clusters In addition to the master node, it also works part-time as a Kubernetes worker node. This can be used in the test environment, and virtual machine resources can be used as much as possible. However, it is not recommended to use it in a production environment. Keep the purity of the master and prohibit Pods from being scheduled to the master node, which will affect the performance of the management node of the cluster.