Deploy K3s and KubeSphere
K3s is a lightweight Kubernetes distribution built for IoT and edge computing with external dependencies minimized. It is packaged as a single binary that reduces the dependencies and steps that are required to set up a Kubernetes cluster.
You can use KubeKey to install both K3s and KubeSphere while KubeSphere can also be deployed on an existing K3s cluster.
Note
Prerequisites
- For information about the prerequisites for K3s installation, see the K3s documentation.
- You may need to create necessary firewall rules or port forwarding rules depending on your environment. For more information, see Port Requirements.
Step 1: Download KubeKey
Follow the step below to download KubeKey.
Download KubeKey from its GitHub Release Page or use the following command directly.
curl -sfL https://get-kk.kubesphere.io | VERSION=v1.1.1 sh -
Run the following command first to make sure you download KubeKey from the correct zone.
export KKZONE=cn
Run the following command to download KubeKey:
curl -sfL https://get-kk.kubesphere.io | VERSION=v1.1.1 sh -
Note
export KKZONE=cn
again before you proceed with the steps below.Note
Make kk
executable:
chmod +x kk
Step 2: Create a Cluster
-
Create a configuration file of your cluster by running the following command:
./kk create config --with-kubernetes v1.20.4-k3s --with-kubesphere v3.1.1
Note
KubeKey v1.1.1 only supports the installation of K3s v1.20.4. -
A default file
config-sample.yaml
will be created if you do not customize the name. Edit the file.vi config-sample.yaml
... metadata: name: sample spec: hosts: - {name: master, address: 192.168.0.2, internalAddress: 192.168.0.2, user: ubuntu, password: Testing123} - {name: node1, address: 192.168.0.3, internalAddress: 192.168.0.3, user: ubuntu, password: Testing123} - {name: node2, address: 192.168.0.4, internalAddress: 192.168.0.4, user: ubuntu, password: Testing123} roleGroups: etcd: - master master: - master worker: - node1 - node2 controlPlaneEndpoint: domain: lb.kubesphere.local address: "" port: 6443 kubernetes: version: v1.20.4-k3s imageRepo: kubesphere clusterName: cluster.local network: plugin: calico kubePodsCIDR: 10.233.64.0/18 kubeServiceCIDR: 10.233.0.0/18 registry: registryMirrors: [] insecureRegistries: [] addons: [] ...
Note
For more information about each field in the configuration file, see an example file. -
Save the file and execute the following command to install K3s and KubeSphere:
./kk create cluster -f config-sample.yaml
-
When the installation finishes, you can inspect installation logs with the following command:
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f
Expected output:
##################################################### ### Welcome to KubeSphere! ### ##################################################### Console: http://192.168.0.2: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 20xx-xx-xx xx:xx:xx #####################################################
-
Access the KubeSphere console at
<NodeIP>:30880
with the default account and password (admin/P@88W0rd
).
Note
Feedback
Was this page Helpful?
Thanks for the feedback. If you have a specific question about how to use KubeSphere, ask it on Slack. Open an issue in the GitHub repo if you want to report a problem or suggest an improvement.