Chapter 5. Exposing services on the service network from a namespace

After creating a service network, exposed services can communicate across that network.

The skupper CLI has two options for exposing services that already exist in a namespace:

5.1. Exposing simple services on the service network

This section describes how services can be enabled for a service network for simple use cases.

Procedure

  1. Create a deployment, some pods, or a service in one of your sites, for example to create the backend service for the tutorial:

    $ kubectl create deployment hello-world-backend --image quay.io/skupper/hello-world-backend

    This step is not Application Interconnect-specific, that is, this process is unchanged from standard processes for your cluster.

  2. Create a service that can communicate on the service network:

    $ skupper expose [deployment <name>|pods <selector>|statefulset <statefulsetname>|service <name>]

    where

    • <name> is the name of your deployment
    • <selector> is a pod selector
    • <statefulsetname> is the name of a statefulset

    For the example deployment in step 1, you create a service using the following command:

    $ skupper expose deployment/hello-world-backend --port 8080

    Options for this command include:

    • --port <port-number>:: Specify the port number that this service is available on the service network. NOTE: You can specify more than one port by repeating this option.
    • --target-port <port-number>:: Specify the port number of pods that you want to expose.
    • --protocol <protocol> allows you specify the protocol you want to use, tcp, http or http2
Note

If you do not specify ports, skupper uses the containerPort value of the deployment.

5.2. Exposing complex services on the service network

This section describes how services can be enabled for a service network for more complex use cases.

Procedure

  1. Create a deployment, some pods, or a service in one of your sites, for example to create the backend service for the tutorial:

    $ kubectl create deployment hello-world-backend --image quay.io/skupper/hello-world-backend

    This step is not Application Interconnect-specific, that is, this process is unchanged from standard processes for your cluster.

  2. Create a service that can communicate on the service network:

    $ skupper service create <name> <port>

    where

    • <name> is the name of the service you want to create
    • <port> is the port the service uses

    For the example deployment in step 1, you create a service using the following command:

    $ skupper service create hello-world-backend 8080
  3. Bind the service to a cluster service:

    $ skupper service bind <service-name> <target-type> <target-name>

    where

    • <service-name> is the name of the service on the service network
    • <target-type> is the object you want to expose, deployment, statefulset, pods, or service.
    • <target-name> is the name of the cluster service
    • --protocol <protocol> allows you specify the protocol you want to use, tcp, http or http2

    For the example deployment in step 1, you bind the service using the following command:

    $ skupper service bind hello-world-backend deployment hello-world-backend