Registering a service in Mesh

Before you create a connection policy, the service that is referenced in the policy must be registered in IBM® Hybrid Cloud Mesh. Run the kubectl expose deployment command to create the Kubernetes service object. When the Kubernetes service is successfully created, Mesh automatically discovers and registers the service.

About this task

The kubectl expose deployment command creates a service object in Kubernetes that allows traffic to reach the application that runs in the deployment. For more information and examples of how to use the kubectl expose command, see Expose a resource as a Kubernetes service.
Important: Using the kubectl expose command to expose resources other than deployments is not supported.

If the service is not already registered in Mesh, complete the following steps.

Procedure

  1. Run commands that are similar to the following examples to create the Kubernetes service object.
    In a Kubernetes environment:
    kubectl expose deployment <deployment-name> --port=<port-to-expose> --target-port=<port-exposed-by-app-pod>
    In an OpenShift® Container Platform environment:
    oc expose deployment <deployment-name> --port=<port-to-expose> --target-port=<port-exposed-by-app-pod>
    • <deployment-name> is the group of pods that are managed by the deployment.
    • <port-to-expose> is the port that applications can use to connect to the Kubernetes service.
    • <port-exposed-by-app-pod> is the port, inside the deployment, that the Kubernetes service routes traffic to.
    In the following example, the deployment my-deployment is exposed on port 80 of the Kubernetes service. Traffic is routed to port 30080 inside the deployment.
    kubectl expose deployment my-deployment --port=80 --target-port=30080

    When the Kubernetes service is successfully created, Mesh automatically discovers and registers the service.

  2. Check that the Kubernetes service is created by running commands like these. For OpenShift Container Platform environments, replace kubectl with oc.
    To see that the service was created successfully, list all the services:
    kubectl get services
    Get details about the service:
    kubectl describe services <service-name>
  3. Check that the service is registered in Mesh:
    1. Get the application name:
      palmctl get applications
    2. Get the Mesh service:
      palmctl get services --application-name <application-name> 
    Wait until the service is discovered and registered in Mesh before you create the connection policy.

What to do next

Create a connection policy. See Connecting applications by using policies in the Mesh console and Connecting applications by using policies with the Mesh CLI.