Overview

Skill Level: Any Skill Level

This recipe explains about the following topics with respect to Cloud Pak for MCM

1. Defining application resources for MCM
2. Deploying MCM Application
3. Application Topology
4. Namespaces
5. Viewing created Resources
6. Resources yaml files

Ingredients

IBM Multicloud Manager 3.2.1

 

 

Step-by-step

  1. About Greetings Application

    In this receipe we are going to use Greetings application to deploy in IBM Multicloud Manager (MCM).

    Greetings and Weather are the 2 microservices available as images as part of this application.

    Normally we will have 4 Kubernetes resources  (2 services and 2 deployments) to deploy these microservices.

    But to deploy in MCM, we need few more MCM related resources. Let us see them in detail below.

     

    App

  2. Defining application resources for MCM

    The application component resources for IBM Multicloud Manager applications are defined in YAML files.

    We can categorize them as

    • ¬† Channel files
    • ¬† Application Resource files (normally bundled with Channel files)
    • ¬† Subscription files

     

    The below picture shows the list of files to be created.

    11-Resources-AllFiles

     

    1. Channel and Application files

    • channel.yaml contains a Kind called Channel.
    • deployable-greetings.yaml contains a Kind called Deployable.
      • It contains 2 deployable (1 Service and 1 Deployment).
      • This service and Deployment defines the Greetings Microservice.
      • This file contains both channel and application resources.
    • deployable-weather.yaml is similar to the above file. But it is for Weather Microservice.

     

    2. Subscription files

    • application.yaml contains a Kind called Application.
    • placement.yaml contains a Kind called PlacementRule.
    • subscription.yaml contains a Kind called Subscription.

     

    The detailed explanation of these files available as a separate step below.

    The source code is available in https://github.com/GandhiCloud/01-simple-mcm-greetings-app.git

     

  3. Deploying MCM Application

    Lets deploy the Greetings MCM application.

    1. Create Namespaces/Projects

    • Login to the MCM hub console.
    • Create the below namespaces
      • greetings-channel-ns
      • greetings-subscription-ns
      • greetings-app-ns

     

    2. Source code download

    • Download the source to some folder say /opt/mcm .

               The source code is available in https://github.com/GandhiCloud/01-simple-mcm-greetings-app.git

     

    3. Login to MCM hub from command line Window

    • Open the command/shell/terminal window
    • Goto the folder /opt/mcm/01-simple-mcm-greetings-app/greetings
    • Copy content from the configure client popup of the MCM hub console.
    • Paste the content into the terminal window
    • You might have logged into the MCM hub by now

     31-Hub-Login

     

    32-Hub-Login-popup 

     

    4. Deploy the app

    • Run the below command to install the application

              sh 11-install.sh

    In few seconds the application should have been installed. You can view the deployed application in the Applications screen.

  4. Application Topology

    Goto the Applications menu in the MCM console and click on the greetings application.

    41-AppTopo-1

    The Application topology screen appears. It contains details of the cluster, services, pods and etc created for that application.

    42-AppTopo-2

     

     

    43-AppTopo-3

     

     

    The pod status should be green afer few seconds. If it is not turing into green for more than few minutes.

     

    The logs screen shows pod-wise logs details.

    45-AppTopo-5

     

    44-AppTopo-4

  5. Accessing application

    Application can be accessed and viewed in the browser using the below urls.

     http://<<CLUSTER_IP>>:32421/

    http://<<CLUSTER_IP>>:32421/weather

    http://<<CLUSTER_IP>>:32422/

    http://<<CLUSTER_IP>>:32422/greetings

     

    51-GreetingsService

     

     51-GreetingsService-Greetings

     

     53-WeatherService54-WeatherService-weather

  6. Namespaces

    We have created 3 namespaces/projects in the MCM Hub. Though they can be created in single namespace, we have used 3 namespaces for better clarity.

    1. greetings-subscription-ns

      This namespace contains the subscription related resources like

    • ¬† Application
    • ¬† PlacementRule
    • ¬† Subscription

     

    2. greetings-channel-ns

      This namespace contains the channel related resources like

    • ¬† Channel
    • ¬† Deployable

     

    3. greetings-app-ns

      This namespace contains the application related resources like

    • ¬† Service
    • ¬† Deployment
    • ¬† Replicaset
    • ¬† POD
    • ¬† EndPoints

    Based on the placement rule, the target cluster is identified, the greetings-app-ns namespace is created and the corresponding resources are created.

  7. Viewing created Resources

    Search option is available to list all the resources created for this application.

    In the search box you can give app=greetings-app for the label, then all the resources created for this application will get listed.

    61-Search-1

     

    3 types of resources are created

    • Channel
    • Subscription
    • Application

     

    Channel Resources

    1. Channel

    This resource is created in hub

    65-Search-Channel

    2. Deployable

    These resources are created in hub

    Here 4  resources are created (2 services and 2 deployment).

    69-Search-Deployable

     

    Subscription Resources

    3. Application

    This resource is created in hub

    62-Search-Application

     

    4. Placement Rule

    This resource is created in hub

    70-Search-Placementrule

     

    5. Subscription

    This resource is created in hub (local cluster) with in the namespace greeting-susbscription-ns

    Also it is created in target cluster (ibmocpa) as a subscriped with in the namespace greeting-app-ns.

    68-Search-Subscription

     

    6. Application Resources

    The application related resources such as Deployment, Service, Pod, Replicaset and EndPoints are created.

    These resource are created in target cluster (ibmocpa).

     

    63-Search-Deployment

    66-SearchService64-Search-POD

    67-Search-EndPoints

    63-Search-Replicaset

  8. Resources yaml files

    The MCM resources files are explained in detail here.

    1. Channel

    1. Name of the Channel. This will be refered in subscription.
    2. Namespace indicates that the resource to be created in channel namespace
    3. Type of the channel repository is Namespace. The other channel repository types are HelmRepo and ObjectStore
    4. The location of the channel repository is the channel namespace (greetings-channel-ns).

    12-Resources-Channel

     

    2. Deployable (Deployment) (Greetings)

    1. Resource Type is Deployable.
    2. Namespace indicates that the resource to be created in channel namespace
    3. Always set is-local-deployable to false, so that by default the app will not get deployed in local cluster.
    4. This deployable wraps the Kind called Deployment
    5. Deployment contains the greetings image

    13-Resources-Deployable-Deployment-Greetings

     

    3. Deployable( Service) (Greetings)

    1. Resource Type is Deployable.
    2. Always set is-local-deployable to false, so that by default the app will not get deployed in local cluster..
    3. This deployable wraps the Kind called Service
    4. NodePort value is 32422
    5. Namespace indicates that the resource to be created in channel namespace

    14-Resources-Deployable-Service-Greetings

    4. Deployable (Deployment) (Weather)

    1. Resource Type is Deployable.
    2. Always set is-local-deployable to false, so that by default it will not deploy the app in local cluster.
    3. This deployable wraps the Kind called Deployment
    4. Deployment contains the weather image
    5. Namespace indicates that the resource to be created in channel namespace

       15-Resources-Deployable-Deployment-Weather

    5. Deployable( Service) (Weather)

    1. Resource Type is Deployable.
    2. Namespace indicates that the resource to be created in channel namespace
    3. Always set is-local-deployable to false, so that by default it will not deploy the app in local cluster.
    4. This deployable wraps the Kind called Service
    5. NodePort value is 32421

    16-Resources-Deployable-Service-Weather 

    6. Application

    1. Resource Type is Application.
    2. Namespace indicates that the resource to be created in subscription namespace

    17-Resources-Application

    7. Placement Rule

    1. Resource Type is Placement Rule.
    2. Namespace indicates that the resource to be created in subscription namespace
    3. The target cluster is name: ibmocpa

    18-Resources-PlacementRule

    8. Subscription

    1. Resource Type is Subscription.
    2. Namespace indicates that the resource to be created in subscription namespace
    3. Channel reference that links the Subscription to the Channel. The format is channel-namespace/channel-name.
    4. Placement rule that links the application to the selected cluster (name: ibmocpa)
    5. The namespace in which the application resources (Deployment/POD/Services/etc) to get created

     

    19-Resources-Subscription

  9. Other Operations

    Placement Rules

    • By modifying the placement Rule, you can move the application from one cluster to the other cluster
    • By changing the cluster replica you can deploy the application in other clusters.

    CICD

    • By modifying the resources in the Channel, the MCM will deploy the updated resources immediately in the appropriate cluster based on the Subscription.
  10. Appendix

    References

    https://www.ibm.com/support/knowledgecenter/en/SSFC4F_1.1.0/mcm/applications/overview.html

    https://github.ibm.com/IBMPrivateCloud/hybrid-cluster-manager-v2-chart/tree/master/3.2.1-examples/guestbook-kube-subscription-separate

    Troubleshooting

    1. If the topology screen shows the PODs in Orange color or if the application pods have not started then run the following command from the command line window to restart the endpoint-appmgr pod.

      oc delete -n multicluster-endpoint $(oc get pods -n multicluster-endpoint -o name | grep endpoint-appmgr)

Join The Discussion