CentOS Stream 9
Sponsored Link

Kubernetes : Configure Control Plane Node2023/10/19


Configure Multi Nodes Kubernetes Cluster.

This example is based on the environment like follows.

+----------------------+   +----------------------+
|   [ mgr.srv.world ]  |   |   [ dlp.srv.world ]  |
|     Manager Node     |   |     Control Plane    |
+-----------+----------+   +-----------+----------+
        eth0|             eth0|
            |                          |
            |                          |
        eth0|             eth0|
+-----------+----------+   +-----------+----------+
| [ node01.srv.world ] |   | [ node02.srv.world ] |
|     Worker Node#1    |   |     Worker Node#2    |
+----------------------+   +----------------------+


Configure pre-requirements on all Nodes, refer to here.


Configure initial setup on Control Plane Node.

For [control-plane-endpoint], specify the Hostname or IP address that is shared among the Kubernetes Cluster.
For the case proxying Kubernetes cluster with a Manager node like this example, specify Manager Node IP address.

For [apiserver-advertise-address], specify Control Plane Node IP address.

For [--pod-network-cidr] option, specify network which Pod Network uses.
There are some plugins for Pod Network. (refer to details below)

  ⇒ https://kubernetes.io/docs/concepts/cluster-administration/networking/

On this example, it selects Calico.
# if Firewalld is running, allow services below

[root@dlp ~]#
firewall-cmd --add-service={kube-apiserver,kube-control-plane,kube-control-plane-secure,kubelet,kubelet-readonly,http,https}

[root@dlp ~]#
firewall-cmd --runtime-to-permanent

[root@dlp ~]#
kubeadm init --control-plane-endpoint= --apiserver-advertise-address= --pod-network-cidr= --cri-socket=unix:///var/run/crio/crio.sock

[init] Using Kubernetes version: v1.28.2
[preflight] Running pre-flight checks
        [WARNING Firewalld]: firewalld is active, please ensure ports [6443 10250] are open or your cluster may not function correctly
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
[certs] Using certificateDir folder "/etc/kubernetes/pki"
[certs] Generating "ca" certificate and key
[certs] Generating "apiserver" certificate and key
[certs] apiserver serving cert is signed for DNS names [dlp.srv.world kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs []
[certs] Generating "apiserver-kubelet-client" certificate and key
[certs] Generating "front-proxy-ca" certificate and key


Your Kubernetes control-plane has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

Alternatively, if you are the root user, you can run:

  export KUBECONFIG=/etc/kubernetes/admin.conf

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:

You can now join any number of control-plane nodes by copying certificate authorities
and service account keys on each node and then running the following as root:

  kubeadm join --token yq90qu.cl827hpp06az8isd \
        --discovery-token-ca-cert-hash sha256:8a8bd725c9cbf8d03c0a724bded0afb923a067d48ca50fd8f0346fd3d0a27b6e \

Then you can join any number of worker nodes by running the following on each as root:

kubeadm join --token yq90qu.cl827hpp06az8isd \
        --discovery-token-ca-cert-hash sha256:8a8bd725c9cbf8d03c0a724bded0afb923a067d48ca50fd8f0346fd3d0a27b6e

# transfrer authentication file for cluster admin to Manager Node with any user

[root@dlp ~]#
scp /etc/kubernetes/admin.conf centos@

cent@'s password:
admin.conf                                    100% 5645    20.7MB/s   00:00
[3] Work on Manager Node. Configure Pod Network with Calico.
# set cluster admin user with a file you transferred from Control Plane
# if you set common user as cluster admin, login with it and run [sudo cp/chown ***]

[root@mgr ~]#
mkdir -p $HOME/.kube

[root@mgr ~]#
cp /home/centos/admin.conf $HOME/.kube/config

[root@mgr ~]#
chown $(id -u):$(id -g) $HOME/.kube/config
[root@mgr ~]#
wget https://raw.githubusercontent.com/projectcalico/calico/master/manifests/calico.yaml

[root@mgr ~]#
kubectl apply -f calico.yaml

poddisruptionbudget.policy/calico-kube-controllers created
serviceaccount/calico-kube-controllers created
serviceaccount/calico-node created
serviceaccount/calico-cni-plugin created
configmap/calico-config created
customresourcedefinition.apiextensions.k8s.io/bgpconfigurations.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/bgpfilters.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/bgppeers.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/blockaffinities.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/caliconodestatuses.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/clusterinformations.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/felixconfigurations.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/globalnetworkpolicies.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/globalnetworksets.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/hostendpoints.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/ipamblocks.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/ipamconfigs.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/ipamhandles.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/ippools.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/ipreservations.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/kubecontrollersconfigurations.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/networkpolicies.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/networksets.crd.projectcalico.org created
clusterrole.rbac.authorization.k8s.io/calico-kube-controllers created
clusterrole.rbac.authorization.k8s.io/calico-node created
clusterrole.rbac.authorization.k8s.io/calico-cni-plugin created
clusterrolebinding.rbac.authorization.k8s.io/calico-kube-controllers created
clusterrolebinding.rbac.authorization.k8s.io/calico-node created
clusterrolebinding.rbac.authorization.k8s.io/calico-cni-plugin created
daemonset.apps/calico-node created
deployment.apps/calico-kube-controllers created

# show state : OK if STATUS = Ready

[root@mgr ~]#
kubectl get nodes

NAME            STATUS   ROLES           AGE     VERSION
dlp.srv.world   Ready    control-plane   7m52s   v1.28.2

# show state : OK if all are Running

[root@mgr ~]#
kubectl get pods -A

NAMESPACE     NAME                                       READY   STATUS    RESTARTS   AGE
kube-system   calico-kube-controllers-57758d645c-ws2gd   1/1     Running   0          50s
kube-system   calico-node-6cxp9                          1/1     Running   0          50s
kube-system   coredns-5dd5756b68-rn87g                   1/1     Running   0          8m18s
kube-system   coredns-5dd5756b68-zmsks                   1/1     Running   0          8m18s
kube-system   etcd-dlp.srv.world                         1/1     Running   0          8m32s
kube-system   kube-apiserver-dlp.srv.world               1/1     Running   0          8m32s
kube-system   kube-controller-manager-dlp.srv.world      1/1     Running   0          8m33s
kube-system   kube-proxy-ktlgl                           1/1     Running   0          8m18s
kube-system   kube-scheduler-dlp.srv.world               1/1     Running   0          8m32s
Matched Content