Deploy KubeSphere and Kubernetes on Amazon EC2 in All in One Mode
DEV Community

Deploy KubeSphere and Kubernetes on Amazon EC2 in All in One Mode

1 Cloud Instance Configuration An All in One installation requires only one cloud host that meets the stated requirements. Note: If the system has at least 8 CPU cores and 16 GB of memory, enabling all components is recommended. See the KubeSphere documentation on enabling pluggable components for details. Operating system Configuration Security group Connection CentOS Linux 7.9.2009 Core 8 CPU cores, 16 GB RAM, 100 GB disk Allow all traffic Remote SSH Cloud instance requirements - The instance must be reachable through SSH. - The node must provide commands such as sudo, curl, openssl, and tar. 2 Connect to the Cloud Instance by SSH BASH C:\Users\xyb>ssh -i xybaws-ningxia-key.pem centos@ 3 Check the Operating System Version BASH [root@ip-172-31-6-245 ~]# cat /etc/redhat-release CentOS Linux release 7.9.2009 (Core) [root@ip-172-31-6-245 ~]# cat /etc/os-release NAME="CentOS Linux" VERSION="7 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="7" PRETTY_NAME="CentOS Linux 7 (Core)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:7" HOME_URL="https://www.centos.org/" BUG_REPORT_URL="https://bugs.centos.org/" CENTOS_MANTISBT_PROJECT="CentOS-7" CENTOS_MANTISBT_PROJECT_VERSION="7" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="7" 4 Change the Hostname BASH $ sudo hostnamectl set-hostname kubesphere-master $ sudo bash $ sudo hostname kubesphere-master 5 Install Dependencies BASH $ sudo yum install -y socat conntrack ebtables ebtables ipset ipvsadm 6 Configure the Security Group and DNS - Configure the cloud instance security group to allow all traffic and ports. This is suitable only for a test environment; in production, expose only the minimum required ports. If the network uses firewall rules or security groups, ensure that infrastructure components can communicate through the required ports. The original article recommends disabling the firewall for this test setup. - Ensure the DNS servers in /etc/resolv.conf are reachable; otherwise, cluster DNS may fail. BASH $ sudo vim /etc/resolv.conf $ sudo cat /etc/resolv.conf ; generated by /usr/sbin/dhclient-script search cn-northwest-1.compute.internal nameserver 8.8.8.8 7 Download KubeKey The cluster must have an available container runtime. When KubeKey builds the cluster, it installs the latest Docker version by default. You can instead install Docker or another container runtime before creating the cluster. KubeKey is a Go based installation tool that replaces the earlier Ansible based installer. It can install KubeSphere, Kubernetes, or both, providing a flexible and efficient setup path. BASH # If access to GitHub or Google APIs is restricted, set the correct download region first. export KKZONE=cn # Then run the following command to download KubeKey. curl -sfL https://get-kk.kubesphere.io | VERSION=v3.0.13 sh - # Finally, make the downloaded kk binary executable. chmod +x kk # Verify the download # ll total 112100 -rwxr-xr-x 1 root root 78973328 Nov 7 08:43 kk drwxr-xr-x 3 root root 18 Nov 19 05:21 kubekey -rw-r--r-- 1 root root 35796470 Nov 19 05:17 kubekey-v3.0.13-linux-amd64.tar.gz 8 Install KubeSphere and Kubernetes Together Installation requires only one command. The command template is: BASH ./kk create cluster [--with-kubernetes version] [--with-kubesphere version] To install Kubernetes and KubeSphere together, use commands such as the following: BASH ./kk create cluster --with-kubernetes v1.26.12 --with-kubesphere v3.4.0 ./kk create cluster --with-kubernetes v1.26.12 --with-kubesphere v3.4.0 --container-manager containerd -y After the command runs, KubeKey checks the installation environment and displays the results in a table. Enter yes to continue. BASH [root@kubesphere-master ~]# ./kk create cluster --with-kubernetes v1.22.12 --with-kubesphere v3.4.0 _ __ _ _ __ | | / / | | | | / / | |/ / _ | |_ | |/ / ___ _ _ | | | | | ' \ / _ \ \ / _ \ | | | | |\ \ || | |) | / |\ \ / || | _| _/_,|./ __| _/_|_, | / | |/ 05:28:23 UTC [GreetingsModule] Greetings 05:28:27 UTC message: [kubesphere-master] Greetings, KubeKey! 05:28:27 UTC success: [kubesphere-master] 05:28:27 UTC [NodePreCheckModule] A pre-check on nodes 05:28:43 UTC success: [kubesphere-master] 05:28:43 UTC [ConfirmModule] Display confirmation form +-------------------+------+------+---------+----------+-------+-------+---------+-----------+--------+--------+------------+------------+-------------+------------------+--------------+ | name | sudo | curl | openssl | ebtables | socat | ipset | ipvsadm | conntrack | chrony | docker | containerd | nfs client | ceph client | glusterfs client | time | +-------------------+------+------+---------+----------+-------+-------+---------+-----------+--------+--------+------------+------------+-------------+------------------+--------------+ | kubesphere-master | y | y | y | y | y | y | y | y | y | | | y | | | UTC 05:28:43 | +-------------------+------+------+---------+----------+-------+-------+---------+-----------+--------+--------+------------+------------+-------------+------------------+--------------+ This is a simple check of your environment. Before installation, ensure that your machines meet all requirements specified at https://github.com/kubesphere/kubekey#requirements-and-recommendations Continue this installation? [yes/no]: yes During installation, the following output indicates that the Kubernetes cluster has been installed successfully. BASH Your Kubernetes control-plane has initialized successfully! To start using your cluster, you need to run the following as a regular user: mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config Alternatively, if you are the root user, you can run: export KUBECONFIG=/etc/kubernetes/admin.conf You should now deploy a pod network to the cluster. Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at: https://kubernetes.io/docs/concepts/cluster-administration/addons/ You can now join any number of control-plane nodes by copying certificate authorities and service account keys on each node and then running the following as root: kubeadm join lb.kubesphere.local:6443 --token qpnirw.gyfdxnceyth942i9 \ --discovery-token-ca-cert-hash sha256:8f0739bdfa2fb5a6118b5b6d0e10985641aa7c903fd749e073caf718b350c282 \ --control-plane Then you can join any number of worker nodes by running the following on each as root: kubeadm join lb.kubesphere.local:6443 --token qpnirw.gyfdxnceyth942i9 \ --discovery-token-ca-cert-hash sha256:8f0739bdfa2fb5a6118b5b6d0e10985641aa7c903fd749e073caf718b350c282 The final output shown below indicates that the KubeSphere cluster has also been installed successfully. Optional Install Kubernetes Separately You may also omit the KubeSphere and Kubernetes version numbers. BASH ./kk create cluster --with-kubernetes BASH [root@kubesphere-master ~]# ./kk create cluster --with-kubernetes --with-kubesphere _ __ _ _ __ | | / / | | | | / / | |/ / _ | | | |/ / ___ _ _ | | | | | ' \ / _ \ \ / _ \ | | | | |\ \ || | |) | / |\ \ / || | _| _/_,|./ __| _/_|_, | / | |/ 05:30:47 UTC [GreetingsModule] Greetings 05:30:47 UTC message: [kubesphere-master] Greetings, KubeKey! 05:30:47 UTC success: [kubesphere-master] 05:30:47 UTC [NodePreCheckModule] A pre-check on nodes 05:30:48 UTC success: [kubesphere-master] 05:30:48 UTC [ConfirmModule] Display confirmation form +-------------------+------+------+---------+----------+-------+-------+---------+-----------+--------+--------+------------+------------+-------------+------------------+--------------+ | name | sudo | curl | openssl | ebtables | socat | ipset | ipvsadm | conntrack | chrony | docker | containerd | nfs client | ceph client | glusterfs client | time | +-------------------+------+------+---------+----------+-------+-------+---------+-----------+--------+--------+------------+------------+-------------+------------------+--------------+ | kubesphere-master | y | y | y | y | y | y | y | y | y | | | y | | | UTC 05:30:48 | +-------------------+------+------+---------+----------+-------+-------+---------+-----------+--------+--------+------------+------------+-------------+------------------+--------------+ This is a simple check of your environment. Before installation, ensure that your machines meet all requirements specified at https://github.com/kubesphere/kubekey#requirements-and-recommendations Continue this installation? [yes/no]: yes The Kubernetes cluster is now installed. Use the following commands to check its status. BASH [root@kubesphere-master ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION kubesphere-master Ready control-plane,master,worker 2m14s v1.23.10 [root@kubesphere-master ~]# kubectl get pod -A NAMESPACE NAME READY STATUS RESTARTS AGE kube-system calico-kube-controllers-74dbdc644f-rsn8n 1/1 Running 0 2m6s kube-system calico-node-p27nq 1/1 Running 0 2m7s kube-system coredns-b7c47bcdc-45mzd 1/1 Running 0 2m6s kube-system coredns-b7c47bcdc-5n5mc 1/1 Running 0 2m6s kube-system kube-apiserver-kubesphere-master 1/1 Running 0 2m17s kube-system kube-controller-manager-kubesphere-master 1/1 Running 0 2m17s kube-system kube-proxy-xqsl4 1/1 Running 0 2m7s kube-system kube-scheduler-kubesphere-master 1/1 Running 0 2m17s kube-system nodelocaldns-m6j69 1/1 Running 0 2m7s Optional Install KubeSphere Separately BASH [root@kubesphere-master ~]# ./kk create cluster --with-kubesphere _ __ _ _ __ | | / / | | | | / / | |/ / _ | | | |/ / ___ _ _ | | | | | ' \ / _ \ \ / _ \ | | | | |\ \ || | |) | / |\ \ / || | _| _/_,|./ __| _/___|_, | / | |/ 05:36:52 UTC [GreetingsModule] Greetings 05:36:53 UTC message: [kubesphere-master] Greetings, KubeKey! 05:36:53 UTC success: [kubesphere-master] 05:36:53 UTC [NodePreCheckModule] A pre-check on nodes 05:36:53 UTC success: [kubesphere-master] 05:36:53 UTC [ConfirmModule] Display confirmation form +-------------------+---

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.