Fedora 35
Sponsored Link

Kubernetes : Configure Master Node2021/11/11

 
Install Kubeadm to Configure Multi Nodes Kubernetes Cluster.
This example is based on the environment like follows.
-----------+---------------------------+--------------------------+------------
           |                           |                          |
       eth0|10.0.0.30              eth0|10.0.0.51             eth0|10.0.0.52
+----------+-----------+   +-----------+----------+   +-----------+----------+
|   [ dlp.srv.world ]  |   | [ node01.srv.world ] |   | [ node02.srv.world ] |
|      Master Node     |   |      Worker Node     |   |      Worker Node     |
+----------------------+   +----------------------+   +----------------------+

[1]
[2]
Configure initial setup on Master Node.
For [--apiserver-advertise-address] option, specify the IP address Kubernetes API server listens.
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.
[root@dlp ~]#
kubeadm init --apiserver-advertise-address=10.0.0.30 --pod-network-cidr=192.168.0.0/16 --cri-socket=unix:///var/run/crio/crio.sock

remote version is much newer: v1.22.3; falling back to: stable-1.21
[init] Using Kubernetes version: v1.21.6
[preflight] Running pre-flight checks
[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

.....
.....

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:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/

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

# the command below is necessary to run on Worker Node when he joins to the cluster, so remember it
kubeadm join 10.0.0.30:6443 --token wa9v2x.wkwtjgfs9nhq0nb9 \
        --discovery-token-ca-cert-hash sha256:58012e541b9b0bc9f229e5d0c763d6dbf202f5b9be95ed428e0a97c0a04d9488

# set cluster admin user
# if you set common user as cluster admin, login with it and run [sudo cp/chown ***]

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

[root@dlp ~]#
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

[root@dlp ~]#
chown $(id -u):$(id -g) $HOME/.kube/config
[3] Configure Pod Network with Calico.
[root@dlp ~]#
wget https://docs.projectcalico.org/manifests/calico.yaml

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

configmap/calico-config created
customresourcedefinition.apiextensions.k8s.io/bgpconfigurations.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
clusterrolebinding.rbac.authorization.k8s.io/calico-kube-controllers created
clusterrole.rbac.authorization.k8s.io/calico-node created
clusterrolebinding.rbac.authorization.k8s.io/calico-node created
daemonset.apps/calico-node created
serviceaccount/calico-node created
deployment.apps/calico-kube-controllers created
serviceaccount/calico-kube-controllers created
Warning: policy/v1beta1 PodDisruptionBudget is deprecated in v1.21+, unavailable in v1.25+; use policy/v1 PodDisruptionBudget
poddisruptionbudget.policy/calico-kube-controllers created

# show state : OK if STATUS = Ready

[root@dlp ~]#
kubectl get nodes

NAME            STATUS   ROLES                  AGE    VERSION
dlp.srv.world   Ready    control-plane,master   9m5s   v1.21.0

# show state : OK if all are Running

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

NAMESPACE     NAME                                       READY   STATUS    RESTARTS   AGE
kube-system   calico-kube-controllers-5d995d45d6-hbxzh   1/1     Running   0          55s
kube-system   calico-node-hwgxp                          1/1     Running   0          55s
kube-system   coredns-558bd4d5db-qkljz                   1/1     Running   0          9m17s
kube-system   coredns-558bd4d5db-rflmk                   1/1     Running   0          9m17s
kube-system   etcd-dlp.srv.world                         1/1     Running   0          9m6s
kube-system   kube-apiserver-dlp.srv.world               1/1     Running   0          9m6s
kube-system   kube-controller-manager-dlp.srv.world      1/1     Running   0          8m6s
kube-system   kube-proxy-5dz9q                           1/1     Running   0          9m17s
kube-system   kube-scheduler-dlp.srv.world               1/1     Running   0          8m12s
Matched Content