diff --git a/helm/bulldozer-bot/.helmignore b/helm/bulldozer-bot/.helmignore new file mode 100644 index 000000000..50af03172 --- /dev/null +++ b/helm/bulldozer-bot/.helmignore @@ -0,0 +1,22 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/helm/bulldozer-bot/Chart.yaml b/helm/bulldozer-bot/Chart.yaml new file mode 100644 index 000000000..9f89908ce --- /dev/null +++ b/helm/bulldozer-bot/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.4.0" +description: A Helm chart for the Palantir bulldozer bot +name: bulldozer-bot +version: 0.1.0 diff --git a/helm/bulldozer-bot/templates/NOTES.txt b/helm/bulldozer-bot/templates/NOTES.txt new file mode 100644 index 000000000..2b1a5ffa6 --- /dev/null +++ b/helm/bulldozer-bot/templates/NOTES.txt @@ -0,0 +1,21 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "bulldozer-bot.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "bulldozer-bot.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "bulldozer-bot.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "bulldozer-bot.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/helm/bulldozer-bot/templates/_helpers.tpl b/helm/bulldozer-bot/templates/_helpers.tpl new file mode 100644 index 000000000..776cbd3f8 --- /dev/null +++ b/helm/bulldozer-bot/templates/_helpers.tpl @@ -0,0 +1,53 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "bulldozer-bot.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 "bulldozer-bot.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 -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "bulldozer-bot.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{- define "bulldozer-bot.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "bulldozer-bot.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "bulldozer-bot.labels" -}} +app.kubernetes.io/name: {{ include "bulldozer-bot.name" . }} +helm.sh/chart: {{ include "bulldozer-bot.chart" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} diff --git a/helm/bulldozer-bot/templates/deployment.yaml b/helm/bulldozer-bot/templates/deployment.yaml new file mode 100644 index 000000000..37c314fc5 --- /dev/null +++ b/helm/bulldozer-bot/templates/deployment.yaml @@ -0,0 +1,62 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "bulldozer-bot.fullname" . }} + labels: +{{ include "bulldozer-bot.labels" . | indent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app.kubernetes.io/name: {{ include "bulldozer-bot.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + app.kubernetes.io/name: {{ include "bulldozer-bot.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + livenessProbe: + httpGet: + # https://github.com/kubernetes/kubernetes/issues/20555#issuecomment-326058311 + path: /api/health + port: http + readinessProbe: + httpGet: + path: /api/health + port: http + volumeMounts: + - name: bulldozer-bot-config + mountPath: /secrets + readOnly: true + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: "{{ template "bulldozer-bot.serviceAccountName" . }}" + volumes: + - name: bulldozer-bot-config + secret: + secretName: {{ .Values.config.secret_name }} diff --git a/helm/bulldozer-bot/templates/ingress.yaml b/helm/bulldozer-bot/templates/ingress.yaml new file mode 100644 index 000000000..2f020e2f0 --- /dev/null +++ b/helm/bulldozer-bot/templates/ingress.yaml @@ -0,0 +1,36 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "bulldozer-bot.fullname" . -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: +{{ include "bulldozer-bot.labels" . | indent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + backend: + serviceName: {{ $fullName }} + servicePort: http + {{- end }} + {{- end }} +{{- end }} diff --git a/helm/bulldozer-bot/templates/rbac.yaml b/helm/bulldozer-bot/templates/rbac.yaml new file mode 100644 index 000000000..09e865586 --- /dev/null +++ b/helm/bulldozer-bot/templates/rbac.yaml @@ -0,0 +1,28 @@ +{{ if .Values.rbac.create }} +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: {{ include "bulldozer-bot.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: +{{ include "bulldozer-bot.labels" . | indent 4 }} +rules: +- apiGroups: [""] + resources: [""] + verbs: [""] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ include "bulldozer-bot.fullname" . }} + labels: +{{ include "bulldozer-bot.labels" . | indent 4 }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: {{ include "bulldozer-bot.fullname" . }} +subjects: +- kind: ServiceAccount + name: {{ template "bulldozer-bot.serviceAccountName" .}} + namespace: {{ .Release.Namespace }} +{{ end }} diff --git a/helm/bulldozer-bot/templates/service.yaml b/helm/bulldozer-bot/templates/service.yaml new file mode 100644 index 000000000..ed8a7f4e9 --- /dev/null +++ b/helm/bulldozer-bot/templates/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "bulldozer-bot.fullname" . }} + labels: +{{ include "bulldozer-bot.labels" . | indent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + app.kubernetes.io/name: {{ include "bulldozer-bot.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/helm/bulldozer-bot/templates/serviceaccount.yaml b/helm/bulldozer-bot/templates/serviceaccount.yaml new file mode 100644 index 000000000..431669beb --- /dev/null +++ b/helm/bulldozer-bot/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{ if .Values.serviceAccount.create }} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "bulldozer-bot.serviceAccountName" . }} +{{- if .Values.serviceAccount.annotations }} + annotations: +{{ toYaml .Values.serviceAccount.annotations | indent 4 }} +{{ end }} + labels: +{{ include "bulldozer-bot.labels" . | indent 4 }} +{{ end }} diff --git a/helm/bulldozer-bot/templates/tests/test-connection.yaml b/helm/bulldozer-bot/templates/tests/test-connection.yaml new file mode 100644 index 000000000..829ba3bd8 --- /dev/null +++ b/helm/bulldozer-bot/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "bulldozer-bot.fullname" . }}-test-connection" + labels: +{{ include "bulldozer-bot.labels" . | indent 4 }} + annotations: + "helm.sh/hook": test-success +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "bulldozer-bot.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/helm/bulldozer-bot/values.yaml b/helm/bulldozer-bot/values.yaml new file mode 100644 index 000000000..0912a526b --- /dev/null +++ b/helm/bulldozer-bot/values.yaml @@ -0,0 +1,61 @@ +# Default values for bulldozer-bot. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: palantirtechnologies/bulldozer + tag: 1.4.0 + pullPolicy: IfNotPresent + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +config: + secret_name: "" + +service: + enabled: false + type: ClusterIP + port: 80 + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: [] + + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +rbac: + create: true + +serviceAccount: + create: true + name: ""