Skip to content

Instantly share code, notes, and snippets.

@alexander-demicev
Last active December 7, 2023 18:18
Show Gist options
  • Save alexander-demicev/13be899c9b33cdeb42d69c8777fb9e54 to your computer and use it in GitHub Desktop.
Save alexander-demicev/13be899c9b33cdeb42d69c8777fb9e54 to your computer and use it in GitHub Desktop.
# 1. Create kind cluster with custom configuration in order to run CAPI Docker provider on it later
cat > kind-cluster-with-extramounts.yaml <<EOF
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: capi-test
nodes:
- role: control-plane
image: kindest/node:v1.26.3
extraMounts:
- hostPath: /var/run/docker.sock
containerPath: /var/run/docker.sock
EOF
kind create cluster --config kind-cluster-with-extramounts.yaml
# 2. Install cert-manager
helm install cert-manager jetstack/cert-manager \
--namespace cert-manager \
--create-namespace \
--version v1.12.3 \
--set installCRDs=true \
--wait
# 3. Install Rancher
helm install rancher rancher-stable/rancher \
--namespace cattle-system \
--create-namespace \
--set replicas=1 \
--set hostname="$RANCHER_HOSTNAME" \
--set global.cattle.psp.enabled=false \
--set 'extraEnv[0].name=CATTLE_FEATURES' \
--set 'extraEnv[0].value=embedded-cluster-api=false' \
--version $RANCHER_VERSION
# 4. Create secret that will be used to configure Cluster API Operator providers.
cat > capi-variables.yaml <<EOF
apiVersion: v1
kind: Secret
metadata:
name: variables
namespace: default
type: Opaque
stringData:
CLUSTER_TOPOLOGY: "true"
EXP_CLUSTER_RESOURCE_SET: "true"
EXP_MACHINE_POOL: "true"
EOF
kubectl apply -f capi-variables.yaml
# 5. This step contains setting the configuration for using private registry. All images published for
# Rancher Tutrles including nightly are private. Make sure you are part of rancher-sandbox org on GitHub and logged
# into GHCR using "docker login"
kubectl create ns rancher-turtles-system
kubectl create secret generic ghcrtoken --from-file=.dockerconfigjson=$PATH_TO_DOCKER_CONFIG/.docker/config.json --namespace=rancher-turtles-system --type=kubernetes.io/dockerconfigjson
# 6. Install Rancher Turtles. In the github actions dashboard select required nightly build https://github.com/rancher-sandbox/rancher-turtles/actions/workflows/nightly-chart-and-image-publish.yaml
# When looking at the specific job, last step will print example helm that contains nightly build version.
helm install rancher-turtles oci://ghcr.io/rancher-sandbox/rancher-turtles-chart/rancher-turtles \
--version $NIGHTLY_BUILD_VERSION -n rancher-turtles-system \
--set cluster-api-operator.cert-manager.enabled=false \
--set cluster-api-operator.cluster-api.configSecret.name=variables \
--set cluster-api-operator.cluster-api.configSecret.namespace=default \
--set rancherTurtles.imagePullSecrets[0]=ghcrtoken \
--set=rancherTurtles.features.embedded-capi.disabled=false \
--dependency-update --wait --timeout 180s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment