diff --git a/library/ix-dev/community/redis/Chart.lock b/library/ix-dev/community/redis/Chart.lock new file mode 100644 index 0000000000..2f3ddf5b76 --- /dev/null +++ b/library/ix-dev/community/redis/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: common + repository: file://../../../common + version: 1.0.9 +digest: sha256:c3eb00f142d5d1cdbff7843940c150a00bd916520363e6ee9f459ce61fa92b40 +generated: "2023-06-29T16:01:12.464571053+03:00" diff --git a/library/ix-dev/community/redis/Chart.yaml b/library/ix-dev/community/redis/Chart.yaml new file mode 100644 index 0000000000..9bb7074109 --- /dev/null +++ b/library/ix-dev/community/redis/Chart.yaml @@ -0,0 +1,25 @@ +name: redis +description: Redis. The open source, in-memory data store used by millions of developers as a database, cache, streaming engine, and message broker. +annotations: + title: Redis +type: application +version: 1.0.0 +apiVersion: v2 +appVersion: 7.0.11 +kubeVersion: '>=1.16.0-0' +maintainers: + - name: truenas + url: https://www.truenas.com/ + email: dev@ixsystems.com +dependencies: + - name: common + repository: file://../../../common + version: 1.0.9 +home: https://redis.io/ +icon: https://avatars.githubusercontent.com/u/1529926?s=200&v=4 +sources: + - https://hub.docker.com/r/bitnami/redis + - https://github.com/bitnami/containers/tree/main/bitnami/redis + - https://redis.io/ +keywords: + - cache diff --git a/library/ix-dev/community/redis/README.md b/library/ix-dev/community/redis/README.md new file mode 100644 index 0000000000..8520dd896c --- /dev/null +++ b/library/ix-dev/community/redis/README.md @@ -0,0 +1,8 @@ +# Redis + +[Redis](https://redis.io/). The open source, in-memory data store used by millions of developers as a database, cache, streaming engine, and message broker. + +> When application is installed, a container will be launched with **root** privileges. +> This is required in order to apply the correct permissions to the `Redis` directories. +> Afterward, the `Redis` container will run as a **non**-root user (`1001`) and root group. +> All mounted storage(s) will be `chown`ed only if the parent directory does not match `1001` user. diff --git a/library/ix-dev/community/redis/app-readme.md b/library/ix-dev/community/redis/app-readme.md new file mode 100644 index 0000000000..8520dd896c --- /dev/null +++ b/library/ix-dev/community/redis/app-readme.md @@ -0,0 +1,8 @@ +# Redis + +[Redis](https://redis.io/). The open source, in-memory data store used by millions of developers as a database, cache, streaming engine, and message broker. + +> When application is installed, a container will be launched with **root** privileges. +> This is required in order to apply the correct permissions to the `Redis` directories. +> Afterward, the `Redis` container will run as a **non**-root user (`1001`) and root group. +> All mounted storage(s) will be `chown`ed only if the parent directory does not match `1001` user. diff --git a/library/ix-dev/community/redis/charts/common-1.0.9.tgz b/library/ix-dev/community/redis/charts/common-1.0.9.tgz new file mode 100644 index 0000000000..c10e7bc035 Binary files /dev/null and b/library/ix-dev/community/redis/charts/common-1.0.9.tgz differ diff --git a/library/ix-dev/community/redis/ci/basic-values.yaml b/library/ix-dev/community/redis/ci/basic-values.yaml new file mode 100644 index 0000000000..8be87344f9 --- /dev/null +++ b/library/ix-dev/community/redis/ci/basic-values.yaml @@ -0,0 +1,7 @@ +redisStorage: + data: + type: hostPath + hostPath: /mnt/{{ .Release.Name }}/data + +redisConfig: + password: pass diff --git a/library/ix-dev/community/redis/ci/no-password-values.yaml b/library/ix-dev/community/redis/ci/no-password-values.yaml new file mode 100644 index 0000000000..7e6d30acf8 --- /dev/null +++ b/library/ix-dev/community/redis/ci/no-password-values.yaml @@ -0,0 +1,7 @@ +redisStorage: + data: + type: hostPath + hostPath: /mnt/{{ .Release.Name }}/data + +redisConfig: + allowEmptyPassword: true diff --git a/library/ix-dev/community/redis/item.yaml b/library/ix-dev/community/redis/item.yaml new file mode 100644 index 0000000000..a7a20f4d61 --- /dev/null +++ b/library/ix-dev/community/redis/item.yaml @@ -0,0 +1,6 @@ +icon_url: https://avatars.githubusercontent.com/u/1529926?s=200&v=4 +screenshots: [] +categories: + - database +tags: + - cache diff --git a/library/ix-dev/community/redis/metadata.yaml b/library/ix-dev/community/redis/metadata.yaml new file mode 100644 index 0000000000..05c8762b70 --- /dev/null +++ b/library/ix-dev/community/redis/metadata.yaml @@ -0,0 +1,8 @@ +runAsContext: + - userName: redis + groupName: root + gid: 1001 + uid: 0 + description: Redis runs as a non-root user and root group. +capabilities: [] +hostMounts: [] diff --git a/library/ix-dev/community/redis/questions.yaml b/library/ix-dev/community/redis/questions.yaml new file mode 100644 index 0000000000..feb8500865 --- /dev/null +++ b/library/ix-dev/community/redis/questions.yaml @@ -0,0 +1,131 @@ +groups: + - name: Redis Configuration + description: Configure Redis + - name: Network Configuration + description: Configure Network for Redis + - name: Storage Configuration + description: Configure Storage for Redis + - name: Resources Configuration + description: Configure Resources for Redis + +questions: + - variable: redisConfig + label: "" + group: Redis Configuration + schema: + type: dict + attrs: + - variable: allowEmptyPassword + label: Allow Empty Password + description: | + Allow empty password for Redis.
+ It's recommended to keep this disabled. + schema: + type: boolean + default: false + - variable: password + label: Password + description: Password for Redis. + schema: + type: string + required: true + private: true + # Character @ is not allowed in password + valid_chars: '^((?!@).)*$' + valid_chars_error: "Character @ is not allowed in password" + show_if: [[ "allowEmptyPassword", "=", false ]] + default: "" + + - variable: redisNetwork + label: "" + group: Network Configuration + schema: + type: dict + attrs: + - variable: hostNetwork + label: Host Network + description: | + Bind to the host network. It's recommended to keep this disabled.
+ schema: + type: boolean + default: false + - variable: redisPort + label: Redis Port + description: The port for Redis. + schema: + type: int + default: 30036 + min: 9000 + max: 65535 + required: true + + - variable: redisStorage + label: "" + group: Storage Configuration + schema: + type: dict + attrs: + - variable: data + label: Redis Data Storage + description: The path to store Redis Data. + schema: + type: dict + attrs: + - variable: type + label: Type + description: | + ixVolume: Is dataset created automatically by the system.
+ Host Path: Is a path that already exists on the system. + schema: + type: string + required: true + default: "ixVolume" + enum: + - value: "hostPath" + description: Host Path (Path that already exists on the system) + - value: "ixVolume" + description: ixVolume (Dataset created automatically by the system) + - variable: datasetName + label: Dataset Name + schema: + type: string + show_if: [["type", "=", "ixVolume"]] + required: true + hidden: true + immutable: true + default: "data" + $ref: + - "normalize/ixVolume" + - variable: hostPath + label: Host Path + schema: + type: hostpath + show_if: [["type", "=", "hostPath"]] + immutable: true + required: true + + - variable: resources + group: Resources Configuration + label: "" + schema: + type: dict + attrs: + - variable: limits + label: Limits + schema: + type: dict + attrs: + - variable: cpu + label: CPU + description: CPU limit for Redis. + schema: + type: string + default: "4000m" + required: true + - variable: memory + label: Memory + description: Memory limit for Redis. + schema: + type: string + default: "8Gi" + required: true diff --git a/library/ix-dev/community/redis/templates/NOTES.txt b/library/ix-dev/community/redis/templates/NOTES.txt new file mode 100644 index 0000000000..ba4e01146c --- /dev/null +++ b/library/ix-dev/community/redis/templates/NOTES.txt @@ -0,0 +1 @@ +{{ include "ix.v1.common.lib.chart.notes" $ }} diff --git a/library/ix-dev/community/redis/templates/_configuration.tpl b/library/ix-dev/community/redis/templates/_configuration.tpl new file mode 100644 index 0000000000..042d191462 --- /dev/null +++ b/library/ix-dev/community/redis/templates/_configuration.tpl @@ -0,0 +1,11 @@ +{{- define "redis.configuration" -}} +configmap: + config: + enabled: true + data: + REDIS_PORT_NUMBER: {{ .Values.redisNetwork.redisPort | quote }} + ALLOW_EMPTY_PASSWORD: {{ ternary "yes" "no" .Values.redisConfig.allowEmptyPassword | quote }} + {{- if not .Values.redisConfig.allowEmptyPassword }} + REDIS_PASSWORD: {{ .Values.redisConfig.password | quote }} + {{- end }} +{{- end -}} diff --git a/library/ix-dev/community/redis/templates/_redis.tpl b/library/ix-dev/community/redis/templates/_redis.tpl new file mode 100644 index 0000000000..2b38ec68ae --- /dev/null +++ b/library/ix-dev/community/redis/templates/_redis.tpl @@ -0,0 +1,101 @@ +{{- define "redis.workload" -}} +workload: + redis: + enabled: true + primary: true + type: Deployment + podSpec: + hostNetwork: {{ .Values.redisNetwork.hostNetwork }} + securityContext: + fsGroup: 1001 + containers: + redis: + enabled: true + primary: true + imageSelector: image + securityContext: + runAsUser: 1001 + runAsGroup: 0 + runAsNonRoot: false + readOnlyRootFilesystem: false + envFrom: + - configMapRef: + name: config + {{ with .Values.redisConfig.additionalEnvs }} + envList: + {{ range $env := . }} + - name: {{ $env.name }} + value: {{ $env.value }} + {{ end }} + {{ end }} + probes: + {{ $args := printf "-p %v" .Values.redisNetwork.redisPort }} + {{ if not .Values.redisConfig.allowEmptyPassword }} + {{ $args = printf "%v -a %v" $args .Values.redisConfig.password }} + {{ end }} + liveness: + enabled: true + type: exec + command: + - /bin/sh + - -c + - | + redis-cli {{ $args }} ping | grep -q PONG + readiness: + enabled: true + type: exec + command: + - /bin/sh + - -c + - | + redis-cli {{ $args }} ping | grep -q PONG + startup: + enabled: true + type: exec + command: + - /bin/sh + - -c + - | + redis-cli {{ $args }} ping | grep -q PONG + initContainers: + {{- include "ix.v1.common.app.permissions" (dict "containerName" "01-permissions" + "UID" 1001 + "GID" 1001 + "mode" "check" + "type" "init") | nindent 8 }} +{{/* Service */}} +service: + redis: + enabled: true + primary: true + type: NodePort + targetSelector: redis + ports: + redis: + enabled: true + primary: true + port: {{ .Values.redisNetwork.redisPort }} + nodePort: {{ .Values.redisNetwork.redisPort }} + targetSelector: redis + +{{/* Persistence */}} +persistence: + data: + enabled: true + type: {{ .Values.redisStorage.data.type }} + datasetName: {{ .Values.redisStorage.data.datasetName | default "" }} + hostPath: {{ .Values.redisStorage.data.hostPath | default "" }} + targetSelector: + redis: + redis: + mountPath: /bitnami/redis/data + 01-permissions: + mountPath: /mnt/directories/data + tmp: + enabled: true + type: emptyDir + targetSelector: + redis: + redis: + mountPath: /tmp +{{- end -}} diff --git a/library/ix-dev/community/redis/templates/_validation.tpl b/library/ix-dev/community/redis/templates/_validation.tpl new file mode 100644 index 0000000000..7ffd67e167 --- /dev/null +++ b/library/ix-dev/community/redis/templates/_validation.tpl @@ -0,0 +1,11 @@ +{{- define "redis.validation" -}} + {{- if not .Values.redisConfig.allowEmptyPassword -}} + {{- if not .Values.redisConfig.password -}} + {{- fail "Redis - Field [Password] is required when [Allow Empty Password] is false" -}} + {{- end -}} + {{- if contains "@" .Values.redisConfig.password -}} + {{- fail "Redis - Field [Password] cannot contain '@'" -}} + {{- end -}} + {{- end -}} + +{{- end -}} diff --git a/library/ix-dev/community/redis/templates/common.yaml b/library/ix-dev/community/redis/templates/common.yaml new file mode 100644 index 0000000000..1cc8104b14 --- /dev/null +++ b/library/ix-dev/community/redis/templates/common.yaml @@ -0,0 +1,8 @@ +{{- include "ix.v1.common.loader.init" . -}} + +{{/* Merge the templates with Values */}} +{{- include "redis.validation" $ -}} +{{- $_ := mustMergeOverwrite .Values (include "redis.configuration" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "redis.workload" $ | fromYaml) -}} + +{{- include "ix.v1.common.loader.apply" . -}} diff --git a/library/ix-dev/community/redis/upgrade_info.json b/library/ix-dev/community/redis/upgrade_info.json new file mode 100644 index 0000000000..767388094a --- /dev/null +++ b/library/ix-dev/community/redis/upgrade_info.json @@ -0,0 +1 @@ +{"filename": "values.yaml", "keys": ["image"]} diff --git a/library/ix-dev/community/redis/upgrade_strategy b/library/ix-dev/community/redis/upgrade_strategy new file mode 100755 index 0000000000..aef37b7f05 --- /dev/null +++ b/library/ix-dev/community/redis/upgrade_strategy @@ -0,0 +1,30 @@ +#!/usr/bin/python3 +import json +import re +import sys + +from catalog_update.upgrade_strategy import semantic_versioning + +RE_STABLE_VERSION = re.compile(r'[1-9]+\.[0-9]+\.[0-9]+') + + +def newer_mapping(image_tags): + key = list(image_tags.keys())[0] + tags = {t: t for t in image_tags[key] if RE_STABLE_VERSION.fullmatch(t)} + version = semantic_versioning(list(tags)) + if not version: + return {} + + return { + 'tags': {key: tags[version]}, + 'app_version': version, + } + + +if __name__ == '__main__': + try: + versions_json = json.loads(sys.stdin.read()) + except ValueError: + raise ValueError('Invalid json specified') + + print(json.dumps(newer_mapping(versions_json))) diff --git a/library/ix-dev/community/redis/values.yaml b/library/ix-dev/community/redis/values.yaml new file mode 100644 index 0000000000..13976a7c63 --- /dev/null +++ b/library/ix-dev/community/redis/values.yaml @@ -0,0 +1,23 @@ +image: + repository: bitnami/redis + pullPolicy: IfNotPresent + tag: 7.0.11 + +resources: + limits: + cpu: 4000m + memory: 8Gi + +redisConfig: + allowEmptyPassword: false + password: '' + additionalEnvs: [] + +redisNetwork: + hostNetwork: false + redisPort: 30036 + +redisStorage: + data: + type: ixVolume + datasetName: data