diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index 82c1183773..e5113d9da7 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: common description: A library chart for iX Official Catalog type: library -version: 1.0.8 +version: 1.0.9 appVersion: v1 annotations: title: Common Library Chart diff --git a/library/common/templates/app_functions/_mariadb.tpl b/library/common/templates/app_functions/_mariadb.tpl new file mode 100644 index 0000000000..c223ccc1bc --- /dev/null +++ b/library/common/templates/app_functions/_mariadb.tpl @@ -0,0 +1,177 @@ +{{/* Returns a mariadb pod with init container for fixing permissions +and a pre-upgrade job to backup the database */}} +{{/* Call this template: +{{ include "ix.v1.common.app.mariadb" (dict "name" "mariadb" "secretName" "mariadb-creds" "backupPath" "/mariadb_backup" "resources" .Values.resources) }} + +name (optional): Name of the mariadb pod/container (default: mariadb) +secretName (required): Name of the secret containing the mariadb credentials +backupPath (optional): Path to store the backup, it's the container's path (default: /mariadb_backup) +resources (required): Resources for the mariadb container +backupChownMode (optional): Whether to chown the backup directory or + check parent directory permissions and fix them if needed. + (default: check) Valid values: always, check +*/}} +{{- define "ix.v1.common.app.mariadb" -}} + {{- $name := .name | default "mariadb" -}} + {{- $secretName := (required "MariaDB - Secret Name is required" .secretName) -}} + {{- $backupPath := .backupPath | default "/mariadb_backup" -}} + {{- $backupChownMode := .backupChownMode | default "check" -}} + {{- $ixChartContext := .ixChartContext -}} + {{- $resources := (required "MariadDB - Resources are required" .resources) }} +{{ $name }}: + enabled: true + type: Deployment + podSpec: + containers: + {{ $name }}: + enabled: true + primary: true + imageSelector: mariadbImage + securityContext: + runAsUser: 999 + runAsGroup: 999 + readOnlyRootFilesystem: false + resources: + limits: + cpu: {{ $resources.limits.cpu }} + memory: {{ $resources.limits.memory }} + envFrom: + - secretRef: + name: {{ $secretName }} + probes: + {{- $args := "--user=root --host=localhost --password=$MARIADB_ROOT_PASSWORD" }} + liveness: + enabled: true + type: exec + command: + - sh + - -c + - "until mariadb-admin {{ $args }} ping && mariadb-admin {{ $args }} status; do sleep 2; done" + readiness: + enabled: true + type: exec + command: + - sh + - -c + - "until mariadb-admin {{ $args }} ping && mariadb-admin {{ $args }} status; do sleep 2; done" + startup: + enabled: true + type: exec + command: + - sh + - -c + - "until mariadb-admin {{ $args }} ping && mariadb-admin {{ $args }} status; do sleep 2; done" + initContainers: + {{- include "ix.v1.common.app.permissions" (dict "UID" 999 "GID" 999) | nindent 6 }} + +{{/* Backup Job */}} +{{- $enableBackupJob := false -}} +{{- if hasKey $ixChartContext "isUpgrade" -}} + {{- if $ixChartContext.isUpgrade -}} + {{- $enableBackupJob = true -}} + {{- end -}} +{{- else -}} + {{/* + If the key is not present in ixChartContext, + means we are outside SCALE (Probably CI), + let upgrade job run + */}} + {{- $enableBackupJob = true -}} +{{- end }} +mariadbbackup: + enabled: {{ $enableBackupJob }} + type: Job + annotations: + "helm.sh/hook": pre-upgrade + "helm.sh/hook-weight": "1" + "helm.sh/hook-delete-policy": hook-succeeded + podSpec: + restartPolicy: Never + containers: + mariadbbackup: + enabled: true + primary: true + imageSelector: mariadbImage + securityContext: + runAsUser: 999 + runAsGroup: 999 + readOnlyRootFilesystem: false + probes: + liveness: + enabled: false + readiness: + enabled: false + startup: + enabled: false + resources: + limits: + cpu: 2000m + memory: 2Gi + envFrom: + - secretRef: + name: {{ $secretName }} + command: + - sh + - -c + - | + until mariadb-admin --user=root --host="${MARIADB_HOST}" --password="${MARIADB_ROOT_PASSWORD}" --connect-timeout=5 ping + do + echo "Waiting for mariadb to be ready. Sleeping 2 seconds" + sleep 2s + done + until mariadb-admin --user=root --host="${MARIADB_HOST}" --password="${MARIADB_ROOT_PASSWORD}" --connect-timeout=5 status + do + echo "Waiting for mariadb to be alive. Sleeping 2 seconds" + sleep 2s + done + + echo "Creating backup of ${MARIADB_DATABASE} database" + + mariadb-dump ${MARIADB_DATABASE} --host="${MARIADB_HOST}" \ + --user=root --password="${MARIADB_ROOT_PASSWORD}" \ + > {{ $backupPath }}/${MARIADB_DATABASE}_$(date +%Y-%m-%d_%H-%M-%S).sql \ + || echo "Failed to create backup" + + echo "Backup finished" + initContainers: + {{- include "ix.v1.common.app.permissions" (dict "UID" 999 "GID" 999 "type" "init" "mode" $backupChownMode) | nindent 6 }} +{{- end -}} + + +{{/* Returns a mariadb-wait container for waiting for mariadb to be ready */}} +{{/* Call this template: +{{ include "ix.v1.common.app.mariadbWait" (dict "name" "mariadb-wait" "secretName" "mariadb-creds") }} + +name (optional): Name of the mariadb-wait container (default: mariadb-wait) +secretName (required): Name of the secret containing the mariadb credentials +*/}} +{{- define "ix.v1.common.app.mariadbWait" -}} + {{- $name := .name | default "mariadb-wait" -}} + {{- $secretName := (required "Mariadb-Wait - Secret Name is required" .secretName) }} +{{ $name }}: + enabled: true + type: init + imageSelector: mariadbImage + envFrom: + - secretRef: + name: {{ $secretName }} + resources: + limits: + cpu: 500m + memory: 256Mi + command: bash + args: + - -c + - | + echo "Waiting for mariadb to be ready" + until mariadb-admin --user=root --host="${MARIADB_HOST}" --password="${MARIADB_ROOT_PASSWORD}" --connect-timeout=5 ping + do + echo "Waiting for mariadb to be ready. Sleeping 2 seconds" + sleep 2s + done + until mariadb-admin --user=root --host="${MARIADB_HOST}" --password="${MARIADB_ROOT_PASSWORD}" --connect-timeout=5 status + do + echo "Waiting for mariadb to be alive. Sleeping 2 seconds" + sleep 2s + done +{{- end -}} diff --git a/library/common/values.yaml b/library/common/values.yaml index 95fdac02cb..9b11deb4c5 100644 --- a/library/common/values.yaml +++ b/library/common/values.yaml @@ -46,6 +46,11 @@ postgresImage: tag: "15.2" pullPolicy: IfNotPresent +mariadbImage: + repository: mariadb + tag: "10.6.14" + pullPolicy: IfNotPresent + # -- (docs/README.md) securityContext: container: diff --git a/library/ix-dev/community/wordpress/Chart.lock b/library/ix-dev/community/wordpress/Chart.lock new file mode 100644 index 0000000000..f730d2f803 --- /dev/null +++ b/library/ix-dev/community/wordpress/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: common + repository: file://../../../common + version: 1.0.9 +digest: sha256:c3eb00f142d5d1cdbff7843940c150a00bd916520363e6ee9f459ce61fa92b40 +generated: "2023-06-14T18:39:35.751013894+03:00" diff --git a/library/ix-dev/community/wordpress/Chart.yaml b/library/ix-dev/community/wordpress/Chart.yaml new file mode 100644 index 0000000000..f66039b925 --- /dev/null +++ b/library/ix-dev/community/wordpress/Chart.yaml @@ -0,0 +1,25 @@ +name: wordpress +description: Wordpress is a web content management system +annotations: + title: Wordpress +type: application +version: 1.0.0 +apiVersion: v2 +appVersion: '1.19.0' +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://wordpress.org +icon: https://github.com/WordPress/WordPress/blob/master/wp-admin/images/wordpress-logo.png?raw=true +sources: + - https://hub.docker.com/_/wordpress + - https://github.com/truenas/charts/tree/master/community/wordpress +keywords: + - cms + - blog diff --git a/library/ix-dev/community/wordpress/README.md b/library/ix-dev/community/wordpress/README.md new file mode 100644 index 0000000000..bde8537dee --- /dev/null +++ b/library/ix-dev/community/wordpress/README.md @@ -0,0 +1,12 @@ +# Wordpress + +[Wordpress](https://wordpress.org/) is a web content management system. + +> When application is installed, a container will be launched with **root** privileges. +> This is required in order to apply the correct permissions to the `wordpress` directories. +> Afterward, the `wordpress` container will run as a **non**-root user (`33`). +> Same applies to the `mariadb` container. This will run afterwards as a **non**-root user (`999`). +> On each upgrade, a container will be launched with **root** privileges in order to apply the correct +> permissions to the `mariadb` **backups** directory. Container that performs the backup will run as a **non**-root user (`999`) afterwards. +> Keep in mind the permissions on the backup directory will be changed to `999:999` on **every** update. +> But will only be changed once for the `wordpress` and `mariadb` data directories. diff --git a/library/ix-dev/community/wordpress/app-readme.md b/library/ix-dev/community/wordpress/app-readme.md new file mode 100644 index 0000000000..bde8537dee --- /dev/null +++ b/library/ix-dev/community/wordpress/app-readme.md @@ -0,0 +1,12 @@ +# Wordpress + +[Wordpress](https://wordpress.org/) is a web content management system. + +> When application is installed, a container will be launched with **root** privileges. +> This is required in order to apply the correct permissions to the `wordpress` directories. +> Afterward, the `wordpress` container will run as a **non**-root user (`33`). +> Same applies to the `mariadb` container. This will run afterwards as a **non**-root user (`999`). +> On each upgrade, a container will be launched with **root** privileges in order to apply the correct +> permissions to the `mariadb` **backups** directory. Container that performs the backup will run as a **non**-root user (`999`) afterwards. +> Keep in mind the permissions on the backup directory will be changed to `999:999` on **every** update. +> But will only be changed once for the `wordpress` and `mariadb` data directories. diff --git a/library/ix-dev/community/wordpress/charts/common-1.0.9.tgz b/library/ix-dev/community/wordpress/charts/common-1.0.9.tgz new file mode 100644 index 0000000000..528451cc57 Binary files /dev/null and b/library/ix-dev/community/wordpress/charts/common-1.0.9.tgz differ diff --git a/library/ix-dev/community/wordpress/ci/basic-values.yaml b/library/ix-dev/community/wordpress/ci/basic-values.yaml new file mode 100644 index 0000000000..25f5e4ec4c --- /dev/null +++ b/library/ix-dev/community/wordpress/ci/basic-values.yaml @@ -0,0 +1,10 @@ +wpStorage: + data: + type: hostPath + hostPath: /mnt/{{ .Release.Name }}/data + mariadbData: + type: hostPath + hostPath: /mnt/{{ .Release.Name }}/mariadbData + mariadbBackup: + type: hostPath + hostPath: /mnt/{{ .Release.Name }}/mariadbBackup diff --git a/library/ix-dev/community/wordpress/item.yaml b/library/ix-dev/community/wordpress/item.yaml new file mode 100644 index 0000000000..57f7095f58 --- /dev/null +++ b/library/ix-dev/community/wordpress/item.yaml @@ -0,0 +1,11 @@ +icon_url: https://github.com/WordPress/WordPress/blob/master/wp-admin/images/wordpress-logo.png?raw=true +categories: + - productivity +screenshots: + - https://wordpress.org/documentation/files/2022/06/wordpress-6-0-dashboard-1024x583.png + - https://ps.w.org/wordpress-popular-posts/assets/screenshot-1.png?rev=2179381 + - https://ps.w.org/wordpress-popular-posts/assets/screenshot-4.png?rev=2179381 + - https://ps.w.org/client-portal/trunk/screenshot-1.png?rev=2868706 +tags: + - cms + - blog diff --git a/library/ix-dev/community/wordpress/metadata.yaml b/library/ix-dev/community/wordpress/metadata.yaml new file mode 100644 index 0000000000..b9e04e4581 --- /dev/null +++ b/library/ix-dev/community/wordpress/metadata.yaml @@ -0,0 +1,10 @@ +runAsContext: + - userName: www-data + groupName: www-data + gid: 33 + uid: 33 + description: Wordpress run as a non-root user (33) +capabilities: + - name: NET_BIND_SERVICE + description: Wordpress requires this ability to bind to port 80 within the container. +hostMounts: [] diff --git a/library/ix-dev/community/wordpress/questions.yaml b/library/ix-dev/community/wordpress/questions.yaml new file mode 100644 index 0000000000..64d239450c --- /dev/null +++ b/library/ix-dev/community/wordpress/questions.yaml @@ -0,0 +1,270 @@ +groups: + - name: Wordpress Configuration + description: Configure Wordpress + - name: Network Configuration + description: Configure Network for Wordpress + - name: Storage Configuration + description: Configure Storage for Wordpress + - name: Resources Configuration + description: Configure Resources for Wordpress + +portals: + web_portal: + protocols: + - "$kubernetes-resource_configmap_portal_protocol" + host: + - "$kubernetes-resource_configmap_portal_host" + ports: + - "$kubernetes-resource_configmap_portal_port" + path: "$kubernetes-resource_configmap_portal_path" + admin: + protocols: + - "$kubernetes-resource_configmap_portal_protocol" + host: + - "$kubernetes-resource_configmap_portal_host" + ports: + - "$kubernetes-resource_configmap_portal_port" + path: /wp-admin + +questions: + - variable: wpConfig + label: "" + group: Wordpress Configuration + schema: + type: dict + attrs: + - variable: additionalEnvs + label: Additional Environment Variables + description: Configure additional environment variables for Wordpress. + schema: + type: list + default: [] + items: + - variable: env + label: Environment Variable + schema: + type: dict + attrs: + - variable: name + label: Name + schema: + type: string + required: true + - variable: value + label: Value + schema: + type: string + required: true + + - variable: wpNetwork + label: "" + group: Network Configuration + schema: + type: dict + attrs: + - variable: webPort + label: Web Port + description: The port for the Wordpress WebUI. + schema: + type: int + default: 30040 + min: 9000 + max: 65535 + required: true + + - variable: wpStorage + label: "" + group: Storage Configuration + schema: + type: dict + attrs: + - variable: data + label: Wordpress Data Storage + description: The path to store Wordpress 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: mariadbData + label: Wordpress MariaDB Data Storage + description: The path to store Wordpress MariaDB 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: mariadbData + $ref: + - "normalize/ixVolume" + - variable: hostPath + label: Host Path + schema: + type: hostpath + show_if: [["type", "=", "hostPath"]] + immutable: true + required: true + - variable: mariadbBackup + label: Wordpress MariaDB Backup Storage + description: The path to store Wordpress MariaDB Backup. + 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: mariadbBackup + $ref: + - "normalize/ixVolume" + - variable: hostPath + label: Host Path + schema: + type: hostpath + show_if: [["type", "=", "hostPath"]] + immutable: true + required: true + - variable: additionalStorages + label: Additional Storage + description: Additional storage for Wordpress. + schema: + type: list + default: [] + items: + - variable: storageEntry + label: Storage Entry + 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: mountPath + label: Mount Path + description: The path inside the container to mount the storage. + schema: + type: path + required: true + - variable: hostPath + label: Host Path + description: The host path to use for storage. + schema: + type: hostpath + show_if: [["type", "=", "hostPath"]] + required: true + - variable: datasetName + label: Dataset Name + description: The name of the dataset to use for storage. + schema: + type: string + show_if: [["type", "=", "ixVolume"]] + required: true + immutable: true + default: "storage_entry" + $ref: + - "normalize/ixVolume" + + - variable: resources + label: "" + group: Resources Configuration + schema: + type: dict + attrs: + - variable: limits + label: Limits + schema: + type: dict + attrs: + - variable: cpu + label: CPU + description: CPU limit for Wordpress. + schema: + type: string + default: 4000m + required: true + - variable: memory + label: Memory + description: Memory limit for Wordpress. + schema: + type: string + default: 8Gi + required: true diff --git a/library/ix-dev/community/wordpress/templates/NOTES.txt b/library/ix-dev/community/wordpress/templates/NOTES.txt new file mode 100644 index 0000000000..ba4e01146c --- /dev/null +++ b/library/ix-dev/community/wordpress/templates/NOTES.txt @@ -0,0 +1 @@ +{{ include "ix.v1.common.lib.chart.notes" $ }} diff --git a/library/ix-dev/community/wordpress/templates/_configuration.tpl b/library/ix-dev/community/wordpress/templates/_configuration.tpl new file mode 100644 index 0000000000..9fa4e00672 --- /dev/null +++ b/library/ix-dev/community/wordpress/templates/_configuration.tpl @@ -0,0 +1,33 @@ +{{- define "wordpress.configuration" -}} + + {{- $fullname := (include "ix.v1.common.lib.chart.names.fullname" $) -}} + + {{- $dbHost := (printf "%s-mariadb" $fullname) -}} + {{- $dbUser := "wordpress" -}} + {{- $dbName := "wordpress" -}} + + {{- $dbPass := (randAlphaNum 32) -}} + {{- $dbRootPass := (randAlphaNum 32) -}} + {{- with (lookup "v1" "Secret" .Release.Namespace (printf "%s-mariadb-creds" $fullname)) -}} + {{- $dbPass = ((index .data "MARIADB_PASSWORD") | b64dec) -}} + {{- $dbRootPass = ((index .data "MARIADB_ROOT_PASSWORD") | b64dec) -}} + {{- end }} + +secret: + mariadb-creds: + enabled: true + data: + MARIADB_USER: {{ $dbUser }} + MARIADB_DATABASE: {{ $dbName }} + MARIADB_PASSWORD: {{ $dbPass }} + MARIADB_ROOT_PASSWORD: {{ $dbRootPass }} + MARIADB_HOST: {{ $dbHost }} + + wordpress-creds: + enabled: true + data: + WORDPRESS_DB_HOST: {{ $dbHost }} + WORDPRESS_DB_NAME: {{ $dbName }} + WORDPRESS_DB_USER: {{ $dbUser }} + WORDPRESS_DB_PASSWORD: {{ $dbPass }} +{{- end -}} diff --git a/library/ix-dev/community/wordpress/templates/_mariadb.tpl b/library/ix-dev/community/wordpress/templates/_mariadb.tpl new file mode 100644 index 0000000000..a5a91b2bb7 --- /dev/null +++ b/library/ix-dev/community/wordpress/templates/_mariadb.tpl @@ -0,0 +1,50 @@ +{{- define "wordpress.mariadb.workload" -}} +workload: +{{- include "ix.v1.common.app.mariadb" (dict "secretName" "mariadb-creds" + "resources" .Values.resources + "ixChartContext" .Values.ixChartContext) | nindent 2 }} +{{/* Service */}} +service: + mariadb: + enabled: true + type: ClusterIP + targetSelector: mariadb + ports: + mariadb: + enabled: true + primary: true + port: 3306 + targetPort: 3306 + targetSelector: mariadb + +{{/* Persistence */}} +persistence: + mariadbdata: + enabled: true + type: {{ .Values.wpStorage.mariadbData.type }} + datasetName: {{ .Values.wpStorage.mariadbData.datasetName | default "" }} + hostPath: {{ .Values.wpStorage.mariadbData.hostPath | default "" }} + targetSelector: + # MariaDB pod + mariadb: + # MariaDB container + mariadb: + mountPath: /var/lib/mysql + # MariaDB - Permissions container + permissions: + mountPath: /mnt/directories/mariadb_data + mariadbbackup: + enabled: true + type: {{ .Values.wpStorage.mariadbBackup.type }} + datasetName: {{ .Values.wpStorage.mariadbBackup.datasetName | default "" }} + hostPath: {{ .Values.wpStorage.mariadbBackup.hostPath | default "" }} + targetSelector: + # MariaDB backup pod + mariadbbackup: + # MariaDB backup container + mariadbbackup: + mountPath: /mariadb_backup + # MariaDB - Permissions container + permissions: + mountPath: /mnt/directories/mariadb_backup +{{- end -}} diff --git a/library/ix-dev/community/wordpress/templates/_portal.tpl b/library/ix-dev/community/wordpress/templates/_portal.tpl new file mode 100644 index 0000000000..6249ccb850 --- /dev/null +++ b/library/ix-dev/community/wordpress/templates/_portal.tpl @@ -0,0 +1,12 @@ +{{- define "wordpress.portal" -}} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: portal +data: + path: / + port: {{ .Values.wpNetwork.webPort | quote }} + protocol: http + host: $node_ip +{{- end -}} diff --git a/library/ix-dev/community/wordpress/templates/_wordpress.tpl b/library/ix-dev/community/wordpress/templates/_wordpress.tpl new file mode 100644 index 0000000000..42b9d333ca --- /dev/null +++ b/library/ix-dev/community/wordpress/templates/_wordpress.tpl @@ -0,0 +1,106 @@ +{{- define "wordpress.workload" -}} +workload: + wordpress: + enabled: true + primary: true + type: Deployment + podSpec: + hostNetwork: false + containers: + wordpress: + enabled: true + primary: true + imageSelector: image + securityContext: + runAsUser: 33 + runAsGroup: 33 + capabilities: + add: + - NET_BIND_SERVICE + envFrom: + - secretRef: + name: wordpress-creds + {{ with .Values.wpConfig.additionalEnvs }} + envList: + {{ range $env := . }} + - name: {{ $env.name }} + value: {{ $env.value }} + {{ end }} + {{ end }} + probes: + liveness: + enabled: true + type: tcp + port: 80 + readiness: + enabled: true + type: tcp + port: 80 + startup: + enabled: true + type: tcp + port: 80 + initContainers: + {{- include "ix.v1.common.app.permissions" (dict "containerName" "01-permissions" + "UID" 33 + "GID" 33 + "type" "install") | nindent 8 }} + {{- include "ix.v1.common.app.mariadbWait" (dict "name" "mariadb-wait" + "secretName" "mariadb-creds") | nindent 8 }} +{{/* Service */}} +service: + wordpress: + enabled: true + primary: true + type: NodePort + targetSelector: wordpress + ports: + webui: + enabled: true + primary: true + port: {{ .Values.wpNetwork.webPort }} + nodePort: {{ .Values.wpNetwork.webPort }} + targetPort: 80 + targetSelector: wordpress + +{{/* Persistence */}} +persistence: + data: + enabled: true + type: {{ .Values.wpStorage.data.type }} + datasetName: {{ .Values.wpStorage.data.datasetName | default "" }} + hostPath: {{ .Values.wpStorage.data.hostPath | default "" }} + targetSelector: + wordpress: + wordpress: + mountPath: /var/www/html + 01-permissions: + mountPath: /mnt/directories/data + {{- range $idx, $storage := .Values.wpStorage.additionalStorages }} + {{ printf "wp-%v" (int $idx) }}: + enabled: true + type: {{ $storage.type }} + datasetName: {{ $storage.datasetName | default "" }} + hostPath: {{ $storage.hostPath | default "" }} + targetSelector: + wordpress: + wordpress: + mountPath: {{ $storage.mountPath }} + 01-permissions: + mountPath: /mnt/directories{{ $storage.mountPath }} + {{- end }} + tmp: + enabled: true + type: emptyDir + targetSelector: + wordpress: + wordpress: + mountPath: /tmp + varrun: + enabled: true + type: emptyDir + targetSelector: + wordpress: + wordpress: + mountPath: /var/run +{{- end -}} diff --git a/library/ix-dev/community/wordpress/templates/common.yaml b/library/ix-dev/community/wordpress/templates/common.yaml new file mode 100644 index 0000000000..8dfa28ebdf --- /dev/null +++ b/library/ix-dev/community/wordpress/templates/common.yaml @@ -0,0 +1,11 @@ +{{- include "ix.v1.common.loader.init" . -}} + +{{/* Merge the templates with Values */}} +{{- $_ := mustMergeOverwrite .Values (include "wordpress.configuration" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "wordpress.workload" $ | fromYaml) -}} +{{- $_ := mustMergeOverwrite .Values (include "wordpress.mariadb.workload" $ | fromYaml) -}} + +{{/* Create the configmap for portal manually*/}} +{{- include "wordpress.portal" $ -}} + +{{- include "ix.v1.common.loader.apply" . -}} diff --git a/library/ix-dev/community/wordpress/upgrade_info.json b/library/ix-dev/community/wordpress/upgrade_info.json new file mode 100644 index 0000000000..767388094a --- /dev/null +++ b/library/ix-dev/community/wordpress/upgrade_info.json @@ -0,0 +1 @@ +{"filename": "values.yaml", "keys": ["image"]} diff --git a/library/ix-dev/community/wordpress/upgrade_strategy b/library/ix-dev/community/wordpress/upgrade_strategy new file mode 100755 index 0000000000..41e9448b21 --- /dev/null +++ b/library/ix-dev/community/wordpress/upgrade_strategy @@ -0,0 +1,31 @@ +#!/usr/bin/python3 +import json +import re +import sys + +from catalog_update.upgrade_strategy import semantic_versioning + + +RE_STABLE_VERSION = re.compile(r'[0-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/wordpress/values.yaml b/library/ix-dev/community/wordpress/values.yaml new file mode 100644 index 0000000000..09d5c5c920 --- /dev/null +++ b/library/ix-dev/community/wordpress/values.yaml @@ -0,0 +1,27 @@ +image: + repository: wordpress + pullPolicy: IfNotPresent + tag: 6.2.2 + +resources: + limits: + cpu: 4000m + memory: 8Gi + +wpConfig: + additionalEnvs: [] + +wpNetwork: + webPort: 30040 + +wpStorage: + data: + type: ixVolume + datasetName: data + mariadbData: + type: ixVolume + datasetName: mariadbData + mariadbBackup: + type: ixVolume + datasetName: mariadbBackup + additionalStorages: []