Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow drone server container port to be configurable #124

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions charts/drone-runner-docker/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if eq .Values.kind "Deployment" }}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand All @@ -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 }}
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -160,4 +167,5 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/drone-runner-docker/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 2 additions & 0 deletions charts/drone-runner-docker/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if eq .Values.kind "Deployment" }}
apiVersion: v1
kind: Service
metadata:
Expand All @@ -13,3 +14,4 @@ spec:
name: http
selector:
{{- include "drone-runner-docker.selectorLabels" . | nindent 4 }}
{{- end }}
190 changes: 190 additions & 0 deletions charts/drone-runner-docker/templates/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
19 changes: 12 additions & 7 deletions charts/drone-runner-docker/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@
# 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: []
# - ip: 10.20.30.40
# 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/
Expand All @@ -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.
##
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion charts/drone/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
2 changes: 1 addition & 1 deletion charts/drone/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ spec:
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
containerPort: {{ .Values.service.containerPort }}
protocol: TCP
livenessProbe:
httpGet:
Expand Down
6 changes: 6 additions & 0 deletions charts/drone/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ updateStrategy: {}
service:
type: ClusterIP
port: 8080
containerPort: 8080
annotations: {}
nodePort:

Expand Down Expand Up @@ -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/
##
Expand Down