Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (12.7k points)
Hi, I am looking for a way to specify a custom NodePort port in a kubernetes service YAML definition? I need to define the port explicitly in my configuration file please help

1 Answer

0 votes
by (29.5k points)

Hi, yes there is a way to set custom ports for your service. You can do it through your configuration file you can refer the YAML file below for reference.

apiVersion: v1

kind: Service

metadata:

  name: nginx1

  labels:

    name: nginx1

spec:

  type: NodePort

  ports:

    - port: 80

      nodePort: 31221

      name: http

    - port: 443

      nodePort: 31221

      name: https

  selector:

    name: nginx1

You can check out more about YAML file creation in the attached tutorial

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...