Managing Kubernetes Cluster with KubeSphere

Mengelola Kubernetes Cluster dengan KubeSphere 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 KubeSphere

  • Download manifest file dan Install KubeSphere pada kubernetes cluster
VER=$( curl --silent "https://api.github.com/repos/kubesphere/ks-installer/releases/latest"| grep '"tag_name"'|sed -E 's/.*"([^"]+)".*/\1/')
wget https://github.com/kubesphere/ks-installer/releases/download/$VER/kubesphere-installer.yaml
wget https://github.com/kubesphere/ks-installer/releases/download/$VER/cluster-configuration.yaml

kubectl apply -f kubesphere-installer.yaml
kubectl apply -f cluster-configuration.yaml
  • Cek log installasi kubesphere, tunggu beberapa menit hingga proses installasi selesai dan akan muncul log informasi untuk akses ke dalam kubesphere seperti berikut
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l 'app in (ks-install, ks-installer)' -o jsonpath='{.items[0].metadata.name}') -f
---<output>---
**************************************************
Waiting for all tasks to be completed ...
task openpitrix status is successful  (1/4)
task multicluster status is successful  (2/4)
task network status is successful  (3/4)
task monitoring status is successful  (4/4)
**************************************************
Collecting installation results ...
#####################################################
###              Welcome to KubeSphere!           ###
#####################################################

Console: http://10.10.1.201:30880
Account: admin
Password: P@88w0rd
NOTES:
  1. After you log into the console, please check the
     monitoring status of service components in
     "Cluster Management". If any service is not
     ready, please wait patiently until all components 
     are up and running.
  2. Please change the default password after login.

#####################################################
https://kubesphere.io             2023-07-28 07:32:23
#####################################################
  • Verifikasi status persistent volume dan persistent volume class kubesphere
kubectl get pv
---<output>---
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                                                             STORAGECLASS   REASON   AGE
pvc-0dc3a99b-9300-42a5-b8f3-5ea0f427943e   20Gi       RWO            Delete           Bound    kubesphere-monitoring-system/prometheus-k8s-db-prometheus-k8s-0   local-path              10m
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
kubectl get pvc -A
---<output>---
NAMESPACE                      NAME                                 STATUS    VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
kubesphere-monitoring-system   prometheus-k8s-db-prometheus-k8s-0   Bound     pvc-0dc3a99b-9300-42a5-b8f3-5ea0f427943e   20Gi       RWO            local-path     10m
  • Verifikasi status service kubesphere
kubectl get service ks-console -n kubesphere-system
---<output>---
NAME         TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
ks-console   NodePort   10.103.248.5   <none>        80:30880/TCP   12m
  • Verifikasi status pod kubesphere-system, pastikan semua running
kubectl get pod --all-namespaces
---<output>---
NAMESPACE                      NAME                                               READY   STATUS    RESTARTS        AGE
default                        web-test-5fdf749d97-6ps4l                          1/1     Running   2 (7h38m ago)   20h
default                        web-test-5fdf749d97-72zqr                          1/1     Running   2 (7h38m ago)   20h
default                        web-test-5fdf749d97-b5f5g                          1/1     Running   2 (7h38m ago)   20h
default                        web-test-5fdf749d97-trcsc                          1/1     Running   2 (7h38m ago)   20h
kube-system                    calico-kube-controllers-85578c44bf-nhtts           1/1     Running   2 (7h38m ago)   21h
kube-system                    calico-node-fm4tq                                  1/1     Running   2 (7h38m ago)   21h
kube-system                    calico-node-nwsql                                  1/1     Running   2 (7h38m ago)   21h
kube-system                    coredns-5d78c9869d-dzcvz                           1/1     Running   2 (7h38m ago)   21h
kube-system                    coredns-5d78c9869d-wb95n                           1/1     Running   2 (7h38m ago)   21h
kube-system                    etcd-alma1.sys-ops.id                              1/1     Running   2 (7h38m ago)   21h
kube-system                    kube-apiserver-alma1.sys-ops.id                    1/1     Running   2 (7h38m ago)   21h
kube-system                    kube-controller-manager-alma1.sys-ops.id           1/1     Running   2 (7h38m ago)   21h
kube-system                    kube-proxy-ht5sw                                   1/1     Running   2 (7h38m ago)   21h
kube-system                    kube-proxy-v64hr                                   1/1     Running   2 (7h38m ago)   21h
kube-system                    kube-scheduler-alma1.sys-ops.id                    1/1     Running   2 (7h38m ago)   21h
kube-system                    snapshot-controller-0                              1/1     Running   0               6h11m
kubesphere-controls-system     default-http-backend-bb44579cb-sgdjb               1/1     Running   0               6h10m
kubesphere-controls-system     kubectl-admin-685dbc7f7b-2ckw9                     1/1     Running   0               6h3m
kubesphere-monitoring-system   alertmanager-main-0                                2/2     Running   0               6h7m
kubesphere-monitoring-system   kube-state-metrics-7db6ccf9d6-qpmk9                3/3     Running   0               6h7m
kubesphere-monitoring-system   node-exporter-hfsdn                                2/2     Running   0               6h7m
kubesphere-monitoring-system   node-exporter-q2s5h                                2/2     Running   0               6h7m
kubesphere-monitoring-system   notification-manager-deployment-56dbc56444-x25l6   2/2     Running   0               6h4m
kubesphere-monitoring-system   notification-manager-operator-dbb677dd9-hd9sr      2/2     Running   0               6h6m
kubesphere-monitoring-system   prometheus-k8s-0                                   2/2     Running   0               6h7m
kubesphere-monitoring-system   prometheus-operator-56f97cc849-nfdv5               2/2     Running   0               6h7m
kubesphere-system              ks-apiserver-7dfc5946c4-4vwdj                      1/1     Running   0               6h10m
kubesphere-system              ks-console-66bbdfcb5-2svnr                         1/1     Running   0               6h10m
kubesphere-system              ks-controller-manager-68c59b9dd6-4pfvq             1/1     Running   0               6h10m
kubesphere-system              ks-installer-6f55f97995-z2d86                      1/1     Running   0               6h11m
local-path-storage             local-path-provisioner-bf548cc96-p2576             1/1     Running   0               6h57m
metallb-system                 controller-595f88d88f-ntx49                        1/1     Running   2 (7h38m ago)   20h
metallb-system                 speaker-8hzl2                                      1/1     Running   4 (7h37m ago)   20h
metallb-system                 speaker-k4h5z                                      1/1     Running   4 (7h37m ago)   20h
web                            web-test-metallb-f655f9985-hthtj                   1/1     Running   0               5h21m

  • Akses KubeSphere kubernetes dashboard dengan url: http://ip_address:30880 dengan default user: admin dan password: P@88w0rd. Ganti default password dengan password baru yang lebih kuat.
  • Tampilan dashboard KubeSphere
  • Tampilan dashboard status node kubernetes
  • Tampilan dashboard project, deployment, pod, dan service
  • Tampilan dashboard storage
  • Tampilan dashboard monitoring node

  • Delete kubesphere
kubectl delete -f cluster-configuration.yaml
kubectl delete -f kubesphere-installer.yaml

herdiana3389

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