Managing Kubernetes Cluster with Portainer

Mengelola Kubernetes Cluster dengan Portainer Dashboard

kubectl get nodes -o wide
---<output>---
NAME               STATUS   ROLES           AGE   VERSION   INTERNAL-IP   EXTERNAL-IP   OS-IMAGE                           KERNEL-VERSION                 CONTAINER-RUNTIME
alma1.sys-ops.id   Ready    control-plane   29h   v1.27.4   10.10.1.201   <none>        AlmaLinux 8.8 (Sapphire Caracal)   4.18.0-477.15.1.el8_8.x86_64   containerd://1.6.21
alma2.sys-ops.id   Ready    <none>          29h   v1.27.4   10.10.1.202   <none>        AlmaLinux 8.8 (Sapphire Caracal)   4.18.0-477.15.1.el8_8.x86_64   containerd://1.6.21

Deploy Local Storage Provisioner

  • Download manifest file dan Install local path storage provisioner untuk menyimpan data kubesphere
  • Default lokasi storage: /opt/local-path-provisioner
wget https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml

kubectl apply -f local-path-storage.yaml
  • Cek status local path storage
kubectl -n local-path-storage get pod
---<output>---
NAME                                     READY   STATUS    RESTARTS   AGE
local-path-provisioner-bf548cc96-p2576   1/1     Running   0          3m
  • Cek status storage class
kubectl get sc
---<output>---
NAME                   PROVISIONER             RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
local-path             rancher.io/local-path   Delete          WaitForFirstConsumer   false                  3m
  • Jadikan local path menjadi default storage
kubectl patch storageclass local-path -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
  • Cek kembali status storage class
kubectl get sc
---<output>---
NAME                   PROVISIONER             RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
local-path (default)   rancher.io/local-path   Delete          WaitForFirstConsumer   false                  4m

Deploy Portainer

  • Download manifest file dan Install Portainer pada kubernetes cluster
  • File deployment berikut khusus untuk menggunakan type service Node Port.
  • Jika ingin meggunakan type service Load Balancer, cek pada bagian bawah artikel
wget https://raw.githubusercontent.com/portainer/k8s/master/deploy/manifests/portainer/portainer.yaml

kubectl apply -f portainer.yaml
  • Verifikasi status pod dan service portainer
kubectl get pods -n portainer
---<output>---
NAME                        READY   STATUS    RESTARTS   AGE
portainer-696988fd4-2fx6k   1/1     Running   0          30s
--------------------------------------------------------------------------------------------------------
kubectl get services -n portainer
---<output>---
NAME        TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)                                         AGE
portainer   NodePort   10.103.80.250   <none>        9000:30777/TCP,9443:30779/TCP,30776:30776/TCP   48s

  • Akses Portainer kubernetes dashboard dengan url: http://ip_address:30777
  • Buat user baru untuk akses ke dalam dashboard portainer
  • Tampilan Portainer kubernetes dashboard

  • Delete portainer
kubectl delete -f portainer.yaml

  • File deployment berikut khusus untuk menggunakan type service Load Balancer.
  • Pastikan sudah men-deploy metallb load balancer pada kubernetes cluster
wget https://raw.githubusercontent.com/portainer/k8s/master/deploy/manifests/portainer/portainer-lb.yaml

kubectl apply -f portainer-lb.yaml
  • Verifikasi status pod dan service portainer
kubectl get pods -n portainer
---<output>---
NAME                         READY   STATUS    RESTARTS   AGE
portainer-7c9d58dd95-4c5wk   1/1     Running   0          47s
---------------------------------------------------------------------------------------------------------
kubectl get services -n portainer
---<output>---
NAME        TYPE           CLUSTER-IP    EXTERNAL-IP   PORT(S)                                        AGE
portainer   LoadBalancer   10.105.80.8   10.10.1.201   9000:32493/TCP,9443:31049/TCP,8000:32063/TCP   82s
  • Akses dashboard portainer dengan url: http://ip_address:9000
  • Delete portainer
kubectl delete -f portainer-lb.yaml

herdiana3389

A system administrator with skills in system administration, virtualization, linux, windows, networking, cloud computing, container, etc.