BUILD CLUSTER RANCHER KUBERNETES
Minimum Specification Cluster of Rancher Kubernetes
OS Request openSUSE 15.5 All Node
BUILD MASTER
- Install All Node3 Master Server With OS opensuse
- Add /etc/hosts
# for upstream node
192.168.1.111 rancher-node1.local rancher-node1
192.168.1.112 rancher-node2.local rancher-node2
192.168.1.113 rancher-node3.pocrancher.local rancher-node3
# for downstream node
192.168.1.116 cluster1-node1.local cluster1-node1
192.168.1.117 cluster1-node2.local cluster1-node2
192.168.1.118 cluster1-node3.local cluster1-node3
#Install All Node
# if need docker for RKE1
SUSEConnect -p sle-module-containers/15.4/x86_64 -r ''
zypper -n install docker
systemctl start docker
systemctl enable docker
systemctl status docker
----
#Create the folder /etc/rancher/rke2:
mkdir -p /etc/rancher/rke2
#navigate to the newly created folder and create a config.yaml file:
cd /etc/rancher/rke2
cat > config.yaml <<EOF
token: my-shared-secret
tls-san:
- rancher.pocrancher.local
- rancher-node1.local
- rancher-node2.local
- rancher-node3.local
EOF
# Enable & start service:
systemctl enable rke2-server.service
systemctl start rke2-server.service
in Node1 | install & config kubectl run:
cd
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
mkdir -p ~/.kube
ln -s /etc/rancher/rke2/rke2.yaml ~/.kube/config
kubectl get nodes -o wide
kubectl get pods --all-namespaces -o wide
kubectl get componentstatuses
#---- if upstream only 1 node, skip this step
#-- For Node2 & 3
# install rke2
curl -sfL https://get.rke2.io |sh -
# Create the folder /etc/rancher/rke2
mkdir -p /etc/rancher/rke2
# create a config.yaml file
cd /etc/rancher/rke2
cat > config.yaml <<EOF
server: https://rancher.local:9345
token: my-shared-secret
tls-san:
- rancher.pocrancher.local
- rancher-node1.local
- rancher-node2.local
- rancher-node3.local
EOF
#-- start services rke2
systemctl enable rke2-server.service
systemctl start rke2-server.service
#You can follow the logs with
sudo journalctl -u rke2-server -f
#-- Other methode for install & running kubectl
#-- Install Kubectl | run on rancher-node1
zypper -n install kubernetes1.18-client
#-- Verify k8s cluster
kubectl --kubeconfig kube_config_cluster.yml get node
#-- Setting kube-config
cd /root
cp kube_config_cluster.yml .kube/kube-rke
cat > kube-rke.sh <<EOF
export KUBECONFIG=/root/.kube/kube-rke
EOF
chmod +x kube-rke.sh
source kube-rke.sh
kubectl get node
#---- RMS Install - only running with SLES
# Process in Node1
1. Install Helm:
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
helm version --client
2. Add repo and create namespace cattle-system for RMS instance:
helm repo add rancher-stable https://releases.rancher.com/server-charts/stable
#helm repo add rancher-latest https://releases.rancher.com/server-charts/latest
kubectl create namespace cattle-system
3. Apply the certification manager file. In this case, we are using v1.0.4 but the newer version will work as well:
#chart requires kubeVersion: >= 1.21.0
#kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/v1.5.1/cert-manager.crds.yaml
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.crds.yaml
4. Create the cert-manager namespace for cert manager rancher:
kubectl create namespace cert-manager
5. Add jetstack repository:
helm repo add jetstack https://charts.jetstack.io
helm repo update
6. Helm install the certificate manager in a new namespace called cert-manager:
helm install cert-manager jetstack/cert-manager \
--namespace cert-manager \
--create-namespace \
--version v1.11.0
7. Verify that the cert-manager pods are running:
kubectl get pods --namespace cert-manager
8. Install the latest rancher in the cattle-system namespace and set the hostname:
helm install rancher rancher-stable/rancher \
--namespace cattle-system \
--set hostname=rancher.pocrancher.local \
--version v2.7.5 \
--set replicas=2
#helm install rancher rancher-stable/rancher \
#--namespace cattle-system \
#--set hostname=rancher.pocrancher.local \
#--set global.cattle.psp.enabled=false \
#--version v2.7.2 \
#--set replicas=1
# Verify rancher ready
while true; do curl -kv https://rancher.local 2>&1 | grep -q "dynamiclistener-ca"; if [ $? != 0 ]; then echo "Rancher isn't ready yet"; sleep 5; continue; fi; break; done; echo "Rancher is Ready";
# Pastikan pod di cert-manager & cattle-system running/completed
kubectl get pods --namespace cert-manager
kubectl get pods --namespace cattle-system
kubectl -n cattle-system get deploy rancher
9. makesure your pod at namespaces cert-manager & cattle-system running/completed:
DEPLOY WORKER
- Install All Node3 Worker Server With OS opensuse
- Create / Regis All Node Cluster RKE