diff --git a/charts/zuul/Chart.yaml b/charts/zuul/Chart.yaml new file mode 100644 index 0000000..36cfc71 --- /dev/null +++ b/charts/zuul/Chart.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: v1 +name: zuul +description: Zuul is a program that drives continuous integration, delivery, and deployment systems with a focus on project gating and interrelated projects. +home: https://zuul-ci.org/docs/zuul/ +appVersion: 3.14.0 +version: 0.0.1 diff --git a/charts/zuul/templates/_helpers.tpl b/charts/zuul/templates/_helpers.tpl new file mode 100644 index 0000000..0bf2309 --- /dev/null +++ b/charts/zuul/templates/_helpers.tpl @@ -0,0 +1,66 @@ +{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "zuul.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "zuul.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Generate basic labels +*/}} +{{- define "zuul.common.labels" }} +app.kubernetes.io/name: {{ include "zuul.fullname" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +app.kubernetes.io/part-of: zuul +{{- end }} + +{{/* +Generate Zuul-executor labels +*/}} +{{- define "zuul.executor.labels" }} +{{- include "zuul.common.labels" . }} +app.kubernetes.io/component: zuul-executor +{{- end }} + +{{/* +Generate Zuul-merger labels +*/}} +{{- define "zuul.merger.labels" }} +{{- include "zuul.common.labels" . }} +app.kubernetes.io/component: zuul-merger +{{- end }} + +{{/* +Generate Zuul-scheduler labels +*/}} +{{- define "zuul.scheduler.labels" }} +{{- include "zuul.common.labels" . }} +app.kubernetes.io/component: zuul-scheduler +{{- end }} + +{{/* +Generate Zuul-web labels +*/}} +{{- define "zuul.web.labels" }} +{{- include "zuul.common.labels" . }} +app.kubernetes.io/component: zuul-web +{{- end }} diff --git a/charts/zuul/templates/executor/service.yaml b/charts/zuul/templates/executor/service.yaml new file mode 100644 index 0000000..835512d --- /dev/null +++ b/charts/zuul/templates/executor/service.yaml @@ -0,0 +1,19 @@ +--- +{{ if .Values.executor.enabled }} +apiVersion: v1 +kind: Service +metadata: + namespace: {{ .Release.Namespace }} + name: {{ include "zuul.fullname" . }}-executor + labels: +{{- include "zuul.executor.labels" . | indent 4 }} +spec: + type: ClusterIP + ports: + - name: logs + port: 7900 + protocol: TCP + targetPort: logs + selector: +{{- include "zuul.executor.labels" . | indent 4 }} +{{ end }} \ No newline at end of file diff --git a/charts/zuul/templates/executor/statefulset.yaml b/charts/zuul/templates/executor/statefulset.yaml new file mode 100644 index 0000000..496f847 --- /dev/null +++ b/charts/zuul/templates/executor/statefulset.yaml @@ -0,0 +1,50 @@ +--- +{{ if .Values.executor.enabled }} +apiVersion: apps/v1 +kind: StatefulSet +metadata: + namespace: {{ .Release.Namespace }} + name: {{ include "zuul.fullname" . }}-executor + labels: +{{- include "zuul.executor.labels" . | indent 4 }} +spec: + serviceName: {{ include "zuul.fullname" . }}-executor + replicas: {{ .Values.executor.replicas }} + selector: + matchLabels: +{{- include "zuul.executor.labels" . | indent 6 }} + template: + metadata: + labels: +{{- include "zuul.executor.labels" . | indent 8 }} + annotations: + checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }} + spec: + containers: + - name: executor + image: zuul/zuul-executor:latest + args: + - /usr/local/bin/zuul-executor + - -d + ports: + - name: logs + containerPort: 7900 + volumeMounts: + - name: zuul-config + mountPath: /etc/zuul + securityContext: + privileged: true + volumes: + - name: zuul-config + secret: + secretName: {{ include "zuul.fullname" . }} + defaultMode: 256 + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} +{{ end }} \ No newline at end of file diff --git a/charts/zuul/templates/merger/deployment.yaml b/charts/zuul/templates/merger/deployment.yaml new file mode 100644 index 0000000..9250254 --- /dev/null +++ b/charts/zuul/templates/merger/deployment.yaml @@ -0,0 +1,44 @@ +--- +{{ if .Values.merger.enabled }} +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: {{ .Release.Namespace }} + name: {{ include "zuul.fullname" . }}-merger + labels: +{{- include "zuul.merger.labels" . | indent 4 }} +spec: + replicas: {{ .Values.merger.replicas }} + selector: + matchLabels: +{{- include "zuul.merger.labels" . | indent 6 }} + template: + metadata: + labels: +{{- include "zuul.merger.labels" . | indent 8 }} + annotations: + checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }} + spec: + containers: + - name: merger + image: zuul/zuul-merger:latest + args: + - /usr/local/bin/zuul-merger + - -d + volumeMounts: + - name: zuul-config + mountPath: /etc/zuul + volumes: + - name: zuul-config + secret: + secretName: {{ include "zuul.fullname" . }} + defaultMode: 256 + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} +{{ end }} \ No newline at end of file diff --git a/charts/zuul/templates/scheduler/service.yaml b/charts/zuul/templates/scheduler/service.yaml new file mode 100644 index 0000000..3972180 --- /dev/null +++ b/charts/zuul/templates/scheduler/service.yaml @@ -0,0 +1,19 @@ +--- +{{ if .Values.scheduler.enabled }} +apiVersion: v1 +kind: Service +metadata: + namespace: {{ .Release.Namespace }} + name: {{ include "zuul.fullname" . }}-gearman + labels: +{{- include "zuul.scheduler.labels" . | indent 4 }} +spec: + type: ClusterIP + ports: + - name: gearman + port: {{ .Values.scheduler.gearman.port }} + protocol: TCP + targetPort: gearman + selector: +{{- include "zuul.scheduler.labels" . | indent 4 }} +{{ end }} \ No newline at end of file diff --git a/charts/zuul/templates/scheduler/statefulset.yaml b/charts/zuul/templates/scheduler/statefulset.yaml new file mode 100644 index 0000000..0b49095 --- /dev/null +++ b/charts/zuul/templates/scheduler/statefulset.yaml @@ -0,0 +1,59 @@ +--- +{{ if .Values.scheduler.enabled }} +apiVersion: apps/v1 +kind: StatefulSet +metadata: + namespace: {{ .Release.Namespace }} + name: {{ include "zuul.fullname" . }}-scheduler + labels: +{{- include "zuul.scheduler.labels" . | indent 4 }} +spec: + replicas: 1 + serviceName: zuul-scheduler + selector: + matchLabels: +{{- include "zuul.scheduler.labels" . | indent 6 }} + template: + metadata: + labels: +{{- include "zuul.scheduler.labels" . | indent 8 }} + annotations: + checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }} + spec: + containers: + - name: launcher + image: zuul/zuul-scheduler:latest + args: + - /usr/local/bin/zuul-scheduler + - -d + ports: + - name: gearman + containerPort: {{ .Values.scheduler.gearman.port }} + volumeMounts: + - name: zuul-config + mountPath: /etc/zuul + - name: {{ include "zuul.fullname" . }}-scheduler + mountPath: /var/lib/zuul + volumes: + - name: zuul-config + secret: + secretName: {{ include "zuul.fullname" . }} + defaultMode: 256 + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} + volumeClaimTemplates: + - metadata: + name: {{ include "zuul.fullname" . }}-scheduler + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 80Gi +{{ end }} \ No newline at end of file diff --git a/charts/zuul/templates/secret.yaml b/charts/zuul/templates/secret.yaml new file mode 100644 index 0000000..95558a2 --- /dev/null +++ b/charts/zuul/templates/secret.yaml @@ -0,0 +1,37 @@ +--- +apiVersion: v1 +kind: Secret +metadata: + namespace: {{ .Release.Namespace }} + name: {{ include "zuul.fullname" . }} + labels: +{{- include "zuul.common.labels" . | indent 4 }} +stringData: + zuul.conf: | + [gearman] + server={{ include "zuul.fullname" . }}-gearman + port={{ .Values.scheduler.gearman.port }} + [zookeeper] + hosts={{ .Values.zookeeper.hosts }} + [gearman_server] + start=true + port={{ .Values.scheduler.gearman.port }} + [web] + listen_address=0.0.0.0 + root=https://{{ .Values.web.host }} + port={{ .Values.web.port }} + [scheduler] + tenant_config=/etc/zuul/main.yaml + [executor] + private_key_file={{ .Values.executor.private_key_file }} + {{ range $connection, $options := .Values.connections }} + [connection {{ $connection }}] + {{ range $key, $value := $options }} + {{ $key }} = {{ $value }} + {{ end }} + {{ end }} + main.yaml: | +{{ toYaml .Values.tenantConfig | indent 4 }} +{{ if .Values.extraFiles }} +{{ (toYaml .Values.extraFiles | indent 2) }} +{{ end }} \ No newline at end of file diff --git a/charts/zuul/templates/web/deployment.yaml b/charts/zuul/templates/web/deployment.yaml new file mode 100644 index 0000000..fdfb813 --- /dev/null +++ b/charts/zuul/templates/web/deployment.yaml @@ -0,0 +1,47 @@ +--- +{{ if .Values.web.enabled }} +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: {{ .Release.Namespace }} + name: {{ include "zuul.fullname" . }}-web + labels: +{{- include "zuul.web.labels" . | indent 4 }} +spec: + replicas: {{ .Values.web.replicas }} + selector: + matchLabels: +{{- include "zuul.web.labels" . | indent 6 }} + template: + metadata: + labels: +{{- include "zuul.web.labels" . | indent 8 }} + annotations: + checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }} + spec: + containers: + - name: web + image: zuul/zuul-web:latest + args: + - /usr/local/bin/zuul-web + - -d + ports: + - name: zuul-web + containerPort: {{ .Values.web.port }} + volumeMounts: + - name: zuul-config + mountPath: /etc/zuul + volumes: + - name: zuul-config + secret: + secretName: {{ include "zuul.fullname" . }} + defaultMode: 256 + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} +{{ end }} \ No newline at end of file diff --git a/charts/zuul/templates/web/ingress.yaml b/charts/zuul/templates/web/ingress.yaml new file mode 100644 index 0000000..a12e323 --- /dev/null +++ b/charts/zuul/templates/web/ingress.yaml @@ -0,0 +1,27 @@ +--- +{{ if and .Values.ingress.enabled .Values.web.enabled }} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + namespace: {{ .Release.Namespace }} + name: {{ include "zuul.fullname" . }}-web + labels: +{{- include "zuul.web.labels" . | indent 4 }} + annotations: + kubernetes.io/ingress.class: nginx + certmanager.k8s.io/cluster-issuer: letsencrypt-prod + nginx.ingress.kubernetes.io/ssl-redirect: "true" +spec: + rules: + - host: {{ .Values.web.host }} + http: + paths: + - backend: + serviceName: {{ include "zuul.fullname" . }}-web + servicePort: {{ .Values.web.port }} + path: / + tls: + - hosts: + - {{ .Values.web.host }} + secretName: {{ include "zuul.fullname" . }}-web-certs +{{ end }} \ No newline at end of file diff --git a/charts/zuul/templates/web/service.yaml b/charts/zuul/templates/web/service.yaml new file mode 100644 index 0000000..13a98aa --- /dev/null +++ b/charts/zuul/templates/web/service.yaml @@ -0,0 +1,19 @@ +--- +{{ if .Values.web.enabled }} +apiVersion: v1 +kind: Service +metadata: + namespace: {{ .Release.Namespace }} + name: {{ include "zuul.fullname" . }}-web + labels: +{{- include "zuul.web.labels" . | indent 4 }} +spec: + type: ClusterIP + ports: + - name: zuul-web + port: {{ .Values.web.port }} + protocol: TCP + targetPort: zuul-web + selector: +{{- include "zuul.web.labels" . | indent 4 }} +{{ end }} \ No newline at end of file diff --git a/charts/zuul/values.yaml b/charts/zuul/values.yaml new file mode 100644 index 0000000..afc76b3 --- /dev/null +++ b/charts/zuul/values.yaml @@ -0,0 +1,27 @@ +--- +zookeeper: + hosts: zookeeper + +executor: + enabled: true + replicas: 3 + +merger: + enabled: true + replicas: 3 + +scheduler: + enabled: true + gearman: + port: 4730 + +web: + enabled: true + replicas: 3 + port: 9000 + +ingress: + enabled: false + +tenantConfig: {} +extraFiles: {}