concept multiple port in category kubernetes

appears as: multiple ports
Kubernetes in Action

This is an excerpt from Manning's book Kubernetes in Action.

Exposing multiple ports in the same service

Your service exposes only a single port, but services can also support multiple ports. For example, if your pods listened on two ports—let’s say 8080 for HTTP and 8443 for HTTPS—you could use a single service to forward both port 80 and 443 to the pod’s ports 8080 and 8443. You don’t need to create two different services in such cases. Using a single, multi-port service exposes all the service’s ports through a single cluster IP.

Listing 5.3. Specifying multiple ports in a service definition
apiVersion: v1
kind: Service
metadata:
  name: kubia
spec:
  ports:
  - name: http              #1
    port: 80                #1
    targetPort: 8080        #1
  - name: https             #2
    port: 443               #2
    targetPort: 8443        #2
  selector:                 #3
    app: kubia              #3
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest