From 65895e77adacefc6e1ec2896090679beced454b8 Mon Sep 17 00:00:00 2001 From: Tom Schoener Date: Thu, 7 Apr 2022 13:15:01 +0200 Subject: [PATCH] setup repository + add group-challenge repo --- .github/workflows/release-chart.yml | 27 +++++ README.md | 19 ++- charts/group-challenge/.gitignore | 1 + charts/group-challenge/.helmignore | 23 ++++ charts/group-challenge/Chart.lock | 6 + charts/group-challenge/Chart.yaml | 11 ++ charts/group-challenge/README.md | 3 + charts/group-challenge/templates/_helpers.tpl | 62 ++++++++++ charts/group-challenge/templates/config.yaml | 8 ++ .../group-challenge/templates/deployment.yaml | 114 ++++++++++++++++++ charts/group-challenge/templates/ingress.yaml | 41 +++++++ charts/group-challenge/templates/service.yaml | 21 ++++ .../templates/serviceaccount.yaml | 12 ++ .../templates/servicemonitor.yaml | 18 +++ charts/group-challenge/values.yaml | 112 +++++++++++++++++ 15 files changed, 477 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release-chart.yml create mode 100644 charts/group-challenge/.gitignore create mode 100644 charts/group-challenge/.helmignore create mode 100644 charts/group-challenge/Chart.lock create mode 100644 charts/group-challenge/Chart.yaml create mode 100644 charts/group-challenge/README.md create mode 100644 charts/group-challenge/templates/_helpers.tpl create mode 100644 charts/group-challenge/templates/config.yaml create mode 100644 charts/group-challenge/templates/deployment.yaml create mode 100644 charts/group-challenge/templates/ingress.yaml create mode 100644 charts/group-challenge/templates/service.yaml create mode 100644 charts/group-challenge/templates/serviceaccount.yaml create mode 100644 charts/group-challenge/templates/servicemonitor.yaml create mode 100644 charts/group-challenge/values.yaml diff --git a/.github/workflows/release-chart.yml b/.github/workflows/release-chart.yml new file mode 100644 index 0000000..e91d999 --- /dev/null +++ b/.github/workflows/release-chart.yml @@ -0,0 +1,27 @@ +name: Release Charts + +on: + push: + branches: + - main + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + - name: Helm Deps + run: | + helm repo add bitnami https://charts.bitnami.com/bitnami + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.4.0 + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file diff --git a/README.md b/README.md index 8fcbb14..5853034 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,19 @@ # helm-charts -public helm charts supported by subshell + +Public helm charts supported by subshell. + +## Add Repo + +The following command allows you to download and install all the charts from this repository: + +```sh +helm repo add subshell-public https://subshell.github.io/helm-charts +``` + +## Development + +All charts should be located in the `charts` directory. On every push to the +main branch, a release of the helm chart is triggered automatically if the +`Chart.yaml` file contains a new version. + +This git repository uses [Github Pages](https://helm.sh/docs/topics/chart_repository/#github-pages-example) to host the helm repository. diff --git a/charts/group-challenge/.gitignore b/charts/group-challenge/.gitignore new file mode 100644 index 0000000..88301c0 --- /dev/null +++ b/charts/group-challenge/.gitignore @@ -0,0 +1 @@ +charts/* \ No newline at end of file diff --git a/charts/group-challenge/.helmignore b/charts/group-challenge/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/group-challenge/.helmignore @@ -0,0 +1,23 @@ +# 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 +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/group-challenge/Chart.lock b/charts/group-challenge/Chart.lock new file mode 100644 index 0000000..1c2354d --- /dev/null +++ b/charts/group-challenge/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: postgresql + repository: https://charts.bitnami.com/bitnami + version: 11.1.17 +digest: sha256:38055223b7aec2efe1354de3996b66f39ab6e6104add65cc9bcf67ad6055ab13 +generated: "2022-04-07T13:15:54.883027+02:00" diff --git a/charts/group-challenge/Chart.yaml b/charts/group-challenge/Chart.yaml new file mode 100644 index 0000000..2ee2347 --- /dev/null +++ b/charts/group-challenge/Chart.yaml @@ -0,0 +1,11 @@ +apiVersion: v2 +name: group-challenge +description: Group challenge helm chart +type: application +version: 1.0.0 +appVersion: "1.0.0" +dependencies: + - name: postgresql + version: 11.1.17 + repository: https://charts.bitnami.com/bitnami + condition: postgresql.enabled \ No newline at end of file diff --git a/charts/group-challenge/README.md b/charts/group-challenge/README.md new file mode 100644 index 0000000..f5edd2c --- /dev/null +++ b/charts/group-challenge/README.md @@ -0,0 +1,3 @@ +# Group Challenge + +Helm Chart for the [Group Challene App](https://github.com/subshell/group-challenge). diff --git a/charts/group-challenge/templates/_helpers.tpl b/charts/group-challenge/templates/_helpers.tpl new file mode 100644 index 0000000..9d84e51 --- /dev/null +++ b/charts/group-challenge/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "group-challenge.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 "group-challenge.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 "group-challenge.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "group-challenge.labels" -}} +helm.sh/chart: {{ include "group-challenge.chart" . }} +{{ include "group-challenge.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "group-challenge.selectorLabels" -}} +app.kubernetes.io/name: {{ include "group-challenge.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "group-challenge.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "group-challenge.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/group-challenge/templates/config.yaml b/charts/group-challenge/templates/config.yaml new file mode 100644 index 0000000..e37ed46 --- /dev/null +++ b/charts/group-challenge/templates/config.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "group-challenge.fullname" . }} + labels: + {{- include "group-challenge.labels" . | nindent 4 }} +data: + config.yaml: |- {{ toYaml (required "A valid config.yaml config is required (nested in the value .Values.groupChallenge.config)!" .Values.groupChallenge.config) | nindent 4 }} \ No newline at end of file diff --git a/charts/group-challenge/templates/deployment.yaml b/charts/group-challenge/templates/deployment.yaml new file mode 100644 index 0000000..49dc837 --- /dev/null +++ b/charts/group-challenge/templates/deployment.yaml @@ -0,0 +1,114 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "group-challenge.fullname" . }} + labels: + {{- include "group-challenge.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "group-challenge.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "group-challenge.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "group-challenge.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + restartPolicy: Always + containers: + {{ if .Values.imgProxy.enabled -}} + - name: img-proxy + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.imgProxy.image.repository }}:{{ .Values.imgProxy.image.tag }}" + imagePullPolicy: {{ .Values.imgProxy.image.pullPolicy }} + volumeMounts: + - name: group-challenge-cache + mountPath: "/tmp/group-challenge-cache" + env: + - name: IMGPROXY_LOCAL_FILESYSTEM_ROOT + value: "/tmp/group-challenge-cache" + - name: IMGPROXY_BIND + value: ":8081" + - name: IMGPROXY_PROMETHEUS_BIND + value: ":8082" + - name: IMGPROXY_MAX_SRC_RESOLUTION + value: "25" + {{ if .Values.imgProxy.env -}} + {{- toYaml .Values.imgProxy.env | nindent 12 }} + {{- end }} + ports: + - name: http-ip + containerPort: 8081 + protocol: TCP + - name: http-ipp + containerPort: 8082 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http-ip + readinessProbe: + httpGet: + path: / + port: http-ip + resources: + {{- toYaml .Values.imgProxy.resources | nindent 12 }} + {{- end }} + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + volumeMounts: + - name: config + mountPath: "/app/config" + - name: group-challenge-cache + mountPath: "/tmp/group-challenge-cache" + env: + {{ if .Values.groupChallenge.env -}} + {{- toYaml .Values.groupChallenge.env | nindent 12 }} + {{- end }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumes: + - name: config + configMap: + name: {{ include "group-challenge.fullname" . }} + - name: group-challenge-cache + emptyDir: {} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/group-challenge/templates/ingress.yaml b/charts/group-challenge/templates/ingress.yaml new file mode 100644 index 0000000..00fdd66 --- /dev/null +++ b/charts/group-challenge/templates/ingress.yaml @@ -0,0 +1,41 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "group-challenge.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "group-challenge.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.ingress.ingressClassName }} + ingressClassName: {{ .Values.ingress.ingressClassName }} + {{- end -}} + {{- 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: + - path: / + pathType: Prefix + backend: + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- end }} + {{- end }} diff --git a/charts/group-challenge/templates/service.yaml b/charts/group-challenge/templates/service.yaml new file mode 100644 index 0000000..1a88e6e --- /dev/null +++ b/charts/group-challenge/templates/service.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "group-challenge.fullname" . }} + labels: + {{- include "group-challenge.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + {{ if .Values.imgProxy.enabled -}} + - port: 8082 + targetPort: http-ipp + protocol: TCP + name: http-ipp + {{- end }} + selector: + {{- include "group-challenge.selectorLabels" . | nindent 4 }} diff --git a/charts/group-challenge/templates/serviceaccount.yaml b/charts/group-challenge/templates/serviceaccount.yaml new file mode 100644 index 0000000..55b9f0e --- /dev/null +++ b/charts/group-challenge/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "group-challenge.serviceAccountName" . }} + labels: + {{- include "group-challenge.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/group-challenge/templates/servicemonitor.yaml b/charts/group-challenge/templates/servicemonitor.yaml new file mode 100644 index 0000000..76170b6 --- /dev/null +++ b/charts/group-challenge/templates/servicemonitor.yaml @@ -0,0 +1,18 @@ +{{- if .Values.serviceMonitor.enabled -}} +{{- $fullName := include "group-challenge.fullname" . -}} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ $fullName }} + labels: {{- include "group-challenge.labels" . | nindent 8 }} +spec: + selector: + matchLabels: {{- include "group-challenge.selectorLabels" . | nindent 12 }} + endpoints: + - interval: {{ .Values.serviceMonitor.interval }} + port: http + path: {{ .Values.serviceMonitor.path }} + - interval: {{ .Values.serviceMonitor.interval }} + port: http-ipp + path: / +{{- end }} diff --git a/charts/group-challenge/values.yaml b/charts/group-challenge/values.yaml new file mode 100644 index 0000000..edfc389 --- /dev/null +++ b/charts/group-challenge/values.yaml @@ -0,0 +1,112 @@ +replicaCount: 1 + +image: + repository: ghcr.io/subshell/group-challenge + pullPolicy: Always + # Overrides the image tag whose default is the chart appVersion. + tag: "latest" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: false + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: + {} + # fsGroup: 2000 + +securityContext: + {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + annotations: + {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + # - host: chart-example.local + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: + requests: + cpu: 100m + memory: 512Mi + limits: + cpu: 500m + memory: 1024Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +groupChallenge: + # k8s env variables + env: [] + # config for the config.yaml file + config: + server: + port: 8080 + staticFilesDir: "./static" + db: + user: postgres + password: postgres + database: group_challenge + host: "gc-postgres:5432" + poolSize: 50 + logQueries: false + imgProxy: + enabled: true + url: "http://localhost:8081" + sharedLocalCacheDir: "/tmp/group-challenge-cache" + thumbnailQuality: 90 + fullSizeQuality: 75 + maxFullWidth: 1280 + maxFullHeight: 0 + +serviceMonitor: + enabled: false + interval: 5s + path: /metrics + +imgProxy: + enabled: true + image: + repository: darthsim/imgproxy + pullPolicy: IfNotPresent + tag: "v3.3.3" + env: [] + resources: {} + +postgresql: + enabled: true + fullnameOverride: gc-postgres + auth: + database: "group_challenge" + enablePostgresUser: true + postgresPassword: postgres