How to handle multiple ports under the same container in kubernetes yaml file

6/26/2019

snippet inside docker-compose.yml

graphite:
  image: sitespeedio/graphite:1.1.5-3
  ports:
   - "2003:2003"
   - "8080:80"
  restart: always

current snippet inside kube.yml that needs changes

spec:
  containers:
  - name: graphite
    image: sitespeedio/graphite:1.1.5-3
    restartPolicy: Always
    ports:
    - containerPort: 2003

here, how to write the second mentioned - "8080:80" port in kubernetes yaml file?

-- Prashanth Sams
kubernetes

1 Answer

6/26/2019
spec:
  containers:
  - name: graphite
    image: sitespeedio/graphite:1.1.5-3
    restartPolicy: Always
    ports:
    - containerPort: 2003
      name: graphite_two 
    - containerPort: 8080
      name: graphite_one 

will solve your issue.

kubectl explain pods.spec.containers.ports provides the detail information about the keys and values

-- Suresh Vishnoi
Source: StackOverflow