Pārlūkot izejas kodu

NAS-122472 / 23.10 / add `wordpress` to `community` train (#1266)

* add `wordpress` to `community` catalog

* set version to 1.0.0

* fix sources

* update readme's

* remove category
Stavros Kois 2 gadi atpakaļ
vecāks
revīzija
77a8173e9f

+ 1 - 1
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

+ 177 - 0
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 -}}

+ 5 - 0
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:

+ 6 - 0
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"

+ 25 - 0
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

+ 12 - 0
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.

+ 12 - 0
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.

BIN
library/ix-dev/community/wordpress/charts/common-1.0.9.tgz


+ 10 - 0
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

+ 11 - 0
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

+ 10 - 0
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: []

+ 270 - 0
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.</br>
+                  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.</br>
+                  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.</br>
+                  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.</br>
+                        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

+ 1 - 0
library/ix-dev/community/wordpress/templates/NOTES.txt

@@ -0,0 +1 @@
+{{ include "ix.v1.common.lib.chart.notes" $ }}

+ 33 - 0
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 -}}

+ 50 - 0
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 -}}

+ 12 - 0
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 -}}

+ 106 - 0
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 -}}

+ 11 - 0
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" . -}}

+ 1 - 0
library/ix-dev/community/wordpress/upgrade_info.json

@@ -0,0 +1 @@
+{"filename": "values.yaml", "keys": ["image"]}

+ 31 - 0
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)))

+ 27 - 0
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: []