{"id":3833,"date":"2024-03-19T20:49:33","date_gmt":"2024-03-19T20:49:33","guid":{"rendered":"https:\/\/code2deploy.com\/blog\/?p=3833"},"modified":"2024-03-19T20:49:33","modified_gmt":"2024-03-19T20:49:33","slug":"setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script","status":"publish","type":"post","link":"https:\/\/code2deploy.com\/blog\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\/","title":{"rendered":"Setting Up a Self-Managed Kubernetes Cluster on Ubuntu 22.04 with Kubeadm and Bash Script"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In this tutorial, we&#8217;ll walk through the process of setting up a Kubernetes cluster on Ubuntu 22.04 using Kubeadm, focusing on an on-premise environment with specific hardware and software prerequisites.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Hardware Prerequisites:<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Master Node:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Minimum 4GB RAM, 4 Core CPU<\/li>\n\n\n\n<li>1GB Ethernet NIC<\/li>\n\n\n\n<li>40GB Hard Disk Space<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Worker Node:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Minimum 2GB RAM, 2 Core CPU<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Software Prerequisites:<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Container Runtime:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Docker, CRI-O, ContainerD (Choose one)<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Kubernetes Tools:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Kubeadm<\/li>\n\n\n\n<li>Kubectl<\/li>\n\n\n\n<li>Kubelet<\/li>\n\n\n\n<li>Kubernetes CNI<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Installation Steps:<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Prepare the Environment:<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Ensure SWAP memory is disabled and necessary prerequisites are installed on both master and worker nodes. This includes the container runtime, <strong>Kubeadm, Kubectl, Kubelet, and Kubernetes CNI.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Bash-Script-1:<\/strong><strong> This script is for both servers(Master and Worker Node), run this script on both servers&nbsp;<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step-1:&nbsp;<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Copy the script and make a sh file on your on-prem <strong>Master<\/strong> and <strong>Worker Nodes&nbsp;<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>sudo vim common-k8s.sh<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>#!\/bin\/bash<br>#<br># Common setup for all servers (Control Plane and Nodes)<br><br>set -euxo pipefail<br><br># Kuernetes Variable Declaration<br><br>KUBERNETES_VERSION=&#8221;1.29.0-1.1&#8243;<br><br># disable swap<br>sudo swapoff -a<br><br># keeps the swaf off during reboot<br>(crontab -l 2&gt;\/dev\/null; echo &#8220;@reboot \/sbin\/swapoff -a&#8221;) | crontab &#8211; || true<br>sudo apt-get update -y<br><br><br># Install CRI-O Runtime<br><br>OS=&#8221;xUbuntu_22.04&#8243;<br><br>VERSION=&#8221;1.28&#8243;<br><br># Create the .conf file to load the modules at bootup<br>cat &lt;&lt;EOF | sudo tee \/etc\/modules-load.d\/k8s.conf<br>overlay<br>br_netfilter<br>EOF<br><br>sudo modprobe overlay<br>sudo modprobe br_netfilter<br><br># sysctl params required by setup, params persist across reboots<br>cat &lt;&lt;EOF | sudo tee \/etc\/sysctl.d\/k8s.conf<br>net.bridge.bridge-nf-call-iptables&nbsp; = 1<br>net.bridge.bridge-nf-call-ip6tables = 1<br>net.ipv4.ip_forward &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = 1<br>EOF<br><br># Apply sysctl params without reboot<br>sudo sysctl &#8211;system<br><br>cat &lt;&lt;EOF | sudo tee \/etc\/apt\/sources.list.d\/devel:kubic:libcontainers:stable.list<br>deb https:\/\/download.opensuse.org\/repositories\/devel:\/kubic:\/libcontainers:\/stable\/$OS\/ \/<br>EOF<br>cat &lt;&lt;EOF | sudo tee \/etc\/apt\/sources.list.d\/devel:kubic:libcontainers:stable:cri-o:$VERSION.list<br>deb http:\/\/download.opensuse.org\/repositories\/devel:\/kubic:\/libcontainers:\/stable:\/cri-o:\/$VERSION\/$OS\/ \/<br>EOF<br><br>curl -L https:\/\/download.opensuse.org\/repositories\/devel:kubic:libcontainers:stable:cri-o:$VERSION\/$OS\/Release.key | sudo apt-key &#8211;keyring \/etc\/apt\/trusted.gpg.d\/libcontainers.gpg add &#8211;<br>curl -L https:\/\/download.opensuse.org\/repositories\/devel:\/kubic:\/libcontainers:\/stable\/$OS\/Release.key | sudo apt-key &#8211;keyring \/etc\/apt\/trusted.gpg.d\/libcontainers.gpg add &#8211;<br><br>sudo apt-get update<br>sudo apt-get install cri-o cri-o-runc -y<br><br>sudo systemctl daemon-reload<br>sudo systemctl enable crio &#8211;now<br><br>echo &#8220;CRI runtime installed susccessfully&#8221;<br><br># Install kubelet, kubectl and Kubeadm<br><br>sudo apt-get update -y<br>sudo apt-get install -y apt-transport-https ca-certificates curl gpg<br><br>curl -fsSL https:\/\/pkgs.k8s.io\/core:\/stable:\/v1.28\/deb\/Release.key | sudo gpg &#8211;dearmor -o \/etc\/apt\/keyrings\/kubernetes-1-28-apt-keyring.gpg<br>echo &#8216;deb [signed-by=\/etc\/apt\/keyrings\/kubernetes-1-28-apt-keyring.gpg] https:\/\/pkgs.k8s.io\/core:\/stable:\/v1.28\/deb\/ \/&#8217; | sudo tee \/etc\/apt\/sources.list.d\/kubernetes-1.28.list<br><br>curl -fsSL https:\/\/pkgs.k8s.io\/core:\/stable:\/v1.29\/deb\/Release.key | sudo gpg &#8211;dearmor -o \/etc\/apt\/keyrings\/kubernetes-1-29-apt-keyring.gpg<br>echo &#8216;deb [signed-by=\/etc\/apt\/keyrings\/kubernetes-1-29-apt-keyring.gpg] https:\/\/pkgs.k8s.io\/core:\/stable:\/v1.29\/deb\/ \/&#8217; | sudo tee \/etc\/apt\/sources.list.d\/kubernetes-1.29.list<br><br>sudo apt-get update -y<br>sudo apt-get install -y kubelet=&#8221;$KUBERNETES_VERSION&#8221; kubectl=&#8221;$KUBERNETES_VERSION&#8221; kubeadm=&#8221;$KUBERNETES_VERSION&#8221;<br>sudo apt-get update -y<br>sudo apt-mark hold kubelet kubeadm kubectl<br><br>sudo apt-get install -y jq<br><br>local_ip=&#8221;$(ip &#8211;json addr show eth0 | jq -r &#8216;.[0].addr_info[] | select(.family == &#8220;inet&#8221;) | .local&#8217;)&#8221;<br>cat &gt; \/etc\/default\/kubelet &lt;&lt; EOF<br>KUBELET_EXTRA_ARGS=&#8211;node-ip=$local_ip<br>EOF<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Allow the execution permission&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>sudo chmod +x common-k8s.sh#run the script&nbsp;sudo .\/common-k8s.sh<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">2. Initialize Kubernetes Cluster:<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Bash-Script-2:<\/strong><strong> this script is only for the Master, run this script on the master node.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step-2<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Copy the script and make a <strong>sh<\/strong> file on your on-prem <strong>Master Node<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>sudo <\/strong><strong>vim<\/strong><strong> master-init-k8s.<\/strong><strong>sh<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note: if you use public IP set here <\/strong><strong>PUBLIC_IP_ACCESS=<\/strong><strong>&#8220;true&#8221;&nbsp;&nbsp;&nbsp;&nbsp;<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you use private IP you must change it<strong> <\/strong><strong>PUBLIC_IP_ACCESS=<\/strong><strong>&#8220;false&#8221;<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>#!\/bin\/bash<\/strong><strong><br><\/strong><strong>#<\/strong><strong><br><\/strong><strong># Setup for Control Plane (Master) servers<\/strong><strong><br><\/strong><strong><br><\/strong><strong>set<\/strong><strong> -euxo pipefail<\/strong><strong><br><\/strong><strong><br><\/strong><strong># If you need public access to API server using the servers Public IP adress, change PUBLIC_IP_ACCESS to true.<\/strong><strong><br><\/strong><strong><br><\/strong><strong>PUBLIC_IP_ACCESS=<\/strong><strong>&#8220;true&#8221;<\/strong><strong><br><\/strong><strong>NODENAME=$(hostname -s)<\/strong><strong><br><\/strong><strong>POD_CIDR=<\/strong><strong>&#8220;192.168.0.0\/16&#8221;<\/strong><strong><br><\/strong><strong><br><\/strong><strong># Pull required images<\/strong><strong><br><\/strong><strong><br><\/strong><strong>sudo kubeadm config images pull<\/strong><strong><br><\/strong><strong><br><\/strong><strong># Initialize kubeadm based on PUBLIC_IP_ACCESS<\/strong><strong><br><\/strong><strong><br><\/strong><strong>if<\/strong><strong> [[ <\/strong><strong>&#8220;<\/strong><strong>$PUBLIC_IP_ACCESS<\/strong><strong>&#8220;<\/strong><strong> == <\/strong><strong>&#8220;false&#8221;<\/strong><strong> ]]; <\/strong><strong>then<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; <\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; MASTER_PRIVATE_IP=$(ip addr show eth0 | awk <\/strong><strong>&#8216;\/inet \/ {print $2}&#8217;<\/strong><strong> | cut -d\/ -f1)<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; sudo kubeadm init &#8211;apiserver-advertise-address=<\/strong><strong>&#8220;<\/strong><strong>$MASTER_PRIVATE_IP<\/strong><strong>&#8220;<\/strong><strong> &#8211;apiserver-cert-extra-sans=<\/strong><strong>&#8220;<\/strong><strong>$MASTER_PRIVATE_IP<\/strong><strong>&#8220;<\/strong><strong> &#8211;pod-network-cidr=<\/strong><strong>&#8220;<\/strong><strong>$POD_CIDR<\/strong><strong>&#8220;<\/strong><strong> &#8211;node-name <\/strong><strong>&#8220;<\/strong><strong>$NODENAME<\/strong><strong>&#8220;<\/strong><strong> &#8211;ignore-preflight-errors Swap<\/strong><strong><br><\/strong><strong><br><\/strong><strong>elif<\/strong><strong> [[ <\/strong><strong>&#8220;<\/strong><strong>$PUBLIC_IP_ACCESS<\/strong><strong>&#8220;<\/strong><strong> == <\/strong><strong>&#8220;true&#8221;<\/strong><strong> ]]; <\/strong><strong>then<\/strong><strong><br><\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; MASTER_PUBLIC_IP=$(curl ifconfig.me &amp;&amp; <\/strong><strong>echo<\/strong><strong> <\/strong><strong>&#8220;&#8221;<\/strong><strong>)<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; sudo kubeadm init &#8211;control-plane-endpoint=<\/strong><strong>&#8220;<\/strong><strong>$MASTER_PUBLIC_IP<\/strong><strong>&#8220;<\/strong><strong> &#8211;apiserver-cert-extra-sans=<\/strong><strong>&#8220;<\/strong><strong>$MASTER_PUBLIC_IP<\/strong><strong>&#8220;<\/strong><strong> &#8211;pod-network-cidr=<\/strong><strong>&#8220;<\/strong><strong>$POD_CIDR<\/strong><strong>&#8220;<\/strong><strong> &#8211;node-name <\/strong><strong>&#8220;<\/strong><strong>$NODENAME<\/strong><strong>&#8220;<\/strong><strong> &#8211;ignore-preflight-errors Swap<\/strong><strong><br><\/strong><strong><br><\/strong><strong>else<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; <\/strong><strong>echo<\/strong><strong> <\/strong><strong>&#8220;Error: MASTER_PUBLIC_IP has an invalid value: <\/strong><strong>$PUBLIC_IP_ACCESS<\/strong><strong>&#8220;<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; <\/strong><strong>exit<\/strong><strong> 1<\/strong><strong><br><\/strong><strong>fi<\/strong><strong><br><\/strong><strong><br><\/strong><strong># Configure kubeconfig<\/strong><strong><br><\/strong><strong><br><\/strong><strong>mkdir -p <\/strong><strong>&#8220;<\/strong><strong>$HOME<\/strong><strong>&#8220;<\/strong><strong>\/.kube<\/strong><strong><br><\/strong><strong>sudo cp -i \/etc\/kubernetes\/admin.conf <\/strong><strong>&#8220;<\/strong><strong>$HOME<\/strong><strong>&#8220;<\/strong><strong>\/.kube\/config<\/strong><strong><br><\/strong><strong>sudo chown <\/strong><strong>&#8220;<\/strong><strong>$(id -u)<\/strong><strong>&#8220;<\/strong><strong>:<\/strong><strong>&#8220;<\/strong><strong>$(id -g)<\/strong><strong>&#8220;<\/strong><strong> <\/strong><strong>&#8220;<\/strong><strong>$HOME<\/strong><strong>&#8220;<\/strong><strong>\/.kube\/config<\/strong><strong><br><\/strong><strong><br><\/strong><strong># Install Claico Network Plugin Network <\/strong><strong><br><\/strong><strong><br><\/strong><strong>kubectl apply -f https:\/\/docs.projectcalico.org\/manifests\/calico.yaml<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Allow the execution permission&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>sudo chmod +x <\/strong><strong>master<\/strong><strong>-init-k8s.sh<\/strong><strong>#run the script&nbsp;<\/strong><strong>sudo .\/<\/strong><strong>master<\/strong><strong>-init-k8s.sh<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step-3:&nbsp;<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Join the worker node into the master node:&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After initializing the master node you will get the worker node join token, and run the join command.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step-4&nbsp;<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Verify the worker node is connected&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl get node<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">3. Configure kubectl:<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Copy the kube config file from the master node to your local workstation.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>mkdir ~\/.kube<br>scp user@master-node:\/etc\/kubernetes\/admin.conf ~\/.kube\/config<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Imperative Way of Managing Kubernetes Resources:<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Pod Operations:<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td># Create a pod with dry run<br>kubectl run todo-express &#8211;image=enam92\/todo-express:v1 &#8211;dry-run=client<br><br># Expose pod using NodePort service<br>kubectl expose pod todo-express &#8211;port=3000 &#8211;type=NodePort<br><br># Inspect pod details<br>kubectl get pods -o wide<br>kubectl logs todo-express<br>kubectl exec -ti todo-express &#8212; bash<br><br># Delete pod<br>kubectl delete pod todo-express<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Service Operations:<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td># Delete service<br>kubectl delete service &lt;ServiceName&gt;<br><br># Expose deployment<br>kubectl expose deployment todo-express &#8211;port=3000 &#8211;type=NodePort<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Deployment Operations:<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td># Create deployment<br>kubectl create deployment todo-express &#8211;image=enam92\/todo-express:v1<br><br># Scale replicas<br>kubectl scale deployments todo-express &#8211;replicas=3<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Kubernetes Manifest Examples:<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Deployment <\/strong><strong>Demo Manifest<\/strong><strong>:<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>apiVersion: apps\/v1<br>kind: Deployment<br><br>metadata:<br>&nbsp; name: my-deployment&nbsp; # Name of the Deployment<br><br>spec:<br>&nbsp; replicas: 3&nbsp; # Desired number of replicas<br>&nbsp; selector:<br>&nbsp; &nbsp; matchLabels:<br>&nbsp; &nbsp; &nbsp; app: my-app&nbsp; # Label selector to match Pods controlled by this Deployment<br>&nbsp; template:&nbsp; # Template for creating Pods<br>&nbsp; &nbsp; metadata:<br>&nbsp; &nbsp; &nbsp; labels:<br>&nbsp; &nbsp; &nbsp; &nbsp; app: my-app&nbsp; # Labels for Pods created from this template<br>&nbsp; &nbsp; spec:<br>&nbsp; &nbsp; &nbsp; containers:&nbsp; # List of containers in the Pod<br>&nbsp; &nbsp; &nbsp; &#8211; name: nginx-container&nbsp; # Name of the container<br>&nbsp; &nbsp; &nbsp; &nbsp; image: nginx:latest&nbsp; # Container image to use<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Pod <\/strong><strong>Demo Manifest<\/strong><strong>:<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>apiVersion<\/strong><strong>: v1<\/strong><strong><br><\/strong><strong>kind<\/strong><strong>: Pod<\/strong><strong><br><\/strong><strong><br><\/strong><strong>metadata:<\/strong><strong><br><\/strong><strong>&nbsp; name: <\/strong><strong>my-pod<\/strong><strong>&nbsp; <\/strong><strong># Name of the Pod<\/strong><strong><br><\/strong><strong><br><\/strong><strong>spec:<\/strong><strong><br><\/strong><strong>&nbsp; containers:&nbsp; <\/strong><strong># List of containers in the Pod<\/strong><strong><br><\/strong><strong>&nbsp; &#8211; name: <\/strong><strong>nginx-container<\/strong><strong>&nbsp; <\/strong><strong># Name of the container<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; image: nginx:latest&nbsp; <\/strong><strong># Container image to use<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Service Demo Manifest:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>apiVersion: v1<\/strong><strong><br><\/strong><strong>kind:<\/strong><strong> Service<\/strong><strong><br><\/strong><strong><br><\/strong><strong>metadata:<\/strong><strong><br><\/strong><strong>&nbsp; name: my-service&nbsp; # Name of the<\/strong><strong> Service<\/strong><strong><br><\/strong><strong><br><\/strong><strong>spec:<\/strong><strong><br><\/strong><strong>&nbsp; selector:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; app: my-app&nbsp; # Label selector <\/strong><strong>to<\/strong><strong> match Pods<\/strong><strong><br><\/strong><strong>&nbsp; ports:<\/strong><strong><br><\/strong><strong>&nbsp; &#8211; protocol: TCP<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; port: 80&nbsp; #<\/strong><strong> Port <\/strong><strong>exposed by the<\/strong><strong> Service<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; targetPort: 80&nbsp; #<\/strong><strong> Port <\/strong><strong>on the Pods<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Ingres Demo Manifest:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>apiVersion<\/strong><strong>: networking.k8s.io\/v1<\/strong><strong><br><\/strong><strong>kind<\/strong><strong>: Ingress<\/strong><strong><br><\/strong><strong><br><\/strong><strong>metadata:<\/strong><strong><br><\/strong><strong>&nbsp; name: my-ingress&nbsp; # Name of the Ingress<\/strong><strong><br><\/strong><strong><br><\/strong><strong>spec:<\/strong><strong><br><\/strong><strong>&nbsp; rules:<\/strong><strong><br><\/strong><strong>&nbsp; &#8211; http:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; paths:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; &#8211; path: \/&nbsp; # Path <\/strong><strong>for<\/strong><strong> the Ingress<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; &nbsp; pathType:<\/strong><strong> Prefix<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; &nbsp; backend:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; service:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: my-service&nbsp; #<\/strong><strong> Service <\/strong><strong>to<\/strong><strong> forward traffic <\/strong><strong>to<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; port:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; number: 80&nbsp; #<\/strong><strong> Port <\/strong><strong>of the Service<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Config-Map Demo Manifest:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>apiVersion<\/strong><strong>: v1<\/strong><strong><br><\/strong><strong>kind<\/strong><strong>: ConfigMap<\/strong><strong><br><\/strong><strong><br><\/strong><strong>metadata:<\/strong><strong><br><\/strong><strong>&nbsp; name: <\/strong><strong>my-configmap<\/strong><strong>&nbsp; <\/strong><strong># Name of the ConfigMap<\/strong><strong><br><\/strong><strong><br><\/strong><strong>data:<\/strong><strong><br><\/strong><strong>&nbsp; key1: <\/strong><strong>value1<\/strong><strong>&nbsp; <\/strong><strong># Key-value pairs with configuration data<\/strong><strong><br><\/strong><strong>&nbsp; key2: <\/strong><strong>value2<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Persistent-Volume Demo Manifest:&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>apiVersion<\/strong><strong>: v1<\/strong><strong><br><\/strong><strong>kind<\/strong><strong>: PersistentVolume<\/strong><strong><br><\/strong><strong><br><\/strong><strong>metadata:<\/strong><strong><br><\/strong><strong>&nbsp; name: <\/strong><strong>my-pv<\/strong><strong>&nbsp; <\/strong><strong># Name of the PersistentVolume<\/strong><strong><br><\/strong><strong><br><\/strong><strong>spec:<\/strong><strong><br><\/strong><strong>&nbsp; capacity:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; storage: <\/strong><strong>1<\/strong><strong>Gi<\/strong><strong>&nbsp; <\/strong><strong># Capacity of the volume<\/strong><strong><br><\/strong><strong>&nbsp; volumeMode: <\/strong><strong>Filesystem<\/strong><strong><br><\/strong><strong>&nbsp; accessModes:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &#8211;<\/strong><strong> <\/strong><strong>ReadWriteOnce<\/strong><strong>&nbsp; <\/strong><strong># Access mode for the volume<\/strong><strong><br><\/strong><strong>&nbsp; persistentVolumeReclaimPolicy: <\/strong><strong>Retain<\/strong><strong><br><\/strong><strong>&nbsp; storageClassName: <\/strong><strong>standard<\/strong><strong>&nbsp; <\/strong><strong># Storage class for dynamic provisioning<\/strong><strong><br><\/strong><strong>&nbsp; hostPath:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; path: <\/strong><strong>\/data\/my-pv<\/strong><strong>&nbsp; <\/strong><strong># Path on the host machine<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Persistent-VolumeClaim Demo Manifest:&nbsp;<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>apiVersion<\/strong><strong>: v1<\/strong><strong><br><\/strong><strong>kind<\/strong><strong>: PersistentVolumeClaim<\/strong><strong><br><\/strong><strong><br><\/strong><strong>metadata:<\/strong><strong><br><\/strong><strong>&nbsp; name: <\/strong><strong>my-pvc<\/strong><strong>&nbsp; <\/strong><strong># Name of the PersistentVolumeClaim<\/strong><strong><br><\/strong><strong><br><\/strong><strong>spec:<\/strong><strong><br><\/strong><strong>&nbsp; accessModes:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &#8211;<\/strong><strong> <\/strong><strong>ReadWriteOnce<\/strong><strong>&nbsp; <\/strong><strong># Access mode for the claim<\/strong><strong><br><\/strong><strong>&nbsp; resources:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; requests:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; storage: <\/strong><strong>500<\/strong><strong>Mi<\/strong><strong>&nbsp; <\/strong><strong># Requested storage capacity<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>ReplicaController Demo Manifest:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>apiVersion<\/strong><strong>: v1<\/strong><strong><br><\/strong><strong>kind<\/strong><strong>: ReplicationController<\/strong><strong><br><\/strong><strong>metadata<\/strong><strong>:<\/strong><strong><br><\/strong><strong>&nbsp; <\/strong><strong>name<\/strong><strong>: myapp-rc<\/strong><strong><br><\/strong><strong>&nbsp; <\/strong><strong>labels<\/strong><strong>:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; <\/strong><strong>app<\/strong><strong>: myapp<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; <\/strong><strong>type<\/strong><strong>: frontend<\/strong><strong><br><\/strong><strong>spec<\/strong><strong>:<\/strong><strong><br><\/strong><strong>&nbsp; <\/strong><strong>template<\/strong><strong>:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; <\/strong><strong>metadata<\/strong><strong>:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; <\/strong><strong>name<\/strong><strong>: myapp-pod<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; <\/strong><strong>labels<\/strong><strong>:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; &nbsp; <\/strong><strong>app<\/strong><strong>: myapp<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; &nbsp; <\/strong><strong>type<\/strong><strong>: frontend<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; <\/strong><strong>spec<\/strong><strong>:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; <\/strong><strong>containers<\/strong><strong>:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; &nbsp; &#8211; <\/strong><strong>name<\/strong><strong>: nginx-container<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/strong><strong>image<\/strong><strong>: nginx<\/strong><strong><br><\/strong><strong>&nbsp; <\/strong><strong>replicas<\/strong><strong>: <\/strong><strong>3<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Replicaset Demo Manifest:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>apiVersion<\/strong><strong>: apps\/v1<\/strong><strong><br><\/strong><strong>kind<\/strong><strong>: ReplicaSet<\/strong><strong><br><\/strong><strong>metadata<\/strong><strong>:<\/strong><strong><br><\/strong><strong>&nbsp; <\/strong><strong>name<\/strong><strong>: myapp-rc<\/strong><strong><br><\/strong><strong>&nbsp; <\/strong><strong>labels<\/strong><strong>:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; <\/strong><strong>app<\/strong><strong>: myapp<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; <\/strong><strong>type<\/strong><strong>: frontend<\/strong><strong><br><\/strong><strong>spec<\/strong><strong>:<\/strong><strong><br><\/strong><strong>&nbsp; <\/strong><strong>template<\/strong><strong>:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; <\/strong><strong>metadata<\/strong><strong>:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; <\/strong><strong>name<\/strong><strong>: myapp-pod<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; <\/strong><strong>labels<\/strong><strong>:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; &nbsp; <\/strong><strong>app<\/strong><strong>: myapp<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; &nbsp; <\/strong><strong>type<\/strong><strong>: frontend<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; <\/strong><strong>spec<\/strong><strong>:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; <\/strong><strong>containers<\/strong><strong>:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; &nbsp; &#8211; <\/strong><strong>name<\/strong><strong>: nginx-container<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/strong><strong>image<\/strong><strong>: nginx<\/strong><strong><br><\/strong><strong>&nbsp; <\/strong><strong>replicas<\/strong><strong>: <\/strong><strong>3<\/strong><strong><br><\/strong><strong>&nbsp; <\/strong><strong>selector<\/strong><strong>:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; <\/strong><strong>matchLabels<\/strong><strong>:<\/strong><strong><br><\/strong><strong>&nbsp; &nbsp; &nbsp; <\/strong><strong>type<\/strong><strong>: frontend<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Replicaset OP Commands:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>kubectl <\/strong><strong>create<\/strong><strong> -f replicaset-definiation.yaml<\/strong><strong><br><\/strong><strong>Kubectl <\/strong><strong>get<\/strong><strong> replicaset myapp-replicaset<\/strong><strong><br><\/strong><strong>kubectl <\/strong><strong>delete<\/strong><strong> replicaset myapp-replicaset<\/strong><strong><br><\/strong><strong>kubectl <\/strong><strong>replace<\/strong><strong> -f replicaset-definition.yml<\/strong><strong><br><\/strong><strong>kubectl scale -replicas=<\/strong><strong>6<\/strong><strong> -f replicaset-definition.yml<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Follow these steps and examples to set up and manage your Kubernetes cluster effectively. Kubernetes provides powerful features for orchestrating and managing containerized applications at scale, enabling efficient resource utilization and automated deployment processes.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Self-Managed Kubernetes Cluster Setup with bash script <\/p>\n","protected":false},"author":1,"featured_media":3834,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,216,107],"tags":[273,10,272,274],"class_list":["post-3833","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-kubernetes","category-kubernetes-basic","category-shell-scripting","tag-kubeadm","tag-kubernetes","tag-kubernetes-cluster-setup","tag-kubernetes-self-hosted-cluster"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Setting Up a Self-Managed Kubernetes Cluster on Ubuntu 22.04 with Kubeadm and Bash Script - code2deploy.com<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.code2deploy.com\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Setting Up a Self-Managed Kubernetes Cluster on Ubuntu 22.04 with Kubeadm and Bash Script - code2deploy.com\" \/>\n<meta property=\"og:description\" content=\"Self-Managed Kubernetes Cluster Setup with bash script\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.code2deploy.com\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\/\" \/>\n<meta property=\"og:site_name\" content=\"code2deploy.com\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-19T20:49:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/blog.code2deploy.com\/wp-content\/uploads\/2024\/03\/Self-Managed-Kubernetes-Cluster.png\" \/>\n\t<meta property=\"og:image:width\" content=\"714\" \/>\n\t<meta property=\"og:image:height\" content=\"515\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"enam\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"enam\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\\\/\"},\"author\":{\"name\":\"enam\",\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#\\\/schema\\\/person\\\/e46930c19b999a87f12566fa8357481b\"},\"headline\":\"Setting Up a Self-Managed Kubernetes Cluster on Ubuntu 22.04 with Kubeadm and Bash Script\",\"datePublished\":\"2024-03-19T20:49:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\\\/\"},\"wordCount\":1706,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#\\\/schema\\\/person\\\/e46930c19b999a87f12566fa8357481b\"},\"image\":{\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/Self-Managed-Kubernetes-Cluster.png\",\"keywords\":[\"Kubeadm\",\"kubernetes\",\"kubernetes cluster setup\",\"kubernetes self-hosted cluster\"],\"articleSection\":[\"Kubernetes\",\"Kubernetes Basic\",\"SHELL Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\\\/\",\"url\":\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\\\/\",\"name\":\"Setting Up a Self-Managed Kubernetes Cluster on Ubuntu 22.04 with Kubeadm and Bash Script - code2deploy.com\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/Self-Managed-Kubernetes-Cluster.png\",\"datePublished\":\"2024-03-19T20:49:33+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\\\/#primaryimage\",\"url\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/Self-Managed-Kubernetes-Cluster.png\",\"contentUrl\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/Self-Managed-Kubernetes-Cluster.png\",\"width\":714,\"height\":515,\"caption\":\"Self-Managed Kubernetes Cluster Setup with bash script\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Setting Up a Self-Managed Kubernetes Cluster on Ubuntu 22.04 with Kubeadm and Bash Script\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/\",\"name\":\"code2deploy.com\\\/blog\",\"description\":\"TechOps\",\"publisher\":{\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#\\\/schema\\\/person\\\/e46930c19b999a87f12566fa8357481b\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#\\\/schema\\\/person\\\/e46930c19b999a87f12566fa8357481b\",\"name\":\"enam\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g\",\"caption\":\"enam\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g\"},\"sameAs\":[\"https:\\\/\\\/code2deploy.com\\\/blog\"],\"url\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/author\\\/enam\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Setting Up a Self-Managed Kubernetes Cluster on Ubuntu 22.04 with Kubeadm and Bash Script - code2deploy.com","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.code2deploy.com\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\/","og_locale":"en_US","og_type":"article","og_title":"Setting Up a Self-Managed Kubernetes Cluster on Ubuntu 22.04 with Kubeadm and Bash Script - code2deploy.com","og_description":"Self-Managed Kubernetes Cluster Setup with bash script","og_url":"https:\/\/blog.code2deploy.com\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\/","og_site_name":"code2deploy.com","article_published_time":"2024-03-19T20:49:33+00:00","og_image":[{"width":714,"height":515,"url":"https:\/\/blog.code2deploy.com\/wp-content\/uploads\/2024\/03\/Self-Managed-Kubernetes-Cluster.png","type":"image\/png"}],"author":"enam","twitter_card":"summary_large_image","twitter_misc":{"Written by":"enam","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blog.code2deploy.com\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\/#article","isPartOf":{"@id":"https:\/\/blog.code2deploy.com\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\/"},"author":{"name":"enam","@id":"https:\/\/code2deploy.com\/blog\/#\/schema\/person\/e46930c19b999a87f12566fa8357481b"},"headline":"Setting Up a Self-Managed Kubernetes Cluster on Ubuntu 22.04 with Kubeadm and Bash Script","datePublished":"2024-03-19T20:49:33+00:00","mainEntityOfPage":{"@id":"https:\/\/blog.code2deploy.com\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\/"},"wordCount":1706,"commentCount":0,"publisher":{"@id":"https:\/\/code2deploy.com\/blog\/#\/schema\/person\/e46930c19b999a87f12566fa8357481b"},"image":{"@id":"https:\/\/blog.code2deploy.com\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\/#primaryimage"},"thumbnailUrl":"https:\/\/code2deploy.com\/blog\/wp-content\/uploads\/2024\/03\/Self-Managed-Kubernetes-Cluster.png","keywords":["Kubeadm","kubernetes","kubernetes cluster setup","kubernetes self-hosted cluster"],"articleSection":["Kubernetes","Kubernetes Basic","SHELL Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blog.code2deploy.com\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blog.code2deploy.com\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\/","url":"https:\/\/blog.code2deploy.com\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\/","name":"Setting Up a Self-Managed Kubernetes Cluster on Ubuntu 22.04 with Kubeadm and Bash Script - code2deploy.com","isPartOf":{"@id":"https:\/\/code2deploy.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blog.code2deploy.com\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\/#primaryimage"},"image":{"@id":"https:\/\/blog.code2deploy.com\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\/#primaryimage"},"thumbnailUrl":"https:\/\/code2deploy.com\/blog\/wp-content\/uploads\/2024\/03\/Self-Managed-Kubernetes-Cluster.png","datePublished":"2024-03-19T20:49:33+00:00","breadcrumb":{"@id":"https:\/\/blog.code2deploy.com\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.code2deploy.com\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.code2deploy.com\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\/#primaryimage","url":"https:\/\/code2deploy.com\/blog\/wp-content\/uploads\/2024\/03\/Self-Managed-Kubernetes-Cluster.png","contentUrl":"https:\/\/code2deploy.com\/blog\/wp-content\/uploads\/2024\/03\/Self-Managed-Kubernetes-Cluster.png","width":714,"height":515,"caption":"Self-Managed Kubernetes Cluster Setup with bash script"},{"@type":"BreadcrumbList","@id":"https:\/\/blog.code2deploy.com\/setting-up-a-self-managed-kubernetes-cluster-on-ubuntu-22-04-with-kubeadm-and-bash-script\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/code2deploy.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Setting Up a Self-Managed Kubernetes Cluster on Ubuntu 22.04 with Kubeadm and Bash Script"}]},{"@type":"WebSite","@id":"https:\/\/code2deploy.com\/blog\/#website","url":"https:\/\/code2deploy.com\/blog\/","name":"code2deploy.com\/blog","description":"TechOps","publisher":{"@id":"https:\/\/code2deploy.com\/blog\/#\/schema\/person\/e46930c19b999a87f12566fa8357481b"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/code2deploy.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/code2deploy.com\/blog\/#\/schema\/person\/e46930c19b999a87f12566fa8357481b","name":"enam","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g","caption":"enam"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g"},"sameAs":["https:\/\/code2deploy.com\/blog"],"url":"https:\/\/code2deploy.com\/blog\/author\/enam\/"}]}},"_links":{"self":[{"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/posts\/3833","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/comments?post=3833"}],"version-history":[{"count":1,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/posts\/3833\/revisions"}],"predecessor-version":[{"id":3835,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/posts\/3833\/revisions\/3835"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/media\/3834"}],"wp:attachment":[{"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/media?parent=3833"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/categories?post=3833"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/tags?post=3833"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}