A common practice is to deploy a new version of an application to a small subset of the available clusters. Using Kustomize again we will modify the pacman image and then promote that image to be running on all clusters.
Ensure that the pacman application is still running in all 3 clusters.
# The for loop will output the `deployment`in the three clusters
for cluster in cluster1 cluster2 cluster3;do echo "*** $cluster ***"; oc get deployment --context $cluster -n pacman;done
*** cluster1 ***
NAME READY UP-TO-DATE AVAILABLE AGE
pacman 1/1 1 1 6m21s
*** cluster2 ***
NAME READY UP-TO-DATE AVAILABLE AGE
pacman 1/1 1 1 6m21s
*** cluster3 ***
NAME READY UP-TO-DATE AVAILABLE AGE
pacman 1/1 1 1 6m21s
We would first like to ensure that cluster3 has the new container image configured. To do this we will modify the file ~/rhacmgitopslab/lab-7-assets/overlays/cluster3/pacman-deployment.yaml
. This lab will use the same directories that were used in lab 7.
NOTE: We are changing the image used by the
pacman
deployment
# Change the directory
cd ~/rhacmgitopslab/lab-7-assets/overlays/cluster3
# Modify the `pacman-deployment.yaml`
cat > pacman-deployment.yaml <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
name: pacman
name: pacman
namespace: pacman
spec:
replicas: 1
template:
metadata:
labels:
name: pacman
spec:
serviceAccount: pacman
containers:
- image: quay.io/mavazque/pacman:latest
name: pacman
EOF
Commit the changes to the repository so that RHACM can make the changes.
# Stage your changes to be sent to the git repository
git commit -am 'Update pacman container image for Cluster3'
# Push your commits to the git repository
git push origin master
NOTE: By default, a GitHub channel subscription clones the GitHub repository specified in the channel every minute and applies changes when the commit ID has changed. Alternatively, you can configure your subscription to apply changes only when the GitHub repository sends repo PUSH and PULL webhook event notifications.
Validate that the image successfully deployed. You should see the out of quay.io/mavazque/pacman:latest
.
oc get deployment --context cluster3 -n pacman pacman -o=jsonpath="{$.spec.template.spec.containers[:1].image}{\"\n\"}"
Because we know that the application deploys and passes startup procedures successfully then we know we can supply the image to the other clusters.
# Change directories
cd ~/rhacmgithub/lab-7-assets/base
# Modify the image used by the `pacman-deployment.yaml`
sed -i 's~quay.io/ifont/pacman-nodejs-app:latest~quay.io/mavazque/pacman:latest~g' pacman-deployment.yaml
Before committing the code to the git repository and deploying the code. We need to set cluster3's application deployment back to the original values since the image will be defined from the base directory now.
# Change directories
cd ~/rhacmgitopslab/lab-7-assets/
# Remove the cluster3 `pacman-deployment.yaml`
rm -rf overlays/cluster3/pacman-deployment.yaml
# Copy the `pacman-deployment.yaml` from cluster1 to cluster3
cp overlays/cluster1/pacman-deployment.yaml overlays/cluster3/pacman-deployment.yaml
Now we will submit the changes to our git repo which should deploy the new image to all clusters.
# Stage your changes to be sent to the git repository
git commit -am 'new image to all clusters'
# Push your commits to the git repository
git push origin master
RHACM will push new pacman image in all three clusters.
Verify the image deployed is our newest pacman image.
# The for loop will output the image being used by each cluster for the pacman application
for cluster in cluster1 cluster2 cluster3;do echo "$cluster "; oc get deployment --context $cluster -n pacman pacman -o=jsonpath='{$.spec.template.spec.containers[:1].image}'; echo "";done
cluster1
quay.io/mavazque/pacman:latest
cluster2
quay.io/mavazque/pacman:latest
cluster3
quay.io/mavazque/pacman:latest
Of course now point to your pacman url and check if everything is working!
oc --context=hubcluster -n haproxy-lb get route haproxy-lb -o jsonpath="{.status.ingress[*].host}{\"\n\"}"
e.g: pacman-multicluster.apps.cluster-b5b7.b5b7.sandbox362.opentlc.com