From 85329974b14e29ffe18986ceb38dcedca3d3baab Mon Sep 17 00:00:00 2001 From: Aki Liu Date: Thu, 14 Sep 2023 22:32:47 +0800 Subject: [PATCH] update install-rancher.sh --- .../scripts/install-rancher-ent.sh | 97 +++++++++++++++++++ .../scripts/install-rancher.sh | 8 +- 2 files changed, 100 insertions(+), 5 deletions(-) create mode 100644 scenarios/azure/linux-server-cockpit/scripts/install-rancher-ent.sh diff --git a/scenarios/azure/linux-server-cockpit/scripts/install-rancher-ent.sh b/scenarios/azure/linux-server-cockpit/scripts/install-rancher-ent.sh new file mode 100644 index 0000000..3adbe14 --- /dev/null +++ b/scenarios/azure/linux-server-cockpit/scripts/install-rancher-ent.sh @@ -0,0 +1,97 @@ +#! /bin/bash -e + +# Install Kubernetes tools +echo "Installing Kubernetes Client Tools - kubectl and helm ..." + +curl -sLS https://get.arkade.dev | sudo sh + +sudo ark get helm +sudo mv /root/.arkade/bin/helm /usr/local/bin/ + +sudo ark get kubectl +sudo mv /root/.arkade/bin/kubectl /usr/local/bin/ + + +#! /bin/bash -e + +# install rancher server +echo "Install Rancher Server using helm chart on RKE2 ..." + +echo "Install RKE2 v1.25 ..." +sudo bash -c 'curl -sfL https://get.rke2.io | INSTALL_RKE2_CHANNEL="v1.25" sh -' +sudo mkdir -p /etc/rancher/rke2 +sudo bash -c 'echo "write-kubeconfig-mode: \"0644\"" > /etc/rancher/rke2/config.yaml' +sudo systemctl enable rke2-server.service +sudo systemctl start rke2-server.service + +mkdir -p $HOME/.kube +ln -s /etc/rancher/rke2/rke2.yaml $HOME/.kube/config +export KUBECONFIG=$HOME/.kube/config + +# Wait until the RKE2 is ready +echo "Initializing RKE2 cluster ..." +while [ `kubectl get deploy -n kube-system | grep 1/1 | wc -l` -ne 3 ] +do + sleep 5 + kubectl get po -n kube-system +done +echo "Your RKE2 cluster is ready!" +kubectl get node + +echo "Install Cert Manager v1.11.4 ..." +kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.11.4/cert-manager.crds.yaml +helm repo add jetstack https://charts.jetstack.io +helm install \ + cert-manager jetstack/cert-manager \ + --namespace cert-manager \ + --version v1.11.4 \ + --create-namespace + +kubectl -n cert-manager rollout status deploy/cert-manager + +# Wait until cert-manager deployment complete +echo "Wait until cert-manager deployment finish ..." +while [ `kubectl get deploy -n cert-manager | grep 1/1 | wc -l` -ne 3 ] +do + sleep 5 + kubectl get po -n cert-manager +done + + +# Install Rancher with helm chart +echo "Install Rancher ${RANCHER_VERSION} ..." +RANCHER_IP=`curl -qs http://checkip.amazonaws.com` +RANCHER_FQDN=rancher.$RANCHER_IP.sslip.io +RANCHER_VERSION=v2.7.5-ent + +helm repo add rancher-prime https://pandaria-releases.oss-cn-beijing.aliyuncs.com/2.7-prime/latest +helm repo update + +helm upgrade --install rancher rancher-prime/rancher \ + --namespace cattle-system \ + --set hostname=$RANCHER_FQDN \ + --set replicas=1 \ + --set global.cattle.psp.enabled=false \ + --set rancherImage=harbor.13.228.163.47.sslip.io/prime/rancher \ + --set systemDefaultRegistry=harbor.13.228.163.47.sslip.io \ + --version ${RANCHER_VERSION} \ + --create-namespace + +echo "Wait until cattle-system deployment finish ..." +while [ `kubectl get deploy -n cattle-system | grep 1/1 | wc -l` -ne 1 ] +do + sleep 5 + kubectl get po -n cattle-system +done + +RANCHER_BOOTSTRAP_PWD=`kubectl get secret --namespace cattle-system bootstrap-secret -o go-template='{{.data.bootstrapPassword|base64decode}}{{ "\n" }}'` + + +echo +echo "---------------------------------------------------------" +echo "Your Rancher Server is ready." +echo +echo "Your Rancher Server URL: https://${RANCHER_FQDN}" > rancher-url.txt +echo "Bootstrap Password: ${RANCHER_BOOTSTRAP_PWD}" >> rancher-url.txt +cat rancher-url.txt +echo "---------------------------------------------------------" diff --git a/scenarios/azure/linux-server-cockpit/scripts/install-rancher.sh b/scenarios/azure/linux-server-cockpit/scripts/install-rancher.sh index 3adbe14..38e2af5 100644 --- a/scenarios/azure/linux-server-cockpit/scripts/install-rancher.sh +++ b/scenarios/azure/linux-server-cockpit/scripts/install-rancher.sh @@ -62,18 +62,16 @@ done echo "Install Rancher ${RANCHER_VERSION} ..." RANCHER_IP=`curl -qs http://checkip.amazonaws.com` RANCHER_FQDN=rancher.$RANCHER_IP.sslip.io -RANCHER_VERSION=v2.7.5-ent +RANCHER_VERSION=v2.7.6 -helm repo add rancher-prime https://pandaria-releases.oss-cn-beijing.aliyuncs.com/2.7-prime/latest +helm repo add rancher-latest https://releases.rancher.com/server-charts/latest helm repo update -helm upgrade --install rancher rancher-prime/rancher \ +helm upgrade --install rancher rancher-latest/rancher \ --namespace cattle-system \ --set hostname=$RANCHER_FQDN \ --set replicas=1 \ --set global.cattle.psp.enabled=false \ - --set rancherImage=harbor.13.228.163.47.sslip.io/prime/rancher \ - --set systemDefaultRegistry=harbor.13.228.163.47.sslip.io \ --version ${RANCHER_VERSION} \ --create-namespace