Get the App
SLTechnology News&Howtos  ›  Servers  › 

Kubernetes Cluster installation Guide: kube-controller-manager component Cluster deployment

Shulou Source: shulou.com Published: 2022-06-03 03:55:26 09月22日 Update

Kube-controller-manager belongs to the master node component, and the kube-controller-manager cluster contains three nodes. After startup, one leader node will be generated through the competitive election mechanism, and the other nodes will be in a blocking state. When the leader node is unavailable, the remaining nodes will be elected again to generate a new leader node to ensure the high availability of the service.

1 installation preparation

Special note: all operations here are performed on the devops machine through the ansible tool. Kube-controller-manager uses certificates in the following two cases:

Use to communicate with kube-apiserver 's secure port; output metrics in prometheus format on the secure port (https,10257) 1.1 Environment variable definition # Variable parameter setting # # KUBE_NAME=kube-controller-managerK8S_INSTALL_PATH=/data/apps/k8s/kubernetesK8S_BIN_PATH=$ {K8S_INSTALL_PATH} / sbinK8S_LOG_DIR=$ {K8S_INSTALL_PATH} / logsK8S_CONF_PATH=/etc/k8s/kubernetesKUBE_CONFIG_PATH=/etc/k8s/kubeconfigCA_ DIR=/etc/k8s/sslSOFTWARE=/root/softwareVERSION=v1.14.2PACKAGE= "kubernetes-server-$ {VERSION}-linux-amd64.tar.gz" DOWNLOAD_URL= "" https://github.com/devops-apps/download/raw/master/kubernetes/${PACKAGE}"ETH_INTERFACE=eth2LISTEN_IP=$(ifconfig | grep-A 1 ${ETH_INTERFACE} | grep inet | awk'{print $2}') USER=k8sSERVICE_CIDR=10.254.0.0/221.2 downloads and distributes kubernetes binaries

Visit the official address of kubernetes github to download a stable realease package to this machine

Wget $DOWNLOAD_URL-P $SOFTWARE

Distribute kubernetes packages to each master node server

Sudo ansible master_k8s_vgs-m copy-a "src=$ {SOFTWARE} / $PACKAGE dest=$ {SOFTWARE} /"-b2 deployment kube-controller-manager cluster 2.1 install kube-controller-manager binaries # 1.Check if the install directory exists.if [!-d "$K8S_BIN_PATH"]; then mkdir-p $K8S_BIN_PATHfiif [!-d "$K8S_LOG_DIR/$KUBE_NAME"] Then mkdir-p $K8S_LOG_DIR/$KUBE_NAMEfiif [!-d "$K8S_CONF_PATH"]; then mkdir-p $K8S_CONF_PATHfiif [!-d "$KUBE_CONFIG_PATH"]; then mkdir-p $KUBE_CONFIG_PATHfi### 2.Install kube-apiserver binary of kubernetes.if [!-f "$SOFTWARE/kubernetes-server-$ {VERSION}-linux-amd64.tar.gz"] Then wget $DOWNLOAD_URL-P $SOFTWARE > > / tmp/install.log 2 > & 1ficd $SOFTWARE & & tar-xzf kubernetes-server-$ {VERSION}-linux-amd64.tar.gz-C. / cp-fp kubernetes/server/bin/$KUBE_NAME $K8S_BIN_PATHln-sf $K8S_BIN_PATH/$KUBE_NAM / usr/local/binchown-R $USER:$USER $K8S_INSTALL_PATHchmod-R 755 $K8S_INSTALL_PATH2.2 Distribution kubeconfig File and Certificate Distribution Certificate cd ${CA_DIR} sudo Ansible master_k8s_vgs-m copy-a "src=ca.pem dest=$ {CA_DIR} /"-bsudo ansible master_k8s_vgs-m copy-a "src=ca-key.pem dest=$ {CA_DIR} /"-bsudo ansible master_k8s_vgs-m copy-a\ "src=kubecontroller-manager.pem dest=$ {CA_DIR} /"-bsudo ansible master_k8s_vgs-m copy-a\ "src=kubecontroller-manager-key.pem dest=$ {CA_DIR} /"-b distribute kubeconfig certification files

Kube-controller-manager uses the kubeconfig file connection to access the apiserver service, which provides the apiserver address, embedded CA certificate, and kube-scheduler certificate:

Cd $KUBE_CONFIG_PATHsudo ansible master_k8s_vgs-m copy-a\ "src=kube-controller-manager.kubeconfig dest=$KUBE_CONFIG_PATH/"-b

Note: if you have synchronized the component kubeconfig and certificate files in the previous section, you do not have to do this here

2.3 create the kube-controller-manager startup service cat > / usr/lib/systemd/system/$ {KUBE_NAME} .service

Tags: Nodes certificates files ports clusters security parameters permissions status services authentication output operation components two address mode monitoring election valid Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker OPPO Reno MySQL Microsoft vpn