No port defined service giving error

Hey @Inderpreet @rahul456 @akshayyw
I’ve assigned a task named “Deploy Apache Web Server on Kubernetes CLuster” where 3rd point is asking:

Create a service named as httpd-service-nautilus under same namespace to expose the deployment, nodePort should be 30004 .

I’ve created a service and getting the error:

thor@jump_host ~$ kubectl create -f web-service.yml --namespace httpd-namespace-nautilus
error: error validating “web-service.yml”: error validating data: ValidationError(Service.spec.ports[0]): missing required field “port” in io.k8s.api.core.v1.ServicePort; if you choose to ignore these errors, turn validation off with --validate=false

As per the question, the “port” field is not defined!

Is this incomplete?

Hello, @Ashu27
What is the image name? I think the default port is 80 for httpd

Hey @Tej-Singh-Rana, the image is httpd:latest and yes the by default port is 80.
But the “port” field is mandatory in service file where no value is given in the question.
Can I use “port:80” in service file?

Hello, @Ashu27
Yes, that’s mandatory field. It will not take any default values.

Yes, and after that verify with the curl command.