mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-05-14 20:03:24 +02:00
Simplify kubernetes dind example allowing for default docker config in workflows (#709)
With this docker clients in workflows can connect on the default socket without needing to change DOCKER_HOST. Startup probe also removes the need for custom shell command. Co-authored-by: silverwind <me@silverwind.io> Reviewed-on: https://gitea.com/gitea/runner/pulls/709 Co-authored-by: thisisqasim <40013+thisisqasim@noreply.gitea.com> Co-committed-by: thisisqasim <40013+thisisqasim@noreply.gitea.com>
This commit is contained in:
@@ -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: 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:
|
Files in this directory:
|
||||||
|
|
||||||
- [`dind-docker.yaml`](dind-docker.yaml)
|
- [`dind-docker.yaml`](dind-docker.yaml)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ metadata:
|
|||||||
name: runner-vol
|
name: runner-vol
|
||||||
spec:
|
spec:
|
||||||
accessModes:
|
accessModes:
|
||||||
- ReadWriteOnce
|
- ReadWriteOnce
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
storage: 1Gi
|
storage: 1Gi
|
||||||
@@ -35,28 +35,35 @@ spec:
|
|||||||
strategy: {}
|
strategy: {}
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
creationTimestamp: null
|
|
||||||
labels:
|
labels:
|
||||||
app: runner
|
app: runner
|
||||||
spec:
|
spec:
|
||||||
restartPolicy: Always
|
restartPolicy: Always
|
||||||
volumes:
|
volumes:
|
||||||
- name: docker-certs
|
- name: docker-socket
|
||||||
emptyDir: {}
|
emptyDir: {}
|
||||||
- name: runner-data
|
- name: runner-data
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: runner-vol
|
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:
|
containers:
|
||||||
- name: runner
|
- name: runner
|
||||||
image: gitea/runner:nightly
|
image: gitea/runner:nightly
|
||||||
command: ["sh", "-c", "while ! nc -z localhost 2376 </dev/null; do echo 'waiting for docker daemon...'; sleep 5; done; /sbin/tini -- run.sh"]
|
|
||||||
env:
|
env:
|
||||||
- name: DOCKER_HOST
|
|
||||||
value: tcp://localhost:2376
|
|
||||||
- name: DOCKER_CERT_PATH
|
|
||||||
value: /certs/client
|
|
||||||
- name: DOCKER_TLS_VERIFY
|
|
||||||
value: "1"
|
|
||||||
- name: GITEA_INSTANCE_URL
|
- name: GITEA_INSTANCE_URL
|
||||||
value: http://gitea-http.gitea.svc.cluster.local:3000
|
value: http://gitea-http.gitea.svc.cluster.local:3000
|
||||||
- name: GITEA_RUNNER_REGISTRATION_TOKEN
|
- name: GITEA_RUNNER_REGISTRATION_TOKEN
|
||||||
@@ -65,17 +72,7 @@ spec:
|
|||||||
name: runner-secret
|
name: runner-secret
|
||||||
key: token
|
key: token
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: docker-certs
|
|
||||||
mountPath: /certs
|
|
||||||
- name: runner-data
|
- name: runner-data
|
||||||
mountPath: /data
|
mountPath: /data
|
||||||
- name: daemon
|
- name: docker-socket
|
||||||
image: docker:23.0.6-dind
|
mountPath: /var/run
|
||||||
env:
|
|
||||||
- name: DOCKER_TLS_CERTDIR
|
|
||||||
value: /certs
|
|
||||||
securityContext:
|
|
||||||
privileged: true
|
|
||||||
volumeMounts:
|
|
||||||
- name: docker-certs
|
|
||||||
mountPath: /certs
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ metadata:
|
|||||||
name: runner-vol
|
name: runner-vol
|
||||||
spec:
|
spec:
|
||||||
accessModes:
|
accessModes:
|
||||||
- ReadWriteOnce
|
- ReadWriteOnce
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
storage: 1Gi
|
storage: 1Gi
|
||||||
@@ -35,7 +35,6 @@ spec:
|
|||||||
strategy: {}
|
strategy: {}
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
creationTimestamp: null
|
|
||||||
labels:
|
labels:
|
||||||
app: runner
|
app: runner
|
||||||
spec:
|
spec:
|
||||||
@@ -50,7 +49,6 @@ spec:
|
|||||||
- name: runner
|
- name: runner
|
||||||
image: gitea/runner:nightly-dind-rootless
|
image: gitea/runner:nightly-dind-rootless
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
# command: ["sh", "-c", "while ! nc -z localhost 2376 </dev/null; do echo 'waiting for docker daemon...'; sleep 5; done; /sbin/tini -- run.sh"]
|
|
||||||
env:
|
env:
|
||||||
- name: DOCKER_HOST
|
- name: DOCKER_HOST
|
||||||
value: tcp://localhost:2376
|
value: tcp://localhost:2376
|
||||||
|
|||||||
Reference in New Issue
Block a user