Red Hat Posted September 30, 2020 Share Posted September 30, 2020 In the first blog posts of this series, we introduced the basic concepts for Application Lifecycle on Red Hat Advanced Cluster Management and deployed an application to multiple clusters. In the second blog post, we showed how a Blue/Green deployment can be made using Red Hat Advanced Cluster Management. If you haven't read the previous blog posts yet, go ahead and read them. This post is a continuation and you will need the context from the previous ones. We are using the same infrastructure we used in the previous posts. See the following diagram: NOTE: Pay special attention to the different labels, as they will be used during the blog posts examples. Component Version Red Hat OpenShift Container Platform 4.5.7 Red Hat Advanced Cluster Management 2.0 Fix Pack 2.0.2 Application Migration on Advanced Cluster Management In the previous post we upgraded the version of our application in Development and Production clusters using Blue/Green deployment technique. Now, we are going to explore how Red Hat Advanced Cluster Management enables us to seamlessly move our applications between our different clusters. Creating new PlacementRules and Subscription We will create two new PlacementRules targeting clusters in the EU region and US region respectively. Additionally, a new Subscription will be used to deploy our reverse-words application in the region we want the application to run on. Create a new Namespace to store the required manifests. oc --context hub create -f https://raw.githubusercontent.com/RHsyseng/acm-app-lifecycle-blog/master/acm-manifests/reversewords-region/00_namespace.yaml Create the required PlacementRules targeting clusters located in EU and US regions. # PlacementRule targeting EU region clustersoc --context hub create -f https://raw.githubusercontent.com/RHsyseng/acm-app-lifecycle-blog/master/acm-manifests/reversewords-region/01_placement_rule_EU.yaml# PlacementRule targeting US region clustersoc --context hub create -f https://raw.githubusercontent.com/RHsyseng/acm-app-lifecycle-blog/master/acm-manifests/reversewords-region/02_placement_rule_US.yaml Create the Subscription and Application. NOTE: The Subscription is currently configured to deploy the application using the PlacementRule matching clusters in EU region. oc --context hub create -f https://raw.githubusercontent.com/RHsyseng/acm-app-lifecycle-blog/master/acm-manifests/reversewords-region/03_subscription-region.yamloc --context hub create -f https://raw.githubusercontent.com/RHsyseng/acm-app-lifecycle-blog/master/acm-manifests/reversewords-region/04_application-region.yaml Now, we should see our application running in the cluster located in EU (which is our Development cluster). oc --context dev -n reverse-words-region get deployments,services,pods NAME READY UP-TO-DATE AVAILABLE AGEdeployment.extensions/reverse-words 1/1 1 1 4m39sNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEservice/reverse-words LoadBalancer 172.30.79.111 a3115b78bce924ddc885d2b7dab766a6-1199935412.eu-central-1.elb.amazonaws.com 8080:30254/TCP 4m39sNAME READY STATUS RESTARTS AGEpod/reverse-words-68795d69ff-xmwc6 1/1 Running 0 4m39s Run the same query against the cluster located in US (Production cluster). See that we don't have any pods running. oc --context pro -n reverse-words-region get deployments,services,pods No resources found in reverse-words-region namespace. Migrating our Application Let's say that due to some law enforcement, our application cannot run on EU servers anymore and we need to move it to US-based servers. We can do that with a single command. If you remember, we created two PlacementRules, one matching EU servers and another matching US servers. We will patch our Subscription so it stops using EU based servers PlacementRule and starts using US based servers PlacementRule. Changing the PlacementRule used by our Subscription will move our application from one region to the other automatically. Patch the Subscription. The following patch updates the PlacementRule used by the Subscription to us-region-clusters. oc --context hub -n reverse-words-region patch subscription.apps.open-cluster-management.io/reversewords-region-app-subscription -p '{"spec":{"placement":{"placementRef":{"name":"us-region-clusters"}}}}' --type=merge Our application will be moved from EU cluster to US cluster automatically. See the commands and outputs: The application will not run on EU (development cluster) anymore. oc --context dev -n reverse-words-region get deployments,services,pods No resources found in reverse-words-region namespace. The application will be running on US (production cluster) now. oc --context pro -n reverse-words-region get deployments,services,pods NAME READY UP-TO-DATE AVAILABLE AGEdeployment.extensions/reverse-words 1/1 1 1 92sNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEservice/reverse-words LoadBalancer 172.30.177.196 a90273a7fa3ea4015989fac522b6b36e-709976322.us-west-2.elb.amazonaws.com 8080:30375/TCP 2m33sNAME READY STATUS RESTARTS AGEpod/reverse-words-68795d69ff-jlktw 1/1 Running 0 92s As you just saw, by using PlacementRules you can migrate your applications between clusters easily. We just used a region-based PlacementRule, but the PlacementRule can be based on any labels configured on your clusters. What's next In the next blog post of this series we will be demonstrating how Red Hat Advanced Cluster Management can help us in a Disaster Recovery scenario. View the full article Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.