Skip to content

Commit

Permalink
Merge pull request #47 from ibm-messaging/9.3.3
Browse files Browse the repository at this point in the history
Updates for 9.3.3 and sample for K8s upgrade PDB
  • Loading branch information
callumpjackson authored Jun 19, 2023
2 parents cc8b1e9 + 7b1f0dd commit 3499057
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IBM MQ Sample Helm Chart
This repository provides a helm chart to deploy an IBM® MQ container built from the [IBM MQ Container GitHub repository](https://github.com/ibm-messaging/mq-container), and has been verified against the [9.3.2 branch](https://github.com/ibm-messaging/mq-container/tree/9.3.2).
This repository provides a helm chart to deploy an IBM® MQ container built from the [IBM MQ Container GitHub repository](https://github.com/ibm-messaging/mq-container), and has been verified against the [9.3.3 branch](https://github.com/ibm-messaging/mq-container/tree/9.3.3).

## Pre-reqs
Prior to using the Helm chart you will need to install two dependencies:
Expand Down
4 changes: 2 additions & 2 deletions charts/ibm-mq/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
apiVersion: v2
name: ibm-mq
description: IBM MQ queue manager
version: 6.0.0
version: 7.0.0
type: application
appVersion: 9.3.2.0
appVersion: 9.3.3.0
kubeVersion: ">=1.18.0-0"
keywords:
- IBM MQ
Expand Down
39 changes: 28 additions & 11 deletions charts/ibm-mq/README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion charts/ibm-mq/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ 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.3.2.0-r1
tag: 9.3.3.0-r1
# 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/)
Expand Down
2 changes: 1 addition & 1 deletion samples/OpenShiftIBMPower/deploy/ibmpower.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
license: accept
image:
repository: cp.icr.io/cp/ibm-mqadvanced-server
tag: 9.3.2.0-r1-ppc64le
tag: 9.3.3.0-r1-ppc64le
pullSecret: ibm-entitlement-key
queueManager:
mqscConfigMaps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
image:
repository: cp.icr.io/cp/ibm-mqadvanced-server
tag: 9.3.2.0-r1-amd64
tag: 9.3.3.0-r1-amd64
pullSecret: ibm-entitlement-key
license: accept
queueManager:
Expand Down
95 changes: 95 additions & 0 deletions samples/genericresources/kubernetesupgrade/drainMQContainers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/bin/bash
# © Copyright IBM Corporation 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.

NAMESPACE=${1:-"default"}
DEBUG=true

function line_separator () {
echo "####################### $1 #######################"
}

function checkForUnschedulableNodes() {
line_separator "Checking for unschedulable nodes"
UNSCHEDULED_NODE_STRING=$(kubectl get nodes -o=jsonpath='{.items[?(@.spec.unschedulable==true)].metadata.name}')
if [ -z "$UNSCHEDULED_NODE_STRING" ]
then
$DEBUG && echo "[DEBUG] No nodes found"
NODE_ARRAY=''
return
else
$DEBUG && echo "[DEBUG] Found these nodes '$UNSCHEDULED_NODE_STRING'"
NODE_ARRAY=("$UNSCHEDULED_NODE_STRING")
fi
}

function findMQPodsOnNode(){
TARGET_NODE=$1
line_separator "Finding MQ Pods on $TARGET_NODE"
MQ_PODS=$(kubectl get pods --field-selector spec.nodeName="$TARGET_NODE" -n "$NAMESPACE" -l app.kubernetes.io/name=ibm-mq -o jsonpath='{.items[*].metadata.name}')
if [ -z "$MQ_PODS" ]
then
$DEBUG && echo "[DEBUG] No MQ pods found"
return
else
$DEBUG && echo "[DEBUG] Found these pods '$MQ_PODS'"
DELETE_POD=false
MQ_PODS_ARRAY=("$MQ_PODS")
for i in "${MQ_PODS_ARRAY[@]}"
do
$DEBUG && echo "[DEBUG] Checking if '$i' has quorum"
QMGR_STATUS=$(kubectl exec "$i" -n "$NAMESPACE" -- dspmq -o nativeha)
QUORUM_STATUS=${QMGR_STATUS#*QUORUM(}
RUNNING_CONTAINERS=${QUORUM_STATUS%%/*}
$DEBUG && echo "[DEBUG] '$i' has a quorum status of '$RUNNING_CONTAINERS'"
QMGR_CONNECTIONS=$(kubectl exec "$i" -n "$NAMESPACE" -- dspmq -o nativeha -x | grep -c "CONNACTV(yes)" )
$DEBUG && echo "[DEBUG] '$i' has active connections to '$QMGR_CONNECTIONS' instances"
if [ "$RUNNING_CONTAINERS" -eq 3 ] && [ "$QMGR_CONNECTIONS" -eq 3 ]
then
$DEBUG && echo "[DEBUG] Queue Manager has $RUNNING_CONTAINERS containers so safe to delete one instance"
DELETE_RESPONSE=$(kubectl delete pod "$i" -n "$NAMESPACE")
$DEBUG && echo "[DEBUG] Pod delete response: $DELETE_RESPONSE"
DELETE_POD=true
else
$DEBUG && echo "[DEBUG] Unsafe to delete Pod - doing nothing and will auto-retry during the next loop"
fi
done
fi

if [ $DELETE_POD = "true" ]
then
$DEBUG && echo "[DEBUG] Deleted pods on worker node so sleeping for 10 seconds for quorum status to correct"
sleep 10
else
$DEBUG && echo "[DEBUG] No pods deleted"
fi
}

while true
do
echo ""
line_separator "Starting check"

checkForUnschedulableNodes
if [ -n "$NODE_ARRAY" ]
then
for node_item in "${NODE_ARRAY[@]}"
do
$DEBUG && echo "[DEBUG] Processing node '$node_item'"
findMQPodsOnNode "$node_item"
done
fi
echo ""
sleep 30
done
23 changes: 23 additions & 0 deletions samples/genericresources/kubernetesupgrade/mqnativeha-pdb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# © Copyright IBM Corporation 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.
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: mqnativeha-pdb
spec:
maxUnavailable: 1
selector:
matchLabels:
app.kubernetes.io/instance: secureapphelm
app.kubernetes.io/name: ibm-mq

0 comments on commit 3499057

Please sign in to comment.