Run openSUSE Kubic – Like (K8s, Podman and CRI-O) on Alibaba Cloud

openSUSE Kubic is Certified Kubernetes distribution & container-related technologies built by the openSUSE community. There is specific iso for openSUSE Kubic.

But sadly. As I am a cloud provider user. There are not many cloud provider who have feature upload ISO Image if I want to upload openSUSE Kubic ISO. And next problem, there is very limited kind cloud provider who have openSUSE distribution for image flavor when launch Virtual Machine. Cloud like AWS and GCP only provide SLES version.

Fortunately, Alibaba Cloud have openSUSE Leap distribution. Alibaba Cloud have openSUSE Leap 42.3, 15.1 and 15.2 beside SLES version. It is help me lot of.

Prepare Virtual Machine for Master and Node

I created two virtual machine with spec:

  • 2 VM openSUSE Leap 15.2 (hostname: master-01,node-01)
  • 2 Core, 2 GB RAM | ecs.t5-c1m1.large
  • Security Group (open port TCP: 22,80,443,6443,30000)

Upgrade to openSUSE Tumbleweed

After created vm, ssh to each server, run upgrade to tumbleweed:

ssh root@ip-server
mkdir /etc/zypp/repos.d/old
mv /etc/zypp/repos.d/*.repo /etc/zypp/repos.d/old
zypper ar -f -c http://download.opensuse.org/tumbleweed/repo/oss repo-oss
zypper ar -f -c http://download.opensuse.org/tumbleweed/repo/non-oss repo-non-oss
zypper ar -f -c http://download.opensuse.org/tumbleweed/repo/debug repo-debug
zypper ar -f -c http://download.opensuse.org/update/tumbleweed/ repo-update
zypper dup

Install Kubernetes Stuff

This step will be doing and each virtual machine.
After upgrade, do power off and power on. Then lets start install Kubernetes stuff:

  1. Config network option
  2. Add config to /etc/sysctl.conf and reload
  3. Install kubeadm, cri-o and podman
modprobe overlay
modprobe br_netfilter
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf 
echo "net.ipv4.conf.all.forwarding = 1" >> /etc/sysctl.conf
echo "net.bridge.bridge-nf-call-iptables = 1" >> /etc/sysctl.conf
sysctl -p
zypper in cri-o cri-tools kubernetes-kubeadm kubernetes-client podman
systemctl enable kubelet
systemctl start kubelet

Initialize Kubernetes Cluster on master-01

After done install Kubernetes stuff, lets start initialize Kubernetes cluster:

kubeadm config images pull
kubeadm init

This process will create cluster. Save output command for join cluster. We need this token for next step. And copy kubeconfig for Kubernetes Client.

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

Setup Network Plugins on master-01

I using project calico for network plugins. It is more better then weave for me.

curl https://docs.projectcalico.org/manifests/calico.yaml -O
kubectl apply -f calico.yaml

Join Cluster on node-01

After created cluster, now we configure node-01 to join cluster. We use command from output kubeadm init at previous command.

kubeadm join 172.31.167.254:6443 --token jqeu4g.34rglub8wkgb9i5x \
    --discovery-token-ca-cert-hash sha256:5d2cbc7a79287228b90b188b4c99626f461a57d13b7a006dfe2265da0d0a9356

Verify Kubernetes Cluster

Do this command on master-01 after node-01 joined cluster.

kubectl get nodes
kubectl get pods --all-namespaces

Create Simple Deployment

I testing cluster using simple app nginx, and service using node port. Here the snippet for nginx-dpy.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-deployment
spec:
  selector:
    matchLabels:
      app: hello
  replicas: 2
  template:
    metadata:
      labels:
        app: hello
        env: staging
    spec:
      containers:
        - name: hello
          image: tuanpembual/hello
          imagePullPolicy: Always
          ports:
            - name: http
              containerPort: 80
              protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
  name: hello-service
  labels:
    app: hello
spec:
  type: NodePort
  selector:
    app: hello
  ports:
    - name: http
      nodePort: 30000
      port: 80
      targetPort: 80
---

Then deploy this yaml:

kubectl apply -f nginx-dpy.yaml
curl localhost:30000

The apps can be access to using master_01_ip_public:30000/. That all from me.

References

I hope it will give you more idea. Thank you
Estu~

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google

You are commenting using your Google account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.