Overview

Skill Level: Any Skill Level

This recipe explains about the following.

1. Configuring DNS in Managed Cluster for Service Discovery
2. Installing a sample application
3. Required Kubernetes objects changes for Service Discovery

Ingredients


IBM Cloud Pak for Multicloud Management 1.3.0 (MCM Hub)
Redhat Openshift Container Plantform 4.3 (Managed Clusters)


Note:

The files refered in this recipe is available in github.com at the below location.

https://github.com/GandhiCloudLab/service-discovery-mcm-130-ocp43/tree/master/deployment/src
https://github.com/GandhiCloudLab/service-discovery-mcm-130-ocp43/tree/master/files

Step-by-step

  1. Cluster and App Details

    Here the MCM Hub cluster is connected with 2 managed clusters d and e. Both the managed clusters are installed with Redhat Openshift Container Platform 4.3.

     

    01-clusters

     

    The App contains 2 services called frontend and catalog. The frontend service deployed in Cluster d and it is going to call catalog service in that is deployed in Cluster e.

     

    02-cluster-app

  2. Configure DNS in Managed Cluster

    Need to configure DNS in the Managed Cluster.

    The Knowledge Center page has the detailed explanation about how to do it. https://www.ibm.com/support/knowledgecenter/SSFC4F_1.3.0/mcm/services/mcm_serv_prep.html. But for RHOCP it is little different and it is explained here.

    Do the followings steps in each of your managed cluster.

     

    1. Get Service Registry IP Address of the managed cluster

    Run the below command.

    kubectl get -n multicluster-endpoint service mcm-svc-registry-dns -o jsonpath='{.spec.clusterIP}’

    You will get the service registry IP printed.

     

    2. Update dns.operator/default

    a. Run the below command to edit the dns.operator

    oc edit dns.operator/default

    b. Add the below information under the spec and save. Here << service registry IP>> is the output that we got in the above step.

    servers:
    – forwardPlugin:
    upstreams:
    – << service registry IP>>
    name: mcm-server
    zones:
    – mcm.svc

    The result would be like this.

    11-operator-dns

     

    3. Viewing Configmap dns-default

    The dns-default configmap would have been created automatically. Run the below command to see the config map.

    kubectl get -n openshift-dns configmap dns-default -o yaml

    The output could be like this.

    12-dns-configmap

     

    4. Viewing Configmap endpoint-svcreg-coredns
    The endpoint-svcreg-coredns configmap also would have been created automatically. Run the below command to see the config map.

    kubectl get -n multicluster-endpoint configmap endpoint-svcreg-coredns -o yaml

    The output could be like this.

    13-configmap-endpoint-svcreg-coredns

     

    5. Viewing Service mcm-svc-registry-dns
    Run the below command to see service.

    oc describe svc mcm-svc-registry-dns -n multicluster-endpoint

    The output could be like this. Here the endpoints for the mentioned service would be empty. This is a problem in RHOCP 4.3 version of MCM. This should be solved and next step does that.

    14-dns-without-endpoints

     

    6. Create workaround service

    a) Run the below command to create a workaround service that will get created with appropriate endpoints.
    oc apply -f /files/svc.yaml

    The svc.yaml file looks like this.

    15-workaround-service

    b) Run the below command to see the above created workaround service with appropriate endpoints.
    oc describe -n multicluster-endpoint service mcm-svc-registry-test

    The output could be like this.

    16-dns-with-endpoints-1

    Now this managed cluster is ready for the service discovery.

    You can repeat the same to other managed clusters if any.

  3. Installing Sample App

    As we have already mentioned, app contains 2 services called frontend and catalog. The frontend service deployed in Cluster d and it is going to call catalog service in that is deployed in Cluster e.

     02-cluster-app

     ———————– ———————– ———————– ———————– ———————————————————————
    Installing the App in Hub
     
    1. Login into MCM hub
    Login to mcm hub in the command line window using the command like this.

    oc login …………….

     
    2. Goto the install folder
    Goto the /deployment/install/ folder

     
    3. Install namespace
    Run the below command.

    sh 01-install-namespace.sh

     
    4. Install app
    Run the below command.

    sh 02-install-app.sh

    ———————– ———————– ———————– ———————– ———————————————————————
    Viewing the installed app
     
    a. Application topology view at MCM Hub
    It contains the cluster d and e. As planned cluster d contains frontweb service and cluster e contains catalog service.

     61-App-Topology

     

    b. Frontweb pod in cluster d

    62-ClusterD-pod 

    c. Frontweb service in cluster d

    63-ClusterD-services

     64-ClusterD-services2

     
    d. Frontweb routes in cluster d

     65-ClusterD-routes

     

    e. ConfigMap endpoint-svcreg-coredns in cluster d
    The DNS we confitured in the previous steps.

    70-clusterE-coredns1 71-clusterE-coredns2

     The same entry would exists in cluster e as well.

     

    6. Catalog pod in cluster e

    68-ClusterE-pod-2

     

    7. Catalog service in cluster e

    69-ClusterE-services

     

    8. ConfigMap endpoint-svcreg-coredns in cluster d
    It is same in all the cluters.

    70-clusterE-coredns1 71-clusterE-coredns2

     

    ———————– ———————– ———————– ———————– ———————————————————————

    Run the installed app

    a) Goto the Routes Page in cluster d. Click on the route.

     

    65-ClusterD-routes

    It should open a application home page.

     

     

    75-app-home

    Click on the View Catalog Name link, it will show the below output.

     

     

    76-app-resultNow the FrontWeb service in Cluster d has called Catalog Service in Cluster e successfully.

  4. Detailed view of Kubernetes Resources

    The files mentioned here are available under the deployment/src folder in this repo.

     
    1. Catalog Deployment
    This is a typical Deployable MCM resource for Catalog service. It contains Deployment Kubernetes resource inside.

    Line No. 35: Container image

     80-catalog-deployment

     
    2. Catalog Service
    This is a typical Deployable MCM resource for Catalog service. It contains Service Kubernetes resource inside.

    Line No. 56: The annodation mcm.ibm.com/service-discovery: “{}” to be added

    Line No. 61: The Type should be LoadBalancer

     81-catalog-service

     
    3. Frontweb Deployment
    This is a typical Deployable MCM resource for FrontWeb service. It contains Deployment Kubernetes resource inside.

    Line No. 35: Container image

    Line No. 38, 41: Service Discovery url to call Catalog service is passed from configmap.

    Line No. 43: Dependencies is declared here. Here FrontWeb is depend on Catalog service.

    Line No. 47: Placement is declared here. It means that the FrontWeb to be deployed in cluster d

     82-frontweb-deployment

     
    4. Configmap
    This configmap is deployed in clusters d. The properties form this configmap is used in FrontWeb service.

    Line No. 23: URL mentioned here is the URL to discover the Catalog service from the FrontWeb` service.

    The format is ServiceName.Namespace.mcm.svc. In this sample app the url is http://service-discovery3-catalog-service.service-discovery3-app-ns.mcm.svc:9090

     84-configmap

     
    5. Channel
    The typical Channel resource for MCM.

     90-channel

     
    6. Placement
    Placement rules defining the clusters d and e.

     91-placement

     
    7. Subscription
    Subscriptions connecting the kubernetes resources Deployment, Services and Routes defined for clusters d and e.

     92-subscription

     
    8. Namespace
    The namespace service-discovery3-chn-ns would be created in MCM Hub, to store the all the Channel, app and subscription related MCM Specific informations.

    The namespace service-discovery3-app-ns would be created in MCM Hub and in Managed Clusters, to store app related Kubernetics specific information.

    93-namespace

Join The Discussion