Setup Kubernetes 1.20.13 on openSUSE Leap 15.4

Nothing to do in the holiday, and want to try the Kubernetes in SUSE. The most important reason is I buy a new Parallels Desktop and have a powerful computer:)


environment

OS: openSUSE Leap 15.4

kubernetes: 1.20.13

virtualization: Parallels Desktop 18 for Mac Pro Edition


setup the virtual machines

create 2 virtual machines of (aarch64) openSUSE Leap 15.4, one is for the master node, the other is for the worker node. the 2 virtual machines are connected under the 'Shared' model in Parallels Desktop.

10.211.55.7    LZY-SUSE154-001
10.211.55.8    LZY-SUSE154-002

during the setup of the virtual machines, ensure swap partition is not created.

add IP, full-hostname and short-hostname into etc\hosts, ==not understand why need do this actually==.

10.211.55.7    LZY-SUSE154-001    master
10.211.55.8    LZY-SUSE154-002    node1

preflight in both virtual machines

sudo zypper update
sudo zypper refresh

#ensure the swap is disable
sudo swapon --show 

install docker, kubelet, kubeadm and kubectl in both virtual machines

sudo zypper install docker

#enable the docker service started on boot
sudo systemctl enable docker
sudo systemctl start docker

sudo docker ps
sudo zypper install kubernetes1.20-kubelet
sudo zypper install kubernetes1.20-kubeadm
sudo zypper install kubernetes1.20-client

#enable the kubelet service started on boot
sudo systemctl enable kubelet

setup the firewall rules in both virtual machines

sudo firewall-cmd --query-port=6443/tcp

#add port in the firewall rules
sudo firewall-cmd --permanent --zone=public --add-port=6443/tcp

sudo systemctl reload firewalld

do in master node, initialize the cluster with kubeadm

initialize the cluster

sudo kubeadm init --kubernetes-version=1.20.13 \
    --apiserver-advertise-address=10.211.55.7 \
    --image-repository registry.aliyuncs.com/google_containers \
    --service-cidr=172.17.0.0/16 \
    --pod-network-cidr=172.18.0.0/16

make kubectl work for the non-root user

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

install a Pod network add-on

sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

if https://raw.githubusercontent.com is blocked, just get the yaml file and copy/pates into vi

sudo vi kube-flannel.yml
sudo kubectl apply -f  kube-flannel.yml

change the IP range of service-cidr

net-conf.json: |
{
    "Network": "172.17.0.0/16",
    "Backend": {
        "Type": "vxlan"
    }
}

check the status, all pods should be in running status

sudo kubectl get pods --all-namespaces

do in worker node, add the worker node into the cluster with kubeadm

specify the container runtime in --cri-socket, Kubernetes uses the Container Runtime Interface (CRI) to interface with your chosen container runtime, if it's using Docker Engine, then set --cri-socket=/var/run/dockershim.sock

sudo kubeadm join 10.211.55.7:6443 --cri-socket=/var/run/dockershim.sock \
    --token <your token> \
    --discovery-token-ca-cert-hash sha256:<your hash>

check status in master node

sudo kubectl get nodes


NAMESTATUSROLESAGEVERSION
lzy-suse154-001Readycontrol-plane,master18hv1.20.13
lzy-suse154-002Readyworker15hv1.20.13

references

https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm
https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm
https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/troubleshooting-kubeadm
https://www.cnblogs.com/yg0070/articles/13848084.html
https://nugi.abdiansyah.com/how-to-kubernetes-in-opensuse-leap-15-1-hardest-way


标签: Kubernetes, openSUSE

评论已关闭