How I should solve this exercise: ``` Deployment cara is created. Expose port 8 . . .

Edith Puclla:
How I should solve this exercise:

Deployment cara is created. Expose port 80 of the deployment using NodePort on port 31888. Use cara as service name.

cara deployment already exist, and I am executing this command, to expose the deployment:

k expose deploy cara --port=80 --type=NodePort

But I am not sure where I should add “31888” this port. Any hint? :pray:

Edith Puclla:
should I change one of this port in the deployment?

Pod Template:
  Labels:  app=cara
  Containers:
   httpd:
    Image:        httpd
    Port:         80/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>

Tej_Singh_Rana:
Hello, @Edith Puclla
You have to specify that nodePort under the service.
Like below example:-

apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: NodePort
  selector:
    app: MyApp
  ports:
      # By default and for convenience, the `targetPort` is set to the same value as the `port` field.
    - port: 80
      targetPort: 80
      nodePort: 30007

Tej_Singh_Rana:
Reference:-
https://kubernetes.io/docs/concepts/services-networking/service/#nodeport

Edith Puclla:
Thank you @Tej_Singh_Rana :blush:

Madhan Kumar:
Use( --name cara) to specify the service name along with the expose command .

Edith Puclla:
I see, that could be my mistake too, thank you @Madhan Kumar

unnivkn:
if deployment name is cara then while doing expose --name is not mandatory. it will create service name same as the name of the deployment. If you need different service name then you can use --name=my-cara-service