Installing the Components of a Kubernetes Cluster


Installing the Components of a Kubernetes Cluster

In this post, we build a test cluster from scratch in order to check the installed components of the cluster and execute some deployments.

Prerequisites:

  • Operating System Ubuntu 18.04.4
  • One  Master Node
  • <N> Worker Node
  • Internet connection to pull binaries  and  repositories
  • Sudo access for user

Steps:

  1. Install the container runtime, as well as kubeadm, kubectl, and kubelet
  2. Initialize the cluster
  3. Add CNI Flannel
  4. Add Nodes to cluster


Kubernetes Components

Control Plane  Components:

Control plane components typically run on Master node and make global decisions like scheduling pod, detecting, and responding cluster events, etc.

  • kube-apiserver: Expose the Kubernetes API.
  • etcd: Consistent and highly-available key-value store used as Kubernetes’ backing store for all cluster data.
  • kube-scheduler: Watch newly created pods and schedule them on a suitable node.
  • kube-controller-manager: 
    • Node controller
    • Replication controller
    • Endpoints controller
    • Service Account & Token controllers
  • cloud-controller-manager: Cloud-specific control logic.

Node  Components:

Node components run on every node, maintaining running pods and providing the Kubernetes runtime environment.

  • kubelet: An agent that runs on each node in the cluster. It makes sure that containers are running in a Pod.
  • kube-proxy: Network proxy that runs each node.
  • container-runtime: Responsible for the running containers.

Installation

Step 1: Add docker and kubernetes repositories for  Master and  Worker nodes

You should run the following command sets on all three nodes to get gpg keys and add repositories.

#curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
#sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

#curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

#cat << EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF

#sudo apt-get update

 

Step 2: Install docker, kubelet, kubeadm and  kubectl for  Master and  Worker nodes

Perform these steps for all nodes in the cluster. If you need to install specific version of any component you can change it as you wish. Also, it's possible to check the latest version with "apt list" command. 

#apt list  docker-ce
#sudo apt-get install -y docker-ce=5:19.03.8~3-0~ubuntu-bionic kubelet=1.18.2-00 kubeadm=1.18.2-00 kubectl=1.18.2-00

 

Step 3: Initialize Cluster

Run the following command in the master node to initialize the Kubernetes cluster. You should disable swap before running this step. "192.168.56.102" is  private ip address  of  master server.

#sudo kubeadm init --apiserver-advertise-address 192.168.56.102 --pod-network-cidr=10.225.0.0/16
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

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:

kubeadm join 192.168.56.102:6443 --token 1aa23n.cv2v8moy1eplc67e \
    --discovery-token-ca-cert-hash sha256:223ef1bf2d71a8bae2f0a05f02ec165efd4601aa4627dfd4dbaaf2a7dabbf887
root@master01:~#

Swap Error: 

#sudo kubeadm init --apiserver-advertise-address 192.168.56.102 --pod-network-cidr=10.225.0.0/16
W0506 22:33:57.562106    7930 configset.go:202] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]
[init] Using Kubernetes version: v1.18.2
[preflight] Running pre-flight checks
        [WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
error execution phase preflight: [preflight] Some fatal errors occurred:
        [ERROR Swap]: running with swap on is not supported. Please disable swap
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher

Step 4: Setup Default  Configuration on Master node

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

Step 5: Install Flannel for the Pod Network (On Master Node)

#kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/2140ac876ef134e0ed5af15c65e414cf26827915/Documentation/kube-flannel.yml
# kubectl  get  pods -n kube-system
NAME                               READY   STATUS    RESTARTS   AGE
coredns-66bff467f8-26wzg           0/1     Pending   0          16m
coredns-66bff467f8-8xcph           0/1     Pending   0          16m
etcd-master01                      1/1     Running   0          16m
kube-apiserver-master01            1/1     Running   0          16m
kube-controller-manager-master01   1/1     Running   0          16m
kube-flannel-ds-amd64-vhmmv        1/1     Running   0          20s
kube-proxy-882x2                   1/1     Running   0          16m
kube-scheduler-master01            1/1     Running   0          16m

Step 6: Join Worker nodes  to the cluster

root@worker01:~# kubeadm join 192.168.56.102:6443 --token 1aa23n.cv2v8moy1eplc67e  --discovery-token-ca-cert-hash sha256:223ef1bf2d71a8bae2f0a05f02ec165efd4601aa4627dfd4dbaaf2a7dabbf887
W0506 23:19:11.241333   19433 join.go:346] [preflight] WARNING: JoinControlPane.controlPlane settings will be ignored when control-plane flag is not set.
[preflight] Running pre-flight checks
        [WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
[preflight] Reading configuration from the cluster...
[preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml'
[kubelet-start] Downloading configuration for the kubelet from the "kubelet-config-1.18" ConfigMap in the kube-system namespace
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Starting the kubelet
[kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap...

This node has joined the cluster:
* Certificate signing request was sent to apiserver and a response was received.
* The Kubelet was informed of the new secure connection details.

Run 'kubectl get nodes' on the control-plane to see this node join the cluster.

root@worker01:~#

Components and Cluster Status

Check components  status:

root@master01:~# kubectl get cs
NAME                 STATUS    MESSAGE             ERROR
scheduler            Healthy   ok
controller-manager   Healthy   ok
etcd-0               Healthy   {"health":"true"}

 

Check cluster information:

root@master01:~# kubectl  cluster-info
Kubernetes master is running at https://192.168.56.102:6443
KubeDNS is running at https://192.168.56.102:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
root@master01:~# # kubectl version --short
Client Version: v1.18.2
Server Version: v1.18.2

Check node information:

root@master01:~# kubectl  get  nodes  -o wide
NAME       STATUS   ROLES    AGE   VERSION   INTERNAL-IP      EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION     CONTAINER-RUNTIME
master01   Ready    master   34m   v1.18.2   192.168.56.102   <none>        Ubuntu 18.04.4 LTS   5.3.0-28-generic   docker://19.3.8
worker01   Ready    <none>   32m   v1.18.2   192.168.56.103   <none>        Ubuntu 18.04.4 LTS   5.3.0-28-generic   docker://19.3.8

Check controller-manager version:

root@master01:~# kubectl  get  pod kube-controller-manager-master01 -o yaml -n kube-system|grep image:
            f:image: {}
    image: k8s.gcr.io/kube-controller-manager:v1.18.2
    image: k8s.gcr.io/kube-controller-manager:v1.18.2

Check kubeadm version:

root@master01:~# kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-16T11:54:15Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}

Run a deployment check if the application is running  on pod:

root@master01:~# kubectl  create deployment  nginx --image=nginx
deployment.apps/nginx created
root@master01:~# kubectl  get pods
NAME                    READY   STATUS              RESTARTS   AGE
nginx-f89759699-2cxgc   0/1     ContainerCreating   0          6s

root@master01:~# kubectl  port-forward nginx-f89759699-2cxgc 8081:80 &
[1] 29150
root@master01:~# Forwarding from 127.0.0.1:8081 -> 80
Forwarding from [::1]:8081 -> 80

root@master01:~# curl -s  -v  http://127.0.0.1:8081


 

 

I'm a IT Infrastructure and Operations Architect with extensive experience and administration skills and works for Turk Telekom. I provide hardware and software support for the IT Infrastructure and Operations tasks.

205 Total Posts
Follow Me

Related Post

86 Comments

  1. generac viagra order viagra with pay pal buy generic viagra canada http://llviabest.com/ - viagra in hamburg ’

  2. viagra paypal buy viagra onoine viagra australia http://genqpviag.com/ - viagra professional sublingual ’

  3. viagra pill viagra side effect or addiction where i can get viagra in sydney

  4. pharmacies in canada pharmacies shipping to usa Cialis Professional

  5. compare prescription prices pharmacies drug costs

  6. buy prescription drugs without doctor canadian rx pharmacy online rx price comparison

  7. online medicine shopping aarp recommended canadian pharmacies canada pharmacy online orders

  8. how much do viagra cost canada pharmaceuticals online viagra online australia

  9. northwest pharmacy/com prescription less viagra north west pharmacy canada

  10. starting cash loans business south africa 1st stop payday loans existing customer payday loans clayton ga

  11. cialis-farmaco.com cialis levitra viagra review alternating cialis and viagra

  12. ace check cashing loan reviews payday 2 cash hilesi list of payday loan lenders uk no credit check

  13. sunny cash loan review payday loans rifle co cash advance lynn haven fl

  14. fast cash loans malaysia cash advance rhode island payday loan max interest

  15. is cialis time release vente cialis en ligne cialis 20 prix en pharmacie

  16. sildenafil 110 mg capsule http://vigedon.com/ viagra 100 buy online

  17. online viagra prescription http://viagraonlinejc.com/ viagra with alcohol

  18. Does your site have a contact page? I'm having a tough time locating it but, I'd like to shoot you an e-mail. I've got some recommendations foor your blog you might be interested in hearing. Either way, great blog and I look forward to seeing it grow over time. https://clients1.google.com.mm/url?q=https://bestwwwkratom.com Wilhelmina Monty https://clients1.google.mv/url?q=https://kratomwwwtea.com

  19. generic cialis mastercard http://buycialisxz.com/ dgeneric cialis

  20. heartguard ivermectin ivermectin coronavirus 1.87 ivermectin paste for dogs what parasites does ivermectin kill

  21. ventolin prescription albuterol price uk is ventolin same as albuterol how to take albuterol inhaler

  22. soolantra ivermectin price of stromectol how to give ivermectin to dogs what parasit is resistant to ivermectin

  23. maculopapular rash amoxicillin where to buy amoxicillin pharmacy can i take amoxicillin with ibuprofen how many days to take amoxicillin 500mg

  24. ventolin jarabe albuterol cost in mexico ventolin inhaler for sale online what is albuterol sulfate

  25. furosemide water pill furosemide 20 mg price furosemide 20 mg pill identification how to adjust dosage of furosemide for dogs

  26. amoxicillin with alcohol amoxicillin 500 mg capsules can a dog take amoxicillin what to do if you miss a dose of amoxicillin

  27. lasix and breastfeeding furosemide price furosemide for high blood pressure what should you eat when taking furosemide?

  28. zithromax and alcohol zithromax 250 cost can zithromax treat a uti what is the medicine azithromycin used for

  29. zithromax 500mg buy azithromycin 1000mg what is zithromax z pak how long does azithromycin take

  30. online clomid cheap clomid tablets uk how much does clomid cost how much clomid should a man take

  31. doxycycline cystic acne buy vibramycin what is doxycycline hyc 100mg used for how long to have lyme to take doxycycline

  32. prednisolone ointment prednisolone prednisone prednisolone suppositories for ulcerative colitis what is the difference prednisolone sodium phosphate vs prednisolone acetate

  33. buying doxycycline online doxycycline 100 mg cap doxycycline treatment for lyme disease how long does it take doxycycline to leave your system

  34. androxal vs clomid where can you buy clomid clomiphene citrate (clomid) when do i start taking clomid

  35. steroids prednisolone generic prednisolone otc can prednisolone reduce pain in dogs how long before prednisolone 5mg works in dogs

  36. https://dissertationahelp.com/ - dissertation phd dissertation statistics help cheap dissertation help dissertation abstract

  37. priligy in canada generic priligy australia onde posso encontrar remedio priligy em usa what does dapoxetine look like

  38. https://thesisacloud.com/ - thesis search doctoral thesis help thesis writing service thesis help online

  39. https://thesisacloud.com/ - thesis help free thesis topics in education thesis publishing phd online

  40. http://essaywriteris.com/ - best online essay writer cheap essays to buy can i get someone to write my essay essay writer reviews

  41. https://thesisacloud.com/ - proquest thesis search thesis paper writing thesis editing service college thesis

  42. dangers of propecia generic propecia from canada how many years is propecia effective where can i get propecia no prescription

  43. prednisolone dexamethasone difference 100mg prednisolone hitech prednisolone buy online canada how does prednisolone help with mast cell cancer

  44. neurontin muscle pain cost of gabapentin 400 mg can you die from neurontin how to get high on gabapentin

  45. how metformin works buy metformin 500 mg uk metformin over the counter walmart how much b12 should i take with metformin

  46. xanax and paxil buy paroxetine australia side effects of getting off paxil what are the effects of taking paxil and mobic

  47. https://thesiswritingtob.com/ - thesiswritingtob.com thesis proposal help thesiswritingtob.com thesis defense advice

  48. plaquenil and sulfa plaquenil price what is plaquenil 200 mg used for who make plaquenil

  49. generic viagra pills: viagra pills pills for erectile dysfunction https://edpillsonline24.com/# erectile dysfunction pills

  50. male erectile pills: kamagra pills viagra pills https://edpillsonline24.com/# ed pills

  51. cialis pills online: best erectile dysfunction pills review male erectile pills https://edpillsonline24.com/# erectile pills canada

  52. viagra otc buy viagra online without prescription no prescription viagra https://swdprescription.com/# buy viagra without prescription

  53. viagra doses 200 mg buying viagra online without prescription viagra without a doctor prescription usa https://swdprescription.com/# buy viagra online without prescription

  54. buy viagra online viagra no prescription buying viagra online without prescription https://swdprescription.com/# viagra prescription

  55. viagra generic viagra without a doctor prescription usa viagra without a doctor prescription usa https://swdprescription.com/# viagra without a doctor prescription

  56. viagra canada no prescription viagra viagra without a doctor prescription usa https://swdprescription.com/# viagra without prescription

  57. how to get viagra without a doctor viagra prescription no prescription viagra https://swdprescription.com/# buy viagra online without prescription

  58. over the counter viagra cvs viagra without a doctor prescription viagra without a doctor prescription canada https://swdprescription.com/# viagra no prescription

  59. viagra for sale viagra without prescription viagra prescription https://swdprescription.com/# buy viagra online without prescription

  60. viagra without a doctor prescription buy viagra without prescription buy viagra online without prescription https://swdprescription.com/# no prescription viagra

  61. viagra price comparison viagra without a doctor prescription no prescription viagra https://swdprescription.com/# viagra without prescription

  62. buy generic 100mg viagra online no prescription viagra buy viagra without prescription https://swdprescription.com/# buy viagra online without prescription

  63. https://amoxilst.com/# amoxicillin 500mg price in canada

  64. https://amoxilst.com/# amoxicillin 500mg prescription

  65. http://clomidst.com/# clomid canada

  66. https://doxycyclinest.com/# buy doxycycline without prescription

  67. https://clomidst.com/# online clomid

  68. https://amoxilst.com/# price of amoxicillin without insurance

  69. https://doxycyclinest.com/# doxycycline order online

  70. http://amoxilst.com/# can you buy amoxicillin uk

  71. https://diflucanst.com/# can i buy diflucan from canada

  72. https://doxycyclinest.com/# doxycycline medication

  73. http://amoxilst.com/# amoxicillin 500mg price

  74. https://clomidst.com/# clomid for men

  75. clomid generic name purchase clomid online and clomid pills and clomid alcohol and buy clomid online and clomiphene generic http://caymanshoresdevelopment.com/__media__/js/netsoltrademark.php?d=clomidst.com/ http://1-800date.com/__media__/js/netsoltrademark.php?d=clomidst.com http://internationallight.org/__media__/js/netsoltrademark.php?d=clomidst.com http://cinemadelux.biz/__media__/js/netsoltrademark.php?d=clomidst.com&popup=1 http://raywild.com/__media__/js/netsoltrademark.php?d=clomidst.com/

  76. buy clomid online no prescription generic for clomid and cheap clomid and clomid 2020 and order clomid and clomid purchase online http://isnotis2.com/__media__/js/netsoltrademark.php?d=clomidst.com/ http://www.chinamusicbookshop.com/bbs/home.php?mod=space&uid=619840 https://qmwe.xyz/home.php?mod=space&uid=741722 http://ky.sgz8.com/home.php?mod=space&uid=371663 https://gevezesohbet.com.tc/members/48160.html

  77. clomiphene for sale clomid medication and clomid online and clomid buy and clomid price and clomid purchase http://niubi.gg/home.php?mod=space&uid=411751 http://www.fxwenxue.com/home.php?mod=space&uid=227082 http://clearanceuk.com/__media__/js/netsoltrademark.php?d=clomidst.com/ http://turpaahjul.com/forum/member.php?1881658-jblmotkl http://www.sj868.cn/home.php?mod=space&uid=909590

  78. clomid tablet clomid for sale and purchase clomid and clomid buy and buy clomid online without prescription and buy clomid online http://anchmedsurg.com/__media__/js/netsoltrademark.php?d=clomidst.com https://forum.lsbclan.net/index.php?action=profile;u=103475 http://www.questrecruitment.co.nz/ra.asp?url=https://clomidst.com http://coatingsinspection.com/__media__/js/netsoltrademark.php?d=clomidst.com http://thesingaporesting.com/__media__/js/netsoltrademark.php?d=clomidst.com

  79. clomid without prescription buy cheap clomid and buy clomid 50mg and cost of clomid and clomid online cheap and order clomid http://environmentalscreenprinters.com/__media__/js/netsoltrademark.php?d=clomidst.com/ http://afterschoolpro.net/__media__/js/netsoltrademark.php?d=clomidst.com/ http://garciasmartcar.com/__media__/js/netsoltrademark.php?d=clomidst.com http://www.copperpages.com/redir.asp?id=97921&account=0§ion=13&url=https://clomidst.com http://nqbtv.com/home.php?mod=space&uid=3148599

  80. clomid 100mg clomid order online and cheap clomid and cost of clomid and clomid tablet and generic for clomid http://allwineallthetime.com/__media__/js/netsoltrademark.php?d=clomidst.com http://xchip.org/__media__/js/netsoltrademark.php?d=clomidst.com http://fishcasslake.com/__media__/js/netsoltrademark.php?d=clomidst.com http://allenbjones.com/__media__/js/netsoltrademark.php?d=clomidst.com http://www.jswz8.com/space-uid-725676.html

  81. clomid online clomiphene tablets and clomid for sale and order clomiphene and price of clomid and buy clomid online without prescription http://www.hyphoto.net/space-uid-918408.html http://circustube.com/te/out.php?u=https://clomidst.com http://signatureeurope.com/__media__/js/netsoltrademark.php?d=clomidst.com/ http://telavivnightlife.com/__media__/js/netsoltrademark.php?d=clomidst.com http://rolldownshutterrepair.com/__media__/js/netsoltrademark.php?d=clomidst.com/

  82. no prescription clomid clomiphene tablets and buy cheap clomid and clomid alcohol and clomid tablets and cheap clomid http://shahcommunications.net/__media__/js/netsoltrademark.php?d=clomidst.com/ http://i-secq.net/__media__/js/netsoltrademark.php?d=clomidst.com http://anchmedsurg.com/__media__/js/netsoltrademark.php?d=clomidst.com/ http://mahalodrinks.com/__media__/js/netsoltrademark.php?d=clomidst.com http://ticketpoints.com/__media__/js/netsoltrademark.php?d=clomidst.com

  83. how to get metformin without prescription: metformin 125 mg - metformin 1000 mg from canada http://edpillsonline24.online/# ed pills that really work

  84. lasix 20 mg: lasix - lasix 100mg http://lasixst.com/# lasix for sale

  85. real metformin mexico: metformin prices canada - metformin 250 mg price in india https://lasixst.com/# lasix for sale

  86. lasix generic name: lasix generic - lasix 100mg http://edpillsonline24.online/# ed medications

Leave a Reply