0% found this document useful (0 votes)
30 views

Kubernetest Installation Steps 1 29 Ubuntu 22 04

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)
30 views

Kubernetest Installation Steps 1 29 Ubuntu 22 04

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.29

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

swapoff -a

vi /etc/hosts
10.0.0.10 infra-server.example.com infra-server
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

vi /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

sysctl -p

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

curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.29/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.29/deb/ /' | sudo tee
/etc/apt/sources.list.d/kubernetes.list
apt-get update
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

sudo kubeadm config images pull --cri-socket /var/run/crio/crio.sock --kubernetes-


version v1.29.0
sudo kubeadm init --pod-network-cidr=10.244.0.0/16 --upload-certs --kubernetes-
version=v1.29.0 --cri-socket /var/run/crio/crio.sock

--------------------------------------------------------------------------------
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:

kubeadm join 10.0.0.11:6443 --token jb8bbg.dsfzpwyl8c0jnatm --discovery-token-ca-


cert-hash sha256:c01f306037d523cee08cfe42cca049a75985d7ed219261381c178e64ff96ffc1

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

kubectl create -f
https://raw.githubusercontent.com/projectcalico/calico/v3.27.2/manifests/tigera-
operator.yaml
wget https://raw.githubusercontent.com/projectcalico/calico/v3.27.2/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.150-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
###################################################################################
################################################################
dnf -y install net-tools telnet curl wget traceroute nmap-ncat git httpd-tools jq
nfs-utils
systemctl stop firewalld && systemctl disable firewalld
sed -i s/^SELINUX=.*$/SELINUX=disabled/ /etc/selinux/config && setenforce 0

[root@infra-server ~]# cat /etc/sysctl.d/70-ipv6.conf


net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
[root@infra-server ~]#

You might also like