diff --git a/status/.helmignore b/status/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/status/.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/status/Chart.lock b/status/Chart.lock new file mode 100644 index 0000000..62b5eb0 --- /dev/null +++ b/status/Chart.lock @@ -0,0 +1,9 @@ +dependencies: +- name: postgresql + repository: https://charts.bitnami.com/bitnami + version: 11.6.20 +- name: redis + repository: https://charts.bitnami.com/bitnami + version: 17.3.5 +digest: sha256:c7f8c3ea9009ead238c633b6be0be75fefd02832a3700d7b97db9a606dcc92ef +generated: "2022-10-18T16:21:29.614938307+02:00" diff --git a/status/Chart.yaml b/status/Chart.yaml new file mode 100644 index 0000000..499b549 --- /dev/null +++ b/status/Chart.yaml @@ -0,0 +1,33 @@ +apiVersion: v2 +name: status +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.3.2 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +appVersion: v2.5.3 + +dependencies: +- name: postgresql + repository: https://charts.bitnami.com/bitnami + version: 11.6.20 + condition: postgresql.enabled +- name: redis + repository: https://charts.bitnami.com/bitnami + version: 17.3.5 + condition: redis.enabled \ No newline at end of file diff --git a/status/README.md b/status/README.md new file mode 100644 index 0000000..e5ae6f1 --- /dev/null +++ b/status/README.md @@ -0,0 +1,79 @@ +# status + +![Version: 0.3.2](https://img.shields.io/badge/Version-0.3.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v2.5.3](https://img.shields.io/badge/AppVersion-v2.5.3-informational?style=flat-square) + +A Helm chart for Kubernetes + +## How to install this chart + +```console +helm install chart_name ./status +``` + +To install the chart with the release name `my-release`: + +```console +helm install chart_name ./status +``` + +To install with some set values: + +```console +helm install chart_name ./status --set values_key1=value1 --set values_key2=value2 +``` + +To install with custom values file: + +```console +helm install chart_name ./status -f values.yaml +``` + +## Requirements + +| Repository | Name | Version | +|------------|------|---------| +| https://charts.bitnami.com/bitnami | postgresql | 11.6.20 | +| https://charts.bitnami.com/bitnami | redis | 17.3.5 | + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| affinity | object | `{}` | | +| autoscaling.enabled | bool | `false` | Enable autoscaling for status service | +| autoscaling.maxReplicas | int | `3` | Maximum number of replicas for status service | +| autoscaling.minReplicas | int | `1` | Minimal number of replicas for status service | +| autoscaling.targetCPUUtilizationPercentage | int | `80` | Target CPU utilization for horizontal pod autoscaler | +| env.private | string | `nil` | Private environment variables which are stores in a kubernetes secret | +| env.public | object | `{"APP_DEBUG":false,"APP_ENV":"production","APP_LOG":"errorlog","APP_NAME":"statuspage","APP_TIMEZONE":"UTC","CACHET_BEACON":false,"CACHET_EMOJI":false,"CACHET_INTERNET_LOOKUPS":"false","CACHE_DRIVER":"redis","DB_DRIVER":"pgsql","DOCKER":true,"MAIL_ADDRESS":"","MAIL_DRIVER":"log","MAIL_ENCRYPTION":"tls","MAIL_HOST":"","MAIL_NAME":"","MAIL_PORT":25,"QUEUE_DRIVER":"redis","SESSION_DRIVER":"redis"}` | Default settings for cachet / status-service. See https://docs.cachethq.io/docs/installing-cachet for more information | +| existingSecret | string | `""` | Use existing secret for Cachet settings | +| extraLabels | object | `{}` | | +| fullnameOverride | string | `""` | | +| image.pullPolicy | string | `"IfNotPresent"` | | +| image.repository | string | `"ghcr.io/dbildungsplattform/cachet"` | Image to use for deploying | +| imagePullSecrets | list | `[]` | | +| ingress.annotations | object | `{}` | Additional annotations for the Ingress resource. To enable certificate autogeneration, place here your cert-manager annotations. | +| ingress.enabled | bool | `false` | Enable ingress controller resource | +| ingress.hosts[0].host | string | `"chart-example.local"` | | +| ingress.hosts[0].paths[0].path | string | `"/"` | | +| ingress.hosts[0].paths[0].pathType | string | `"Prefix"` | | +| ingress.tls | list | `[]` | Enable TLS configuration for the hostnames defined at ingress.hosts parameter | +| nameOverride | string | `""` | | +| nodeSelector | object | `{}` | | +| podAnnotations | object | `{}` | The annotations to be applied to instances of the status-service pod | +| podSecurityContext | object | `{}` | Settings for security context of the pod | +| postgresql | object | `{"auth":{"database":"status","existingSecret":"","password":"status","postgresPassword":"status","secretKeys":{"adminPasswordKey":"","userPasswordKey":""},"username":"status"},"enabled":true,"primary":{"persistence":{"enabled":true,"size":"10Gi"}},"service":{"ports":{"postgresql":5432}}}` | Postgresql settings. See https://github.com/bitnami/charts/tree/master/bitnami/postgresql fro details | +| redis | object | `{"architecture":"standalone","enabled":true}` | Redis settings. See https://github.com/bitnami/charts/tree/master/bitnami/redis fro details | +| replicaCount | int | `1` | | +| resources.limits | object | `{"cpu":"1000m","memory":"1Gi"}` | The resources limits for the container | +| resources.requests | object | `{"cpu":"100m","memory":"128Mi"}` | The requested resources for the container | +| securityContext.runAsUser | int | `1001` | | +| seedData | object | `{}` | | +| service.port | int | `80` | Status service port | +| service.type | string | `"ClusterIP"` | Kubernetes Service type | +| serviceAccount.annotations | object | `{}` | Annotations to add to the service account | +| serviceAccount.create | bool | `false` | Specifies whether a service account should be created | +| serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template | +| test.enabled | bool | `true` | | +| tolerations | list | `[]` | | + diff --git a/status/files/LICENSE b/status/files/LICENSE new file mode 100644 index 0000000..43fbc47 --- /dev/null +++ b/status/files/LICENSE @@ -0,0 +1,9 @@ +The MIT License (MIT) + +Copyright (c) James Brooks + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/status/files/SeederCommand.php b/status/files/SeederCommand.php new file mode 100644 index 0000000..e8709b9 --- /dev/null +++ b/status/files/SeederCommand.php @@ -0,0 +1,233 @@ +settings = $settings; + $this->componentGroups = []; + } + + /** + * Execute the console command. + * + * @return void + */ + public function handle() + { + $seed_data_path = __DIR__ . '/../../seedData.json'; + if(is_file($seed_data_path)) { + $this->info('Seed data found'); + $this->seedData = json_decode(file_get_contents($seed_data_path), true); + } else{ + $this->error('Seed data not found'); + } + $this->info('Starting setup of Cachet'); + $this->seedUsers(); + $this->seedIncidentTemplates(); + $this->seedComponentGroups(); + $this->seedComponents(); + $this->seedSettings(); + $this->info('Setup ran successfully!'); + } + + + /** + * Seed the component groups table. + * + * @return void + */ + protected function seedIncidentTemplates() + { + if(isset($this->seedData["enableSeedData"]) && $this->seedData["enableSeedData"]=="true"){ + $this->info('Updating all incident templates'); + if(isset($this->seedData["incidentTemplates"])){ + foreach ($this->seedData["incidentTemplates"] as $template) { + IncidentTemplate::updateOrCreate(['name' => $template['name']], + [ + 'name' => $template['name'], + 'template' => $template['template'] + ]); + } + } + } + } + + /** + * Seed the component groups table. + * + * @return void + */ + protected function seedComponentGroups() + { + if(isset($this->seedData["enableSeedData"]) && $this->seedData["enableSeedData"]=="true"){ + $this->info('Updating all component groups'); + if(isset($this->seedData["componentGroups"])){ + $index=1; + foreach ($this->seedData["componentGroups"] as $group) { + ComponentGroup::updateOrCreate(['name' => $group['name']], + [ + 'name' => $group['name'], + 'order' => $index, + 'collapsed' => 0, + 'visible' => ComponentGroup::VISIBLE_GUEST, + ]); + $this->componentGroups[$group['name']] = $index; + $index++; + } + } + } + } + + /** + * Seed the components table. + * + * @return void + */ + protected function seedComponents() + { + if(isset($this->seedData["enableSeedData"]) && $this->seedData["enableSeedData"]=="true"){ + $this->info('Updating all components'); + if(isset($this->seedData["components"])){ + foreach ($this->seedData["components"] as $component) { + Component::updateOrCreate(['name' => $component['name']], + [ + 'name' => $component['name'], + 'description' => $component['description'], + 'status' => 1, + 'order' => 0, + 'group_id' => $this->componentGroups[$component["componentGroup"]], + 'link' => $component['link'] + ]); + } + } + } + } + + + /** + * Seed the settings table. + * + * @return void + */ + protected function seedSettings() + { + $this->info('Updating all settings'); + if(isset($this->seedData["settings"])){ + foreach ($this->seedData["settings"] as $setting_key => $setting_value) { + $this->settings->set($setting_key, $setting_value); + } + } + } + + + /** + * Seed the users table. + * + * @return void + */ + protected function seedUsers() + { + if(isset($this->seedData["enableSeedData"]) && $this->seedData["enableSeedData"]=="true"){ + $this->info('Updating all users'); + if(isset($this->seedData["users"])){ + foreach ($this->seedData["users"] as $user) { + $level= User::LEVEL_USER; + if(isset($user['level']) && $user['level']=='admin'){ + $level= User::LEVEL_ADMIN; + } + $password = env($user['password_env'], Str::random(20)); + $api_key = env($user['api_key_env'], Str::random(20)); + try{ + User::updateOrCreate(['username' => $user['username']], + [ + 'username' => $user['username'], + 'email' => $user['email'], + 'level' => $level, + 'password' => $password, + 'api_key' => $api_key + ]); + } catch(ValidationException $e){ + $this->error('Validation error: ' . $e->getMessage()); + $this->error('User data: '. $user); + } + } + } + } + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return []; + } +} \ No newline at end of file diff --git a/status/templates/NOTES.txt b/status/templates/NOTES.txt new file mode 100644 index 0000000..f162279 --- /dev/null +++ b/status/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 "status.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 "status.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "status.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + 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 "status.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 --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/status/templates/_helpers.tpl b/status/templates/_helpers.tpl new file mode 100644 index 0000000..50a5ed4 --- /dev/null +++ b/status/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "status.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 "status.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 "status.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "status.labels" -}} +helm.sh/chart: {{ include "status.chart" . }} +{{ include "status.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "status.selectorLabels" -}} +app.kubernetes.io/name: {{ include "status.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "status.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "status.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/status/templates/configmap-files.yaml b/status/templates/configmap-files.yaml new file mode 100644 index 0000000..0523159 --- /dev/null +++ b/status/templates/configmap-files.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "status.fullname" . }}-files + labels: +{{ include "status.labels" . | indent 4 }} +data: + SeederCommand.php: |- +{{ .Files.Get "files/SeederCommand.php" | indent 4 }} + seedData.json: |- +{{ toPrettyJson .Values.seedData | indent 4 }} \ No newline at end of file diff --git a/status/templates/configmap.yaml b/status/templates/configmap.yaml new file mode 100644 index 0000000..bf601a9 --- /dev/null +++ b/status/templates/configmap.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "status.fullname" . }} + labels: +{{ include "status.labels" . | indent 4 }} +data: + # database + DB_HOST: {{ include "status.fullname" . }}-postgresql + DB_DATABASE: {{ .Values.postgresql.auth.database }} + DB_USERNAME: {{ .Values.postgresql.auth.username }} + DB_PORT: {{ .Values.postgresql.service.ports.postgresql | quote }} + APP_ENV: {{ default "production" .Values.env.public.APP_ENV | quote }} + REDIS_HOST: {{ include "status.fullname" . }}-redis-master +{{- with (first .Values.ingress.hosts) }} + APP_URL: {{ .host }} +{{- end }} + {{- range $key, $value := .Values.env.public }} + {{ $key }}: {{ $value | quote }} + {{- end }} \ No newline at end of file diff --git a/status/templates/deployment.yaml b/status/templates/deployment.yaml new file mode 100644 index 0000000..0004863 --- /dev/null +++ b/status/templates/deployment.yaml @@ -0,0 +1,117 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "status.fullname" . }} + labels: + {{- include "status.labels" . | nindent 4 }} +spec: +{{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} +{{- end }} + selector: + matchLabels: + {{- include "status.selectorLabels" . | nindent 6 }} + template: + metadata: + annotations: + checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} + checksum/config-files: {{ include (print $.Template.BasePath "/configmap-files.yaml") . | sha256sum }} + checksum/seedercommand: {{ .Files.Get "files/SeederCommand.php" | sha256sum }} + checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }} + {{- with .Values.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "status.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "status.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + lifecycle: + postStart: + exec: + command: + - sh + - -c + - sed 's,DemoSeederCommand,SeederCommand,g' -i /var/www/html/app/Console/Kernel.php &> /proc/1/fd/1 && php artisan cachet:seeder --no-interaction &> /proc/1/fd/1 + ports: + - name: http + containerPort: 8000 + protocol: TCP + livenessProbe: + httpGet: + path: /api/v1/ping + port: http + timeoutSeconds: 10 + periodSeconds: 10 + successThreshold: 1 + failureThreshold: 3 + readinessProbe: + httpGet: + path: /api/v1/ping + port: http + timeoutSeconds: 10 + periodSeconds: 10 + successThreshold: 1 + failureThreshold: 3 +# For retrieving the db password for postgresql a separate entry is needed to reuse the common secret + env: + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + {{- if .Values.postgresql.auth.existingSecret }} + name: {{ .Values.postgresql.auth.existingSecret }} + {{- else }} + name: {{ include "status.fullname" . }}-postgresql + {{- end }} + key: postgresql-password + envFrom: + - configMapRef: + name: {{ include "status.fullname" . }} + {{- if .Values.existingSecret }} + - secretRef: + name: {{ .Values.existingSecret }} + {{- else }} + - secretRef: + name: {{ include "status.fullname" . }} + {{- end }} + volumeMounts: + - name: {{ include "status.fullname" . }}-files + mountPath: /var/www/html/app/Console/Commands/SeederCommand.php + subPath: SeederCommand.php + - name: {{ include "status.fullname" . }}-files + mountPath: /var/www/html/app/seedData.json + subPath: seedData.json + 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 }} + volumes: + - name: {{ include "status.fullname" . }}-files + configMap: + name: {{ include "status.fullname" . }}-files + items: + - key: SeederCommand.php + path: SeederCommand.php + - key: seedData.json + path: seedData.json \ No newline at end of file diff --git a/status/templates/hpa.yaml b/status/templates/hpa.yaml new file mode 100644 index 0000000..14165cc --- /dev/null +++ b/status/templates/hpa.yaml @@ -0,0 +1,34 @@ +{{- if .Values.autoscaling.enabled }} +{{- if semverCompare ">=1.22" .Capabilities.KubeVersion.GitVersion }} +apiVersion: autoscaling/v2 +{{- else -}} +apiVersion: autoscaling/v2beta1 +{{- end }} +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "status.fullname" . }} + labels: + {{- include "status.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "status.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/status/templates/ingress.yaml b/status/templates/ingress.yaml new file mode 100644 index 0000000..9e6e48b --- /dev/null +++ b/status/templates/ingress.yaml @@ -0,0 +1,44 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "status.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "status.labels" . | nindent 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: {{ .path }} + pathType: {{ .pathType }} + backend: + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} diff --git a/status/templates/secret.yaml b/status/templates/secret.yaml new file mode 100644 index 0000000..c83052b --- /dev/null +++ b/status/templates/secret.yaml @@ -0,0 +1,13 @@ +{{- if not .Values.existingSecret }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "status.fullname" . }} + labels: +{{ include "status.labels" . | indent 4 }} +data: +{{ range $key, $value := .Values.env.private }} + {{ $key }}: {{ $value | b64enc }} +{{- end -}} +{{- end -}} + diff --git a/status/templates/service.yaml b/status/templates/service.yaml new file mode 100644 index 0000000..d77857b --- /dev/null +++ b/status/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "status.fullname" . }} + labels: + {{- include "status.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "status.selectorLabels" . | nindent 4 }} diff --git a/status/templates/serviceaccount.yaml b/status/templates/serviceaccount.yaml new file mode 100644 index 0000000..bf96fbc --- /dev/null +++ b/status/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "status.serviceAccountName" . }} + labels: + {{- include "status.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/status/templates/tests/test-connection.yaml b/status/templates/tests/test-connection.yaml new file mode 100644 index 0000000..7a572ed --- /dev/null +++ b/status/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "status.fullname" . }}-test-connection" + labels: + {{- include "status.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test-success +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "status.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/status/values.yaml b/status/values.yaml new file mode 100644 index 0000000..7f24e2d --- /dev/null +++ b/status/values.yaml @@ -0,0 +1,147 @@ + +replicaCount: 1 + +image: + # -- Image to use for deploying + repository: ghcr.io/dbildungsplattform/cachet + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + # tag: "" + +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: "" +# -- The annotations to be applied to instances of the status-service pod +podAnnotations: {} +# -- Settings for security context of the pod +podSecurityContext: {} + # fsGroup: 2000 +# -- Settings for security context of the container +securityContext: + runAsUser: 1001 + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true +service: + # -- Kubernetes Service type + type: ClusterIP + # -- Status service port + port: 80 + +ingress: + # -- Enable ingress controller resource + enabled: false + # -- Additional annotations for the Ingress resource. To enable certificate autogeneration, place here your cert-manager annotations. + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + # -- The list of hostnames to be covered with this ingress record. + hosts: + - host: chart-example.local + paths: + - path: / + pathType: Prefix + # -- Enable TLS configuration for the hostnames defined at ingress.hosts parameter + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: + # -- The resources limits for the container + limits: + cpu: 1000m + memory: 1Gi + # -- The requested resources for the container + requests: + cpu: 100m + memory: 128Mi + +autoscaling: + # -- Enable autoscaling for status service + enabled: false + # -- Minimal number of replicas for status service + minReplicas: 1 + # -- Maximum number of replicas for status service + maxReplicas: 3 + # -- Target CPU utilization for horizontal pod autoscaler + targetCPUUtilizationPercentage: 80 +# -- Postgresql settings. See https://github.com/bitnami/charts/tree/master/bitnami/postgresql fro details +postgresql: + enabled: true + auth: + username: "status" + postgresPassword: "status" + password: "status" + database: "status" + existingSecret: "" + secretKeys: + adminPasswordKey: "" + userPasswordKey: "" + service: + ports: + postgresql: 5432 + primary: + persistence: + enabled: true + size: 10Gi + +# -- Redis settings. See https://github.com/bitnami/charts/tree/master/bitnami/redis fro details +redis: + enabled: true + architecture: standalone + +env: + # -- Default settings for cachet / status-service. See https://docs.cachethq.io/docs/installing-cachet for more information + public: + # Application environments + APP_NAME: "statuspage" + APP_ENV: "production" + APP_TIMEZONE: "UTC" + CACHET_INTERNET_LOOKUPS: "false" + APP_DEBUG: false + APP_LOG: errorlog + DB_DRIVER: pgsql + DOCKER: true + CACHE_DRIVER: redis + SESSION_DRIVER: redis + QUEUE_DRIVER: redis + CACHET_EMOJI: false + CACHET_BEACON: false + # Email configuration: https://docs.cachethq.io/docs/configuring-mail + MAIL_DRIVER: log + MAIL_HOST: "" + MAIL_ADDRESS: "" + MAIL_PORT: 25 + MAIL_NAME: "" + MAIL_ENCRYPTION: tls + + # -- Private environment variables which are stores in a kubernetes secret + private: + # env.private.APP_KEY --App key for Cachet. Generate with echo "base64:$(openssl rand -base64 32)" +# -- Use existing secret for Cachet settings +existingSecret: "" + +test: + enabled: true + +extraLabels: {} + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +seedData: {} \ No newline at end of file