Skip to content

Commit

Permalink
add support for additional rancher helm repos
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonas Berhe authored and Yonas Berhe committed Sep 6, 2024
1 parent d6b2e92 commit 615f337
Showing 1 changed file with 32 additions and 13 deletions.
45 changes: 32 additions & 13 deletions cypress/jenkins/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ DASHBOARD_REPO="${DASHBOARD_REPO:-rancher/dashboard.git}"
DASHBOARD_BRANCH="${DASHBOARD_BRANCH:-master}"
GITHUB_URL="https://github.com/"
RANCHER_TYPE="${RANCHER_TYPE:-local}"
RANCHER_REPO="${RANCHER_REPO:-latest}"
HELM_VERSION="${HELM_VERSION:-3.13.2}"
NODEJS_VERSION="${NODEJS_VERSION:-14.19.1}"
CYPRESS_VERSION="${CYPRESS_VERSION:-13.2.0}"
Expand Down Expand Up @@ -92,25 +93,43 @@ create_initial_clusters() {
TARFILE="helm-v${HELM_VERSION}-linux-amd64.tar.gz"
curl -L -o "${TARFILE}" "https://get.helm.sh/${TARFILE}"
tar -C "${WORKSPACE}/bin" --strip-components=1 -xzf "${TARFILE}"
helm repo add rancher-latest https://releases.rancher.com/server-charts/latest
helm repo update
if [[ -n "${RANCHER_REPO}" ]]; then
if [[ "${RANCHER_REPO}" == "prime" ]]; then
# RANCHER_REPO="rancher-prime"
helm repo add rancher-"${RANCHER_REPO}" https://charts.rancher.com/server-charts/"${RANCHER_REPO}"
helm repo update
elif [[ "${RANCHER_REPO}" == "alpha" ]]; then
# RANCHER_REPO="rancher-alpha"
helm repo add rancher-"${RANCHER_REPO}" https://releases.rancher.com/server-charts/"${RANCHER_REPO}"
helm repo update
elif [[ "${RANCHER_REPO}" == "stable" ]]; then
# RANCHER_REPO="rancher-stable"
helm repo add rancher-"${RANCHER_REPO}" https://releases.rancher.com/server-charts/"${RANCHER_REPO}"
helm repo update
else
# RANCHER_REPO="rancher-latest"
helm repo add rancher-latest https://releases.rancher.com/server-charts/latest
helm repo update
fi
corral config vars set rancher_chart_repo "${RANCHER_REPO}"
fi
version_string=$(echo "${RANCHER_IMAGE_TAG}" | cut -f1 -d"-")
if [[ -z "${RANCHER_VERSION}" && "${RANCHER_IMAGE_TAG}" == "head" ]]; then
RANCHER_VERSION=$(helm search repo rancher-latest --devel --versions | sed -n '1!p' | head -1 | cut -f2 | tr -d '[:space:]')
elif [[ -z "${RANCHER_VERSION}" ]]; then
RANCHER_VERSION=$(helm search repo rancher-latest --devel --versions | grep "${version_string}" | head -n 1 | cut -f2 | tr -d '[:space:]')
if [[ "${RANCHER_IMAGE_TAG}" == "head" ]]; then
RANCHER_VERSION=$(helm search repo "${RANCHER_REPO}" --devel --versions | sed -n '1!p' | head -1 | cut -f2 | tr -d '[:space:]')
else
RANCHER_VERSION=$(helm search repo "${RANCHER_REPO}" --devel --versions | grep "${version_string}" | head -n 1 | cut -f2 | tr -d '[:space:]')
fi
corral config vars set rancher_image_tag "${RANCHER_IMAGE_TAG}"
fi
cd "${WORKSPACE}/corral-packages"
yq -i e ".variables.rancher_version += [\"${RANCHER_VERSION}\"] | .variables.rancher_version style=\"literal\"" packages/aws/rancher-k3s.yaml
yq -i e ".variables.kubernetes_version += [\"${K3S_KUBERNETES_VERSION}\"] | .variables.kubernetes_version style=\"literal\"" packages/aws/rancher-k3s.yaml
yq -i e ".variables.cert_manager_version += [\"${CERT_MANAGER_VERSION}\"] | .variables.kubernetes_version style=\"literal\"" packages/aws/rancher-k3s.yaml
yq -i e ".variables.rancher_version += [\"${RANCHER_VERSION}\"] | .variables.rancher_version style=\"literal\"" packages/aws/rancher-rke2.yaml
yq -i e ".variables.kubernetes_version += [\"${K3S_KUBERNETES_VERSION}\"] | .variables.kubernetes_version style=\"literal\"" packages/aws/rancher-rke2.yaml
yq -i e ".variables.cert_manager_version += [\"${CERT_MANAGER_VERSION}\"] | .variables.kubernetes_version style=\"literal\"" packages/aws/rancher-rke2.yaml

echo $'manifest:\n name: custom-node\ndescription: custom generated node\ntemplates:\n - aws/nodes\nvariables:\n instance_type:\n - t3a.xlarge' > packages/aws/custom-node.yaml

yq -i e ".variables.kubernetes_version += [\"${K3S_KUBERNETES_VERSION}\"] | .variables.kubernetes_version style=\"literal\"" packages/aws/k3s.yaml
cat packages/aws/rancher-k3s.yaml
yq -i e ".variables.kubernetes_version += [\"${K3S_KUBERNETES_VERSION}\"] | .variables.kubernetes_version style=\"literal\"" packages/aws/rancher-rke2.yaml
cat packages/aws/rancher-rke2.yaml
ls -al packages/aws/
cat packages/aws/dashboard-tests.yaml
cat packages/aws/custom-node.yaml
Expand Down Expand Up @@ -143,12 +162,12 @@ create_initial_clusters() {
corral config vars set aws_hostname_prefix "jenkins-${prefix_random}-i"
corral config vars set server_count 1
corral create --skip-cleanup --recreate --debug importcluster \
"dist/aws-k3s-${K3S_KUBERNETES_VERSION}"
"dist/aws-rke2-rancher-calico-${K3S_KUBERNETES_VERSION}-${RANCHER_VERSION//v}-${CERT_MANAGER_VERSION}"
corral config vars set imported_kubeconfig $(corral vars importcluster kubeconfig)
corral config vars set aws_hostname_prefix "jenkins-${prefix_random}"
corral config vars set server_count "${SERVER_COUNT:-3}"
corral create --skip-cleanup --recreate --debug rancher \
"dist/aws-k3s-rancher-${K3S_KUBERNETES_VERSION}-${RANCHER_VERSION//v}-${CERT_MANAGER_VERSION}"
"dist/aws-rke2-rancher-calico-${K3S_KUBERNETES_VERSION}-${RANCHER_VERSION//v}-${CERT_MANAGER_VERSION}"
}


Expand Down

0 comments on commit 615f337

Please sign in to comment.