0% found this document useful (0 votes)
34 views4 pages

Kubernetest Installation Steps 1 29 Ubuntu 22 04

The document provides instructions for installing Kubernetes on Ubuntu 22.04 using kubeadm. It covers prerequisites like disabling swap and configuring hosts file. It then walks through installing kubeadm, kubelet and kubectl and configuring the cluster. The document also covers deploying Calico and Metallb networking and testing with a sample nginx deployment.

Uploaded by

Thomas Mathias
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views4 pages

Kubernetest Installation Steps 1 29 Ubuntu 22 04

The document provides instructions for installing Kubernetes on Ubuntu 22.04 using kubeadm. It covers prerequisites like disabling swap and configuring hosts file. It then walks through installing kubeadm, kubelet and kubectl and configuring the cluster. The document also covers deploying Calico and Metallb networking and testing with a sample nginx deployment.

Uploaded by

Thomas Mathias
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

https://kubernetes.

io/docs/setup/production-environment/tools/kubeadm/install-
kubeadm/

Create .vimrc file in homedirectory


Create a file in your home directory called .vimrc, and put your commands in there:

vi .vimrc
set tabstop=4
set shiftwidth=4
set expandtab

Ubuntu - 22.04
Kubernetes - 1.30

sed -i '/swap/ s/^\(.*\)$/#\1/g' /etc/fstab


swapoff -a

vi /etc/hosts
10.0.0.5 infra-server.example.com infra-server
10.0.0.10 workstation.example.com workstation
10.0.0.11 k8s-master.example.com k8s-master
10.0.0.12 k8s-worker1.example.com k8s-worker1
10.0.0.13 k8s-worker2.example.com k8s-worker2
10.0.0.14 k8s-worker3.example.com k8s-worker3

apt-get update -y && apt-get install -y apt-transport-https ca-certificates curl


gpg

apt install nfs-common -y && apt update -y

curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | sudo gpg --


dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg]
https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /' | sudo tee
/etc/apt/sources.list.d/kubernetes.list
apt-get update -y && apt-get install -y kubelet kubeadm kubectl
apt-mark hold kubelet kubeadm kubectl

modprobe overlay
modprobe br_netfilter

tee /etc/sysctl.d/kubernetes.conf<<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF

sysctl --system

export OS=xUbuntu_22.04
export CRIO_VERSION=1.28

echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/


stable/$OS/ /"|sudo tee
/etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
echo "deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/
stable:/cri-o:/$CRIO_VERSION/$OS/ /"|sudo tee
/etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:$CRIO_VERSION.list

curl -L
https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable:cri-o:
$CRIO_VERSION/$OS/Release.key | sudo apt-key add -

curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/
stable/$OS/Release.key | sudo apt-key add -

apt update -y && apt install cri-o cri-o-runc -y


systemctl enable crio.service && systemctl start crio.service && apt install cri-
tools -y

kubeadm config images pull


kubeadm init --pod-network-cidr=10.244.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
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
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:

kubeadm join 10.0.0.11:6443 --token yuxkgx.q708321raj70t62u --discovery-token-ca-


cert-hash sha256:7284551695524fa91c6e0cac457b0d59cccd4b789f835e3cabf8c99a1cd956af

root@k8s-master:~#
--------------------------------------------------------------------------------

kubectl create -f
https://raw.githubusercontent.com/projectcalico/calico/v3.27.3/manifests/tigera-
operator.yaml

wget https://raw.githubusercontent.com/projectcalico/calico/v3.27.3/manifests/
custom-resources.yaml
cp -p custom-resources.yaml custom-resources.yaml_bkp
sed -i 's/cidr: 192\.168\.0\.0\/16/cidr: 10.244.0.0\/16/g' custom-resources.yaml
diff custom-resources.yaml custom-resources.yaml_bkp
kubectl create -f custom-resources.yaml

###################################################################################
##############################################
kubectl label node k8s-worker1 node-role.kubernetes.io/worker=worker
kubectl label node k8s-worker2 node-role.kubernetes.io/worker=worker
kubectl label node k8s-worker3 node-role.kubernetes.io/worker=worker
############################################ METALLB
###################################################################################
##
# see what changes would be made, returns nonzero returncode if different
kubectl get configmap kube-proxy -n kube-system -o yaml | sed -e "s/strictARP:
false/strictARP: true/" | kubectl diff -f - -n kube-system

# actually apply the changes, returns nonzero returncode on errors only


kubectl get configmap kube-proxy -n kube-system -o yaml | sed -e "s/strictARP:
false/strictARP: true/" | kubectl apply -f - -n kube-system

kubectl apply -f
https://raw.githubusercontent.com/metallb/metallb/v0.14.3/config/manifests/metallb-
native.yaml

kubectl get pods -A -o wide


-----------------------------------------------------
vi first-pool.yaml
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: first-pool
namespace: metallb-system
spec:
addresses:
- 10.0.0.100-10.0.0.250
-----------------------------------------------------
kubectl apply -f first-pool.yaml
-----------------------------------------------------
vi firstL2advertisement.yaml
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: example
namespace: metallb-system
spec:
ipAddressPools:
- first-pool
------------------------------------------------
kubectl apply -f firstL2advertisement.yaml
###################################################################################
################################################################
Testing:
###################################################################################
################################################################
kubectl create deploy nginx --image nginx
watch kubectl get pod
kubectl expose deploy nginx --port 80 --type LoadBalancer
kubectl get svc
###################################################################################
################################################################
apt install nfs-common -y && apt update -y

curl -fsSL -o get_helm.sh


https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
helm repo add nfs-subdir-external-provisioner
https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner/
helm install nfs-subdir-external-provisioner nfs-subdir-external-provisioner/nfs-
subdir-external-provisioner --set nfs.server=10.0.0.5 --set nfs.path=/nfsshare

kubectl patch storageclass nfs-client -p '{"metadata": {"annotations":


{"storageclass.kubernetes.io/is-default-class":"true"}}}'
###################################################################################
#################################################################

You might also like