From 4a2fa6280d0f54eda917aba39235b6e2aefad708 Mon Sep 17 00:00:00 2001 From: Kjeld Schouten-Lebbing Date: Thu, 11 Nov 2021 21:58:55 +0100 Subject: [PATCH] feat(memcached): add memcached App (#1307) --- charts/incubator/memcached/.helmignore | 24 ++ charts/incubator/memcached/Chart.yaml | 31 ++ charts/incubator/memcached/questions.yaml | 270 ++++++++++++++++++ .../templates/backup-postgres-config.yaml | 15 + .../incubator/memcached/templates/common.yaml | 2 + .../incubator/memcached/templates/secret.yaml | 13 + .../upgrade-backup-postgres-hook.yaml | 56 ++++ charts/incubator/memcached/values.yaml | 11 + 8 files changed, 422 insertions(+) create mode 100644 charts/incubator/memcached/.helmignore create mode 100644 charts/incubator/memcached/Chart.yaml create mode 100644 charts/incubator/memcached/questions.yaml create mode 100644 charts/incubator/memcached/templates/backup-postgres-config.yaml create mode 100644 charts/incubator/memcached/templates/common.yaml create mode 100644 charts/incubator/memcached/templates/secret.yaml create mode 100644 charts/incubator/memcached/templates/upgrade-backup-postgres-hook.yaml create mode 100644 charts/incubator/memcached/values.yaml diff --git a/charts/incubator/memcached/.helmignore b/charts/incubator/memcached/.helmignore new file mode 100644 index 00000000000..e559de0a012 --- /dev/null +++ b/charts/incubator/memcached/.helmignore @@ -0,0 +1,24 @@ +# 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/ +# OWNERS file for Kubernetes +OWNERS diff --git a/charts/incubator/memcached/Chart.yaml b/charts/incubator/memcached/Chart.yaml new file mode 100644 index 00000000000..20e28111722 --- /dev/null +++ b/charts/incubator/memcached/Chart.yaml @@ -0,0 +1,31 @@ +apiVersion: v2 +appVersion: "14.0.0" +dependencies: +- name: common + repository: https://truecharts.org + version: 8.5.4 +deprecated: false +description: Memcached is a memory-backed database caching solution +home: https://github.com/truecharts/apps/tree/master/stable/memcached +icon: https://bitnami.com/assets/stacks/memcached/img/memcached-stack-220x234.png +keywords: +- memcached +- database +- cache +kubeVersion: '>=1.16.0-0' +maintainers: +- email: info@truecharts.org + name: TrueCharts + url: truecharts.org +name: memcached +sources: + - https://github.com/bitnami/bitnami-docker-memcached + - http://memcached.org/ +type: application +version: 0.0.1 +annotations: + truecharts.org/catagories: | + - database + - cache + truecharts.org/SCALE-support: "true" + truecharts.org/grade: U diff --git a/charts/incubator/memcached/questions.yaml b/charts/incubator/memcached/questions.yaml new file mode 100644 index 00000000000..08b0a747fdd --- /dev/null +++ b/charts/incubator/memcached/questions.yaml @@ -0,0 +1,270 @@ +# Include{groups} +questions: + - variable: portal + group: "Container Image" + label: "Configure Portal Button" + schema: + type: dict + hidden: true + attrs: + - variable: enabled + label: "Enable" + description: "enable the portal button" + schema: + hidden: true + editable: false + type: boolean + default: false +# Include{global} + - variable: controller + group: "Controller" + label: "" + schema: + type: dict + attrs: + - variable: advanced + label: "Show Advanced Controller Settings" + schema: + type: boolean + default: false + show_subquestions_if: true + subquestions: + - variable: type + description: "Please specify type of workload to deploy" + label: "(Advanced) Controller Type" + schema: + type: string + default: "deployment" + required: true + enum: + - value: "deployment" + description: "Deployment" + - value: "statefulset" + description: "Statefulset" + - value: "daemonset" + description: "Daemonset" + - variable: replicas + description: "Number of desired pod replicas" + label: "Desired Replicas" + schema: + type: int + default: 1 + required: true + - variable: strategy + description: "Please specify type of workload to deploy" + label: "(Advanced) Update Strategy" + schema: + type: string + default: "Recreate" + required: true + enum: + - value: "Recreate" + description: "Recreate: Kill existing pods before creating new ones" + - value: "RollingUpdate" + description: "RollingUpdate: Create new pods and then kill old ones" + - value: "OnDelete" + description: "(Legacy) OnDelete: ignore .spec.template changes" +# Include{controllerExpert} + + - variable: env + group: "Container Configuration" + label: "Image Environment" + schema: + type: dict + attrs: +# Include{fixedEnv} + +# Include{containerConfig} + + - variable: postgresqlDatabase + group: "App Configuration" + label: "Database Name" + schema: + type: string + default: "mydatabase" + required: true + - variable: postgresqlUsername + group: "App Configuration" + label: "Database User" + schema: + type: string + default: "mydatabaseuser" + required: true + - variable: postgresqlPassword + group: "App Configuration" + label: "Database Password" + schema: + type: string + default: "" + required: true + + - variable: service + group: "Networking and Services" + label: "Configure Service(s)" + schema: + type: dict + attrs: + - variable: main + label: "Main Service" + description: "The Primary service on which the healthcheck runs, often the webUI" + schema: + type: dict + attrs: +# Include{serviceSelector} + - variable: main + label: "Main Service Port Configuration" + schema: + type: dict + attrs: + - variable: advanced + label: "Show Advanced settings" + schema: + type: boolean + default: false + show_subquestions_if: true + subquestions: + - variable: protocol + label: "Port Type" + schema: + type: string + default: "TCP" + enum: + - value: HTTP + description: "HTTP" + - value: "HTTPS" + description: "HTTPS" + - value: TCP + description: "TCP" + - value: "UDP" + description: "UDP" + - variable: nodePort + label: "Node Port (Optional)" + description: "This port gets exposed to the node. Only considered when service type is NodePort, Simple or LoadBalancer" + schema: + type: int + min: 9000 + max: 65535 + - variable: targetPort + label: "Target Port" + description: "The internal(!) port on the container the Application runs on" + schema: + type: int + default: 11211 + + - variable: port + label: "Container Port" + schema: + type: int + default: 11211 + editable: true + required: true + + + + - variable: serviceexpert + group: "Networking and Services" + label: "Show Expert Config" + schema: + type: boolean + default: false + show_subquestions_if: true + subquestions: + - variable: hostNetwork + group: "Networking and Services" + label: "Host-Networking (Complicated)" + schema: + type: boolean + default: false + +# Include{serviceExpert} + +# Include{serviceList} + +# Include{persistenceList} + +# Include{ingressList} + + - variable: advancedSecurity + label: "Show Advanced Security Settings" + group: "Security and Permissions" + schema: + type: boolean + default: false + show_subquestions_if: true + subquestions: + - variable: securityContext + label: "Security Context" + schema: + type: dict + attrs: + - variable: privileged + label: "Privileged mode" + schema: + type: boolean + default: false + - variable: readOnlyRootFilesystem + label: "ReadOnly Root Filesystem" + schema: + type: boolean + default: true + - variable: allowPrivilegeEscalation + label: "Allow Privilege Escalation" + schema: + type: boolean + default: false + - variable: runAsNonRoot + label: "runAsNonRoot" + schema: + type: boolean + default: true + + - variable: podSecurityContext + group: "Security and Permissions" + label: "Pod Security Context" + schema: + type: dict + attrs: + - variable: runAsUser + label: "runAsUser" + description: "The UserID of the user running the application" + schema: + type: int + default: 568 + - variable: runAsGroup + label: "runAsGroup" + description: The groupID this App of the user running the application" + schema: + type: int + default: 568 + - variable: fsGroup + label: "fsGroup" + description: "The group that should own ALL storage." + schema: + type: int + default: 568 + - variable: supplementalGroups + label: "supplemental Groups" + schema: + type: list + default: [] + items: + - variable: supplementalGroupsEntry + label: "supplemental Group" + schema: + type: int + - variable: fsGroupChangePolicy + label: "When should we take ownership?" + schema: + type: string + default: "OnRootMismatch" + enum: + - value: "OnRootMismatch" + description: "OnRootMismatch" + - value: "Always" + description: "Always" + +# Include{resources} + +# Include{advanced} + +# Include{addons} diff --git a/charts/incubator/memcached/templates/backup-postgres-config.yaml b/charts/incubator/memcached/templates/backup-postgres-config.yaml new file mode 100644 index 00000000000..e52eb2ed5a1 --- /dev/null +++ b/charts/incubator/memcached/templates/backup-postgres-config.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: "postgres-backup-hook-config-map" + annotations: + rollme: {{ randAlphaNum 5 | quote }} +data: + entrypoint.sh: |- + #!/bin/sh + cmd="/docker-entrypoint.sh postgres" + eval "${cmd}" & disown; + until pg_isready; do + sleep 5; + done; + pg_dump -U {{ .Values.postgresqlUser }} -d {{ .Values.postgresqlDatabase }} > /dbbackups/$BACKUP_NAME; diff --git a/charts/incubator/memcached/templates/common.yaml b/charts/incubator/memcached/templates/common.yaml new file mode 100644 index 00000000000..9705d4f5fa6 --- /dev/null +++ b/charts/incubator/memcached/templates/common.yaml @@ -0,0 +1,2 @@ + +{{ include "common.all" . }} diff --git a/charts/incubator/memcached/templates/secret.yaml b/charts/incubator/memcached/templates/secret.yaml new file mode 100644 index 00000000000..be7022c005f --- /dev/null +++ b/charts/incubator/memcached/templates/secret.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "common.names.fullname" . }} + labels: + {{- include "common.labels" . | nindent 4 }} + annotations: + {{- with .Values.annotations }} + {{- toYaml . | nindent 4 }} + {{- end }} +type: Opaque +data: + postgresql-password: {{ ( .Values.postgresqlPassword | default "empty" ) | b64enc | quote }} diff --git a/charts/incubator/memcached/templates/upgrade-backup-postgres-hook.yaml b/charts/incubator/memcached/templates/upgrade-backup-postgres-hook.yaml new file mode 100644 index 00000000000..516ee5180a6 --- /dev/null +++ b/charts/incubator/memcached/templates/upgrade-backup-postgres-hook.yaml @@ -0,0 +1,56 @@ +{{- if and ( .Values.enableUpgradeBackup ) ( .Values.ixChartContext ) -}} +{{- if .Values.ixChartContext.isUpgrade -}} +{{- $upgradeDict := .Values.ixChartContext.upgradeMetadata -}} +{{ $values := (. | mustDeepCopy) }} +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: "pre-upgrade-hook2" + annotations: + "helm.sh/hook": pre-upgrade + "helm.sh/hook-weight": "1" + "helm.sh/hook-delete-policy": hook-succeeded + rollme: {{ randAlphaNum 5 | quote }} +spec: + template: + metadata: + name: "pre-upgrade-hook2" + spec: + restartPolicy: Never + containers: + - name: {{ .Chart.Name }}-postgres-backup + image: {{ printf "%v:%v" .Values.image.repository .Values.image.tag}} + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: BACKUP_NAME + value: {{- printf "postgres-backup-from-%s-to-%s-revision-%d" $upgradeDict.oldChartVersion $upgradeDict.newChartVersion (int64 $upgradeDict.preUpgradeRevision) -}} + - name: POSTGRES_USER + value: {{ .Values.postgresqlUsername | quote }} + - name: POSTGRES_DB + value: {{ .Values.postgresqlDatabase | quote }} + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: {{ ( .Values.existingSecret | default ( include "common.names.fullname" . ) ) | quote }} + key: "postgresql-password" + command: + - "/bin/backup_entrypoint.sh" + volumeMounts: + - name: backup-script-configmap + mountPath: /bin/backup_entrypoint.sh + readOnly: true + subPath: entrypoint.sh + {{- with (include "common.controller.volumeMounts" . | trim) }} + {{ nindent 4 . }} + {{- end }} + volumes: + - name: backup-script-configmap + configMap: + defaultMode: 0700 + name: "postgres-backup-hook-config-map" + {{- with (include "common.controller.volumes" . | trim) }} + {{- nindent 2 . }} + {{- end }} +{{- end -}} +{{- end -}} diff --git a/charts/incubator/memcached/values.yaml b/charts/incubator/memcached/values.yaml new file mode 100644 index 00000000000..29a936e5168 --- /dev/null +++ b/charts/incubator/memcached/values.yaml @@ -0,0 +1,11 @@ +image: + repository: bitnami/memcached + pullPolicy: IfNotPresent + tag: 1.6.12@sha256:f02e8e24e90ce1e3ce132964bea7a9af70d1e13510d8c1c8a6e66c2fed1f4621 + +service: + main: + ports: + main: + port: 11211 + targetPort: 11211