diff --git a/examples/kubernetes/README.md b/examples/kubernetes/README.md index 79acc562..c755c885 100644 --- a/examples/kubernetes/README.md +++ b/examples/kubernetes/README.md @@ -2,6 +2,10 @@ NOTE: Docker in Docker (dind) requires elevated privileges on Kubernetes. The current way to achieve this is to set the pod `SecurityContext` to `privileged`. Keep in mind that this is a potential security issue that has the potential for a malicious application to break out of the container context. +NOTE: `dind-docker.yaml` uses the native sidecar pattern (init container with `restartPolicy: Always`), which requires Kubernetes 1.29+ (or 1.28 with the `SidecarContainers` feature gate). + +NOTE: A helm chart for `gitea-runner` also exists for easier deployments https://gitea.com/gitea/helm-actions + Files in this directory: - [`dind-docker.yaml`](dind-docker.yaml) diff --git a/examples/kubernetes/dind-docker.yaml b/examples/kubernetes/dind-docker.yaml index b247f3d9..ce3b4a22 100644 --- a/examples/kubernetes/dind-docker.yaml +++ b/examples/kubernetes/dind-docker.yaml @@ -4,7 +4,7 @@ metadata: name: runner-vol spec: accessModes: - - ReadWriteOnce + - ReadWriteOnce resources: requests: storage: 1Gi @@ -35,28 +35,35 @@ spec: strategy: {} template: metadata: - creationTimestamp: null labels: app: runner spec: restartPolicy: Always volumes: - - name: docker-certs + - name: docker-socket emptyDir: {} - name: runner-data persistentVolumeClaim: claimName: runner-vol + initContainers: + - name: docker + image: docker:28.2.2-dind + securityContext: + privileged: true + volumeMounts: + - name: docker-socket + mountPath: /var/run + startupProbe: + exec: + command: ["/usr/bin/test", "-S", "/var/run/docker.sock"] + livenessProbe: + exec: + command: ["/usr/bin/test", "-S", "/var/run/docker.sock"] + restartPolicy: Always containers: - name: runner image: gitea/runner:nightly - command: ["sh", "-c", "while ! nc -z localhost 2376