diff --git a/charts/drone-runner-docker/templates/deployment.yaml b/charts/drone-runner-docker/templates/deployment.yaml index dcfa6b0..3d8d041 100644 --- a/charts/drone-runner-docker/templates/deployment.yaml +++ b/charts/drone-runner-docker/templates/deployment.yaml @@ -1,3 +1,4 @@ +{{- if eq .Values.kind "Deployment" }} apiVersion: apps/v1 kind: Deployment metadata: @@ -8,6 +9,7 @@ spec: {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount }} {{- end }} + revisionHistoryLimit: {{ .Values.revisionHistoryLimit }} selector: matchLabels: {{- include "drone-runner-docker.selectorLabels" . | nindent 6 }} @@ -36,8 +38,10 @@ spec: hostAliases: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.extraVolumes }} volumes: + - name: {{ include "drone-runner-docker.fullname" . }}-cache + emptyDir: {} + {{- with .Values.extraVolumes }} {{- toYaml . | nindent 8 }} {{- end }} containers: @@ -83,8 +87,11 @@ spec: resources: {{- toYaml . | nindent 12 }} {{- end }} - {{- with .Values.dind.extraVolumeMounts }} volumeMounts: + - name: {{ include "drone-runner-docker.fullname" . }}-cache + mountPath: /var/lib/docker + subPath: docker + {{- with .Values.dind.extraVolumeMounts }} {{- toYaml . | nindent 12 }} {{- end }} {{- if $.Values.gc.enabled }} @@ -160,4 +167,5 @@ spec: tolerations: {{- toYaml . | nindent 8 }} {{- end }} - terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} \ No newline at end of file + terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} +{{- end }} \ No newline at end of file diff --git a/charts/drone-runner-docker/templates/hpa.yaml b/charts/drone-runner-docker/templates/hpa.yaml index 533bcbd..8194dd5 100644 --- a/charts/drone-runner-docker/templates/hpa.yaml +++ b/charts/drone-runner-docker/templates/hpa.yaml @@ -12,7 +12,7 @@ metadata: spec: scaleTargetRef: apiVersion: apps/v1 - kind: Deployment + kind: {{ .Values.kind }} name: {{ include "drone-runner-docker.fullname" . }} minReplicas: {{ .Values.autoscaling.minReplicas }} maxReplicas: {{ .Values.autoscaling.maxReplicas }} diff --git a/charts/drone-runner-docker/templates/service.yaml b/charts/drone-runner-docker/templates/service.yaml index 1e404ea..4bedcce 100644 --- a/charts/drone-runner-docker/templates/service.yaml +++ b/charts/drone-runner-docker/templates/service.yaml @@ -1,3 +1,4 @@ +{{- if eq .Values.kind "Deployment" }} apiVersion: v1 kind: Service metadata: @@ -13,3 +14,4 @@ spec: name: http selector: {{- include "drone-runner-docker.selectorLabels" . | nindent 4 }} +{{- end }} \ No newline at end of file diff --git a/charts/drone-runner-docker/templates/statefulset.yaml b/charts/drone-runner-docker/templates/statefulset.yaml new file mode 100644 index 0000000..af19016 --- /dev/null +++ b/charts/drone-runner-docker/templates/statefulset.yaml @@ -0,0 +1,190 @@ +{{- if eq .Values.kind "StatefulSet" }} +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ include "drone-runner-docker.fullname" . }} + labels: + {{- include "drone-runner-docker.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + revisionHistoryLimit: {{ .Values.revisionHistoryLimit }} + serviceName: {{ include "drone-runner-docker.fullname" . }} + selector: + matchLabels: + {{- include "drone-runner-docker.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "drone-runner-docker.selectorLabels" . | nindent 8 }} + {{- if .Values.podLabels }} + {{- toYaml .Values.podLabels | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "drone-runner-docker.serviceAccountName" . }} + {{- with .Values.podSecurityContext }} + securityContext: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.hostAliases }} + hostAliases: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- if not .Values.persistance.enabled }} + volumes: + - name: {{ include "drone-runner-docker.fullname" . }}-cache + emptyDir: {} + {{- with .Values.extraVolumes }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- else }} + {{- with .Values.extraVolumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- end }} + containers: + - name: dind + image: "{{ .Values.dind.registry }}/{{ .Values.dind.repository }}:{{ .Values.dind.tag }}" + imagePullPolicy: {{ .Values.dind.pullPolicy }} + command: + {{- range .Values.dind.command }} + - {{ . }} + {{- end }} + args: + {{- range .Values.dind.commandArgs }} + - {{ . }} + {{- end }} + {{- with .Values.dind.securityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + lifecycle: + preStop: + # wait for all running containers to have stopped, so the last build can finish before the runner is fully stopped. + exec: + command: ["/bin/sh","-c","while true; do sleep {{ .Values.dind.gracefulShutdownRetryPeriod }}; lastEventTime=$(docker -H tcp://localhost:2375 events --since={{ .Values.dind.gracefulShutdownRetryPeriod }}s --until=1s | wc -l); containersRunning=$(docker -H tcp://localhost:2375 ps -q | wc -l); if [ $containersRunning -eq 0 ] && [ $lastEventTime -eq 0 ]; then exit 0; fi; echo 'steps/containers running, retry'; done"] + livenessProbe: + exec: + command: + - docker + - -H + - tcp://localhost:2375 + - images + initialDelaySeconds: 5 + periodSeconds: 5 + readinessProbe: + exec: + command: + - docker + - -H + - tcp://localhost:2375 + - images + initialDelaySeconds: 5 + periodSeconds: 5 + {{- with .Values.dind.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + volumeMounts: + - name: {{ include "drone-runner-docker.fullname" . }}-cache + mountPath: /var/lib/docker + subPath: docker + {{- with .Values.dind.extraVolumeMounts }} + {{- toYaml . | nindent 12 }} + {{- end }} + {{- if $.Values.gc.enabled }} + - name: gc + image: "{{ .Values.gc.registry }}/{{ .Values.gc.repository }}:{{ .Values.gc.tag }}" + imagePullPolicy: {{ .Values.gc.pullPolicy }} + {{- with .Values.gc.securityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + env: + - name: DOCKER_HOST + value: {{ .Values.env.DOCKER_HOST }} + {{- if $.Values.gc.env }} + {{- range $key, $value := $.Values.gc.env }} + - name: {{ $key }} + value: {{ $value | quote }} + {{- end }} + {{- end }} + {{- with .Values.gc.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- end }} + - name: {{ .Chart.Name }} + {{- with .Values.securityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + envFrom: + - configMapRef: + name: {{ include "drone-runner-docker.fullname" . }} + {{- range .Values.extraSecretNamesForEnvFrom }} + - secretRef: + name: {{ . }} + {{- end }} + {{- with .Values.extraVolumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + env: + - name: DOCKER_HOST + value: {{ .Values.env.DOCKER_HOST }} + - name: DRONE_RUNNER_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + ports: + - name: tcp + containerPort: 3000 + protocol: TCP + livenessProbe: + tcpSocket: + port: tcp + readinessProbe: + tcpSocket: + port: tcp + {{- with .Values.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} + {{- if .Values.persistance.enabled }} + volumeClaimTemplates: + - metadata: + name: {{ include "drone-runner-docker.fullname" . }}-cache + spec: + accessModes: [ {{ .Values.persistance.accessMode }} ] + storageClassName: {{ .Values.persistance.storageClass }} + resources: + requests: + storage: {{ .Values.persistance.size }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/drone-runner-docker/values.yaml b/charts/drone-runner-docker/values.yaml index c3ed1e6..bba3bc0 100644 --- a/charts/drone-runner-docker/values.yaml +++ b/charts/drone-runner-docker/values.yaml @@ -2,6 +2,15 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. +# -- Choose kind of workload you want to use. StatefulSet or Deployment +kind: StatefulSet + +persistance: + enabled: true + accessMode: ReadWriteOnce + storageClass: default + size: 32Gi + # -- Mapping between IP and hostnames that will be injected as entries in the pod's hosts files # https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/ hostAliases: [] @@ -9,6 +18,7 @@ hostAliases: [] # hostnames: # - gitea-127.0.0.1.sslip.io replicaCount: 1 +revisionHistoryLimit: 3 ## The official drone docker runner image, change tag to use a different version. ## ref: https://hub.docker.com/r/drone/drone-runner-docker/tags/ @@ -24,9 +34,7 @@ image: ## Volumes here per the Pod spec's "volumes" section of the dind container ## Ref: https://kubernetes.io/docs/concepts/storage/volumes/ ## -extraVolumes: - - name: storage - emptyDir: {} +extraVolumes: [] ## If you have declared extra volumes, mount them here, per the Pod Container's ## "volumeMounts" section. ## @@ -51,10 +59,7 @@ dind: ## If you have declared extra volumes, mount them here, per the Pod Container's ## "volumeMounts" section of dind container ## - extraVolumeMounts: - - name: storage - mountPath: /var/lib/docker - subPath: docker + extraVolumeMounts: [] resources: {} # We usually recommend not to specify default resources and to leave this as a conscious diff --git a/charts/drone/Chart.yaml b/charts/drone/Chart.yaml index 85d1258..b558402 100644 --- a/charts/drone/Chart.yaml +++ b/charts/drone/Chart.yaml @@ -4,7 +4,7 @@ name: drone description: Drone is a self-service Continuous Delivery platform for busy development teams # TODO: Un-comment once we move back to apiVersion: v2. # type: application -version: 0.6.5 +version: 0.6.6 appVersion: 2.20.0 kubeVersion: "^1.13.0-0" home: https://drone.io/ diff --git a/charts/drone/templates/deployment.yaml b/charts/drone/templates/deployment.yaml index aa3ba6c..8acd5db 100644 --- a/charts/drone/templates/deployment.yaml +++ b/charts/drone/templates/deployment.yaml @@ -38,7 +38,7 @@ spec: imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: http - containerPort: 80 + containerPort: {{ .Values.service.containerPort }} protocol: TCP livenessProbe: httpGet: diff --git a/charts/drone/values.yaml b/charts/drone/values.yaml index db263be..ff2f403 100644 --- a/charts/drone/values.yaml +++ b/charts/drone/values.yaml @@ -56,6 +56,7 @@ updateStrategy: {} service: type: ClusterIP port: 8080 + containerPort: 8080 annotations: {} nodePort: @@ -188,6 +189,11 @@ env: ## Ref: https://docs.drone.io/installation/reference/drone-server-host/ ## DRONE_SERVER_HOST: "" + + ## Set the default container port where the server will run. This configuration needs to match with service.containerPort, see above + ## + DRONE_SERVER_HOST: ":8080" + ## The protocol to pair with the value in DRONE_SERVER_HOST (http or https). ## Ref: https://docs.drone.io/installation/reference/drone-server-proto/ ##