피드 구독

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.

infra-view

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.

  1. 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
  2. Create the required PlacementRules targeting clusters located in EU and US regions.

    # PlacementRule targeting EU region clusters
    oc --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 clusters
    oc --context hub create -f https://raw.githubusercontent.com/RHsyseng/acm-app-lifecycle-blog/master/acm-manifests/reversewords-region/02_placement_rule_US.yaml
  3. 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.yaml
    oc --context hub create -f https://raw.githubusercontent.com/RHsyseng/acm-app-lifecycle-blog/master/acm-manifests/reversewords-region/04_application-region.yaml
  4. 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   AGE
    deployment.extensions/reverse-words 1/1 1 1 4m39s

    NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
    service/reverse-words LoadBalancer 172.30.79.111 a3115b78bce924ddc885d2b7dab766a6-1199935412.eu-central-1.elb.amazonaws.com 8080:30254/TCP 4m39s

    NAME READY STATUS RESTARTS AGE
    pod/reverse-words-68795d69ff-xmwc6 1/1 Running 0 4m39s
  5. 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.

  1. 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
  2. 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   AGE
    deployment.extensions/reverse-words 1/1 1 1 92s

    NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
    service/reverse-words LoadBalancer 172.30.177.196 a90273a7fa3ea4015989fac522b6b36e-709976322.us-west-2.elb.amazonaws.com 8080:30375/TCP 2m33s

    NAME READY STATUS RESTARTS AGE
    pod/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.


저자 소개

UI_Icon-Red_Hat-Close-A-Black-RGB

채널별 검색

automation icon

오토메이션

기술, 팀, 인프라를 위한 IT 자동화 최신 동향

AI icon

인공지능

고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트

open hybrid cloud icon

오픈 하이브리드 클라우드

하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요

security icon

보안

환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보

edge icon

엣지 컴퓨팅

엣지에서의 운영을 단순화하는 플랫폼 업데이트

Infrastructure icon

인프라

세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보

application development icon

애플리케이션

복잡한 애플리케이션에 대한 솔루션 더 보기

Original series icon

오리지널 쇼

엔터프라이즈 기술 분야의 제작자와 리더가 전하는 흥미로운 스토리