We can all agree that containerization technology has been highly adopted in the past decade. This is due to the fact that almost all organizations around the world have decided to modernize their existing applications for cloud use. Containerization is the packaging software code with all the required dependencies in a lightweight executable. Containers can be run using tools like docker, Podman, Kubernetes e.t.c

Kubernetes(k8s) is a free and open-source container orchestration tool that works by distributing the workload across a cluster of hosts. It also automates the container networking needs, storage, and persistent volumes while maintaining the desired container state.

When a Kubernetes environment grows, it can be hard to manage. This creates a high need for Kubernetes management tools. The available tools in the market include K9s, Weave scope, Dashboard + Kubectl + Kubeadm, KubeSpray, Kontena Lens, WKSctl, Rancher, Portainer, Headlamp, Konstellate e.t.c

KubeSphere is a distributed operating system that has a commitment to providing a plug-and-play architecture for cloud-native application management with Kubernetes as its kernel. This multi-tenant enterprise-grade platform has full-stack automated IT operations and streamlined DevOps workflows. It has a user-friendly web UI to help users build robust and feature-rich platforms. It also makes common functions such as resource management, DevOps (CI/CD), monitoring, logging, service mesh, multi-tenancy, auditing, alerting and notification, application lifecycle management, multi-cluster deployment, access control, storage and networking, autoscaling, registry management, and security management more effortless.

One of the fantastic features is that it allows third-party applications to integrate seamlessly into its ecosystem. Other features include:

  • Open Source: with its open-source model, developments can be easily enhanced. Its source code is available on GitHub 
  • O&M Friendly: It hides the details of underlying infrastructure and helps modernize migrate, deploy and manage existing deployments
  • Run KubeSphere Everywhere: this lightweight platform is more friendly to different cloud ecosystems. It can be installed on cloud platforms such as Alibaba Cloud, QingCloud, Tencent Cloud, AWS, Huawei Cloud e.t.c
  • Landscape: KubeSphere is a member of the Kubernetes Conformance Certified platform and enriches the CNCF CLOUD NATIVE Landscape.

Today, we will learn how to install and use KubeSphere on an existing Kubernetes cluster.

Prerequisites

For this guide to work best, you need to have the following:

Also, ensure that kubectl is installed.

curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin

To be able to use the tool, export the admin config:

##For RKE2
export PATH=$PATH:/var/lib/rancher/rke2/bin export KUBECONFIG=/etc/rancher/rke2/rke2.yaml

##For K0s
export KUBECONFIG=/var/lib/k0s/pki/admin.conf

Check the available nodes in the cluster

$ kubectl get nodes
NAME      STATUS   ROLES           AGE     VERSION
master    Ready    control-plane   3m38s   v1.25.2+k0s
worker1   Ready    <none>          100s    v1.25.2+k0s
worker2   Ready    <none>          92s     v1.25.2+k0s

Step 1 – Create Persistent Volumes For KubeSphere

One of the requirements of KubeSphere is to have a persistent volume set-up. We need to create a storage class in the cluster and set it as the default storage class.

Refer to our articles below on how to configure persistent storage for your Kubernetes cluster:

Check if you have storage class configured and working.

$ kubectl get sc
NAME                   PROVISIONER             RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
local-path (default)   rancher.io/local-path   Delete          WaitForFirstConsumer   false                  13m

$ kubectl get sc
NAME                      PROVISIONER                    RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
kubesphere-sc (default)   kubernetes.io/no-provisioner   Delete          WaitForFirstConsumer   false                  2m31s

Once the configurations have been made accordingly, apply the manifest.

kubectl create -f Kubevious-pv.yml

Step 2 – Deploy KubeSphere on Kubernetes

Once the cluster meets all the requirements, you can install KubeSphere. In this guide, we will use kubectl to install KubeSphere with the default minimal package.

Download installation manifest files.

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

Apply to create kubernetes objects:

$ kubectl apply -f kubesphere-installer.yaml
customresourcedefinition.apiextensions.k8s.io/clusterconfigurations.installer.kubesphere.io created
namespace/kubesphere-system created
serviceaccount/ks-installer created
clusterrole.rbac.authorization.k8s.io/ks-installer created
clusterrolebinding.rbac.authorization.k8s.io/ks-installer created
deployment.apps/ks-installer created

$ kubectl apply -f cluster-configuration.yaml
clusterconfiguration.installer.kubesphere.io/ks-installer created

After running the two commands, you will have a namespace kubesphere-system created and several other resources started. You can follow through the deployment with the command:

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

Sample Output:

....
TASK [ks-core/prepare : KubeSphere | Getting installation init files] **********
changed: [localhost] => (item=ks-init)

TASK [ks-core/prepare : KubeSphere | Initing KubeSphere] ***********************
changed: [localhost] => (item=role-templates.yaml)

TASK [ks-core/prepare : KubeSphere | Generating kubeconfig-admin] **************
skipping: [localhost]

PLAY RECAP *********************************************************************
localhost                  : ok=29   changed=21   unreachable=0    failed=0    skipped=16   rescued=0    ignored=0   
Start installing monitoring
Start installing multicluster
Start installing openpitrix
Start installing network
**************************************************
Waiting for all tasks to be completed ...
task network status is successful  (1/4)
task openpitrix status is successful  (2/4)
task multicluster status is successful  (3/4)
....

Check if all pods are running:

kubectl get pod --all-namespaces

Sample Output:

Install and Use KubeSphere

You can verify the status of the created PVs:

$ kubectl get pv
NAME             CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                                                             STORAGECLASS    REASON   AGE
kubesphere-pv    20Gi       RWO            Retain           Bound    kubesphere-monitoring-system/prometheus-k8s-db-prometheus-k8s-0   kubesphere-sc            27m
kubesphere-pv2   20Gi       RWO            Retain           Bound    kubesphere-monitoring-system/prometheus-k8s-db-prometheus-k8s-1   kubesphere-sc            15m

From the output, the two PVs have been bound. This means that they are under use. You can also view PVCs created:

$ kubectl get pvc -A
NAMESPACE                      NAME                                 STATUS   VOLUME           CAPACITY   ACCESS MODES   STORAGECLASS    AGE
kubesphere-monitoring-system   prometheus-k8s-db-prometheus-k8s-0   Bound    kubesphere-pv    20Gi       RWO            kubesphere-sc   26m
kubesphere-monitoring-system   prometheus-k8s-db-prometheus-k8s-1   Bound    kubesphere-pv2   20Gi       RWO            kubesphere-sc   25m

Now we can proceed and get the port for the ks-console. The default port is 30880

$ kubectl get svc/ks-console -n kubesphere-system
NAME         TYPE       CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
ks-console   NodePort   10.110.224.204   <none>        80:30880/TCP   30m

We have confirmed that we have a NodePort service running on port 30880. You might need to allow this port through the firewall.

Step 3 – Access KubeSphere Web UI

Using the port, you can then access the KubeSphere Web UI using the URL http://node_IP:30880

Install and Use KubeSphere 1

Login using the default account and password (admin/P@88w0rd). You will be required to set a preferred password. Thereafter, you will be authenticated to the below dashboard.

Install and Use KubeSphere 2