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:
-
exposesupports simple use cases, for example, a deployment with a single service. See Section 5.1, “Exposing simple services on the service network” for instructions. -
service createandservice bindis a more flexible method of exposing services, for example, if you have multiple services for a deployment. See Section 5.2, “Exposing complex services on the service network” for instructions.
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
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.
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,httporhttp2
-
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
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.
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
-
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, orservice. -
<target-name>is the name of the cluster service -
--protocol <protocol>allows you specify the protocol you want to use,tcp,httporhttp2
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
-