Last active
February 15, 2026 21:08
-
-
Save eumel8/db8eb4bf32e551eb8ca96a9c5b3372ff to your computer and use it in GitHub Desktop.
gitlab-ci-k8s
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Gitlab CI Pipeline for kind/k3d for end to end test | |
| # Docker 28+ breaks nested container runtimes (k3d/kind) due to procfs hardening. | |
| # Pinned to docker:27-dind intentionally for Helm E2E testing. | |
| image: docker:27-dind | |
| services: | |
| - name: docker:27-dind | |
| alias: docker | |
| variables: | |
| DOCKER_HOST: tcp://docker:2375 | |
| DOCKER_TLS_CERTDIR: "" | |
| KIND_VERSION: v0.31.0 | |
| KUBECTL_VERSION: v1.34.3 | |
| HELM_VERSION: v4.1.0 | |
| CLUSTER_NAME: ci-cluster | |
| K3S_VERSION: v1.35.0-k3s3 | |
| K3D_VERSION: v5.8.3 | |
| stages: | |
| - deploy | |
| - cleanup | |
| before_script: | |
| # Install Packages on Alpine Image | |
| - apk add --no-cache curl bash | |
| - docker version | |
| # Install kind | |
| - curl -Lo /usr/local/bin/kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-linux-amd64 | |
| - chmod +x /usr/local/bin/kind | |
| # Install kubectl | |
| - curl -Lo /usr/local/bin/kubectl https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl | |
| - chmod +x /usr/local/bin/kubectl | |
| # Install helm | |
| - curl -fsSL https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz | tar -xzv | |
| - mv linux-amd64/helm /usr/local/bin/ | |
| - rm -rf linux-amd64 | |
| kind-cluster: | |
| stage: deploy | |
| tags: | |
| - dind | |
| parallel: | |
| matrix: | |
| - KIND_VERSION: ["v0.31.0", "v0.30.0"] | |
| script: | |
| # Kind config | |
| - | | |
| cat <<EOF > kind-config.yaml | |
| kind: Cluster | |
| apiVersion: kind.x-k8s.io/v1alpha4 | |
| nodes: | |
| - role: control-plane | |
| - role: worker | |
| - role: worker | |
| networking: | |
| apiServerAddress: "0.0.0.0" | |
| apiServerPort: 6443 | |
| kubeadmConfigPatches: | |
| - | | |
| kind: ClusterConfiguration | |
| apiServer: | |
| certSANs: | |
| - "docker" | |
| EOF | |
| # Create cluster | |
| - kind create cluster --name ${CLUSTER_NAME} --config kind-config.yaml | |
| # Replace API endpoint in kubeconfig | |
| - sed -i -E -e "s/localhost|0\.0\.0\.0/docker/g" "$HOME/.kube/config" | |
| # Test | |
| - kubectl cluster-info | |
| - kubectl wait --for=condition=ready nodes --all --timeout=300s | |
| - kubectl get nodes -o wide | |
| # Start application test here | |
| - echo "app test" | |
| k3d-cluster: | |
| stage: deploy | |
| tags: | |
| - dind | |
| parallel: | |
| matrix: | |
| - K8S_VERSION: ["v1.35.0-k3s3", "v1.34.3-k3s3"] | |
| script: | |
| - curl -Lo /usr/local/bin/k3d https://github.com/k3d-io/k3d/releases/download/${K3D_VERSION}/k3d-linux-amd64 | |
| - chmod +x /usr/local/bin/kubectl /usr/local/bin/k3d | |
| # Create cluster (API direkt erreichbar) | |
| - | | |
| k3d cluster create ${CLUSTER_NAME} \ | |
| --image rancher/k3s:${K3S_VERSION} \ | |
| --api-port 6443 \ | |
| --servers 1 \ | |
| --agents 0 \ | |
| --wait | |
| # Test | |
| - kubectl cluster-info | |
| - kubectl wait --for=condition=ready nodes --all --timeout=300s | |
| - kubectl get nodes -o wide | |
| # Start application test here | |
| - echo "app test" | |
| cleanup-kind: | |
| stage: cleanup | |
| tags: | |
| - dind | |
| needs: | |
| - kind-cluster | |
| when: always | |
| script: | |
| - kind delete cluster --name ${CLUSTER_NAME} |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
kwok/vanilla example