From e0b1d129971d6c513227184e4536a19e8719d3bd Mon Sep 17 00:00:00 2001 From: DanielTamil Date: Mon, 4 Nov 2024 16:36:45 +0100 Subject: [PATCH 1/4] Enable dynamic config map --- charts/ibm-mq/templates/stateful-set.yaml | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/charts/ibm-mq/templates/stateful-set.yaml b/charts/ibm-mq/templates/stateful-set.yaml index 9215bda..7e926d1 100644 --- a/charts/ibm-mq/templates/stateful-set.yaml +++ b/charts/ibm-mq/templates/stateful-set.yaml @@ -137,6 +137,8 @@ spec: volumes: {{- else if .Values.web.manualConfig.secret.name }} volumes: + {{- else if .Values.queueManager.mqscDynamicConfigMaps }} + volumes: {{- end}} {{- if .Values.queueManager.multiinstance.enable }} - name: {{ $dataVolumeClaimName }} @@ -204,6 +206,23 @@ spec: {{- end }} {{- end }} {{- end }} + {{- if .Values.queueManager.mqscDynamicConfigMaps }} + - name: partner-configmaps + projected: + defaultMode: 511 + sources: + {{- range $index, $source := .Values.queueManager.mqscDynamicConfigMaps }} + {{- if $source.items }} + - configMap: + name: {{ $source.name }} + items: + {{- range $source.items }} + - key: {{ . }} + path: {{ . }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} {{- range $index, $source := .Values.queueManager.qminiConfigMaps }} {{- if $source.items }} - name: ini-cm-{{ $source.name }} @@ -370,6 +389,8 @@ spec: volumeMounts: {{- else if .Values.web.manualConfig.secret.name }} volumeMounts: + {{- else if .Values.queueManager.mqscDynamicConfigMaps }} + volumeMounts: {{- end}} {{- if .Values.queueManager.nativeha.tls }} {{- if .Values.queueManager.nativeha.tls.secretName }} @@ -402,6 +423,10 @@ spec: {{- end }} {{- end }} {{- end }} + {{- if .Values.queueManager.mqscDynamicConfigMaps }} + - name: partner-configmaps + mountPath: "/partner-configmaps" + {{- end }} {{- if .Values.queueManager.qminiConfigMaps }} {{- range $index, $source := .Values.queueManager.qminiConfigMaps }} {{- range $index, $item := $source.items }} From ab2ae8c32aa5844b09b5a406bd445e6ce121d90b Mon Sep 17 00:00:00 2001 From: DanielTamil Date: Mon, 4 Nov 2024 16:37:58 +0100 Subject: [PATCH 2/4] Add files via upload --- .../DynamicConfigMaps/dynamic-configmap.yaml | 7 + .../DynamicConfigMaps/dynamic-scripts.yaml | 57 +++++ .../DynamicConfigMaps/static-configmap.yaml | 7 + .../DynamicConfigMaps/values-sample.yaml | 222 ++++++++++++++++++ 4 files changed, 293 insertions(+) create mode 100644 charts/ibm-mq/templates/DynamicConfigMaps/dynamic-configmap.yaml create mode 100644 charts/ibm-mq/templates/DynamicConfigMaps/dynamic-scripts.yaml create mode 100644 charts/ibm-mq/templates/DynamicConfigMaps/static-configmap.yaml create mode 100644 charts/ibm-mq/templates/DynamicConfigMaps/values-sample.yaml diff --git a/charts/ibm-mq/templates/DynamicConfigMaps/dynamic-configmap.yaml b/charts/ibm-mq/templates/DynamicConfigMaps/dynamic-configmap.yaml new file mode 100644 index 0000000..803624e --- /dev/null +++ b/charts/ibm-mq/templates/DynamicConfigMaps/dynamic-configmap.yaml @@ -0,0 +1,7 @@ +kind: ConfigMap +apiVersion: v1 +metadata: + name: dynamic-configmap +data: + dynamic-configmap.mqsc: |- + DEFINE QLOCAL(TestQ1) REPLACE DESCR('TestQueue') DEFPSIST(YES) MAXMSGL(100000000) MAXDEPTH(1000000) \ No newline at end of file diff --git a/charts/ibm-mq/templates/DynamicConfigMaps/dynamic-scripts.yaml b/charts/ibm-mq/templates/DynamicConfigMaps/dynamic-scripts.yaml new file mode 100644 index 0000000..fe14a29 --- /dev/null +++ b/charts/ibm-mq/templates/DynamicConfigMaps/dynamic-scripts.yaml @@ -0,0 +1,57 @@ +kind: ConfigMap +apiVersion: v1 +metadata: + name: dynamic-scripts +data: + start-mqsc.sh: |- + #!/bin/bash + # + # Copyright 2023 IBM Corp. + # + # Licensed under the Apache License, Version 2.0 (the 'License'); + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + # + declare -A cksums + + # Outer loop that keeps the MQ service running + while true; do + for file in /partner-configmaps/*; do + if [ -f "$file" ]; then + tmpCksum=$(cksum "$file" 2>/dev/null | cut -d" " -f1) + + if [ "${cksums[$file]}" != "$tmpCksum" ]; then + cksums[$file]=$tmpCksum + echo "Applying MQSC for $file" + runmqsc $1 < "$file" + fi + fi + done + sleep 59 + done + stop-mqsc.sh: |- + #!/bin/bash + # + # Copyright 2023 IBM Corp. + # + # Licensed under the Apache License, Version 2.0 (the 'License'); + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + # + echo "done" \ No newline at end of file diff --git a/charts/ibm-mq/templates/DynamicConfigMaps/static-configmap.yaml b/charts/ibm-mq/templates/DynamicConfigMaps/static-configmap.yaml new file mode 100644 index 0000000..a98f074 --- /dev/null +++ b/charts/ibm-mq/templates/DynamicConfigMaps/static-configmap.yaml @@ -0,0 +1,7 @@ +kind: ConfigMap +apiVersion: v1 +metadata: + name: static-configmap +data: + static-configmap.mqsc: |- + DEFINE SERVICE(APPLY_MQSC) CONTROL(QMGR) SERVTYPE(SERVER) STARTCMD('/partner-configmaps/start-mqsc.sh') STARTARG(QM1) STOPCMD('/partner-configmaps/stop-mqsc.sh') STOPARG('') STDOUT('') STDERR('') REPLACE \ No newline at end of file diff --git a/charts/ibm-mq/templates/DynamicConfigMaps/values-sample.yaml b/charts/ibm-mq/templates/DynamicConfigMaps/values-sample.yaml new file mode 100644 index 0000000..99fc4d7 --- /dev/null +++ b/charts/ibm-mq/templates/DynamicConfigMaps/values-sample.yaml @@ -0,0 +1,222 @@ +# © Copyright IBM Corporation 2021, 2023 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# license must be set to "accept" to accept the terms of the IBM license +license: "not accepted" + +image: + # repository is the container repository to use + repository: icr.io/ibm-messaging/mq + # tag is the tag to use for the container repository + tag: 9.4.0.0-r3 + # pullSecret is the secret to use when pulling the image from a private registry + pullSecret: + # pullPolicy is either IfNotPresent or Always (https://kubernetes.io/docs/concepts/containers/images/) + pullPolicy: IfNotPresent + +# set passwords for users: "admin" and "app" +credentials: + # enabled is whether to configure user credentials via secret or not. (in MQ /run/secrets directory) + enable: false + # If enabled, provide the name of the secret that contains your user passwords. See adjacent README.md for instructions on how to create this Secret. + secret: "mq-credentials" + +# metadata allows setting of additional labels and annottations to be added to all resources. Set on helm install using --set metadata.labels.KEY=VALUE,metadata.labels.=VALUE,... +metadata: + labels: {} + annotations: {} + +# persistence section specifies persistence settings which apply to the whole chart +persistence: + + # dataPVC section specifies settings for the main Persistent Volume Claim, which is used for data in /var/mqm -> /mnt/mqm + dataPVC: + # enabled is whether to use this Persistent Volumes or not + enable: false + # name sets part of the name for this Persistent Volume Claim + name: "data" + ## size is the minimum size of the Persistent Volume + size: 2Gi + ## storageClass to use for this PVCs + storageClassName: "" + + # logPVC section specifies settings for the main Persistent Volume Claim, which is used for log in /mnt/mqm-log + logPVC: + # enabled is whether to use this Persistent Volumes or not + enable: false + # name sets part of the name for this Persistent Volume Claim + name: "log" + ## size is the minimum size of the Persistent Volume + size: 2Gi + ## storageClass to use for this PVCs + storageClassName: "" + + # dataPVC section specifies settings for the main Persistent Volume Claim, which is used for data in /mnt/mqm-data + qmPVC: + # enabled is whether to use this Persistent Volumes or not + enable: true + # name sets part of the name for this Persistent Volume Claim + name: "qm" + ## size is the minimum size of the Persistent Volume + size: 2Gi + ## storageClass to use for this PVCs + storageClassName: "" + + +resources: + limits: + cpu: 500m + memory: 1024Mi + requests: + cpu: 100m + memory: 512Mi + +security: + # context section specifies additional security context settings for the pod + context: + fsGroup: + supplementalGroups: [] + seccompProfile: + type: + # initVolumeAsRoot specifies whether or not storage provider requires root permissions to initialize + initVolumeAsRoot: false + runAsUser: + readOnlyRootFilesystem: false + +# queueManager section specifies settings for the MQ Queue Manager +queueManager: + # name allows you to specify the name to use for the queue manager. Defaults to the Helm release name. + name: + # nativeha specifies whether to run in nativeha mode with an active and two following container instances + nativeha: + enable: false + # multiinstance specifies whether to run in multiinstance mode with an active and one standby container instances + multiinstance: + enable: false + # Allows MQSC snippets to be loaded from static configMaps. These will be loaded into the running instance + mqscConfigMaps: + - name: static-configmap + items: + - static-configmap.mqsc + # Allows MQSC snippets to be loaded from Dynamic ConfigMaps. These will be loaded into the running instance + mqscDynamicConfigMaps: + - name: dynamic-scripts + items: + - start-mqsc.sh + - stop-mqsc.sh + + - name: dynamic-configmap + items: + - dynamic-configmap.mqsc + + + # Allows MQSC snippets to be loaded from secrets. These will be loaded into the running instance + mqscSecrets: [] + # Allows QM INI snippets to be loaded from configMaps. These will be loaded into the running instance + qminiConfigMaps: [] + # Allows QM INI snippets to be loaded from secrets. These will be loaded into the running instance + qminiSecrets: [] + # Enviroment variables to be associated with the queue manager containers + envVariables: [] + # The duration in seconds the Queue Manager needs to terminate gracefully, difference in time between SIGTERM and SIGKILL + terminationGracePeriodSeconds: 30 + # The stateful set updateStrategy policy + updateStrategy: RollingUpdate +# pki is used to supply certificates, that are stored in k8s secrets, for use with the webconsole and queue manager. +# Must be supplied as an array of yaml objects in the following format: +# - name: