https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.16/#container-v1-core にある
ports
List of ports to expose from the container. Exposing a port here gives the system additional information about the network connections a container uses, but is primarily informational. Not specifying a port here DOES NOT prevent that port from being exposed. Any port which is listening on the default "0.0.0.0" address inside a container will be accessible from the network. Cannot be updated.
の確認
$ kubectl apply -f test-ports.yaml
deployment.apps/test-ports created
service/test-ports created
$ kubectl get svc test-ports
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
test-ports ClusterIP 10.43.247.19 <none> 8081/TCP,8080/TCP 24s
$ curl 10.43.247.19:8080
8080 server
$ curl 10.43.247.19:8081
8081 server
確かに ports で開けてようがなかろうがアクセスできるみたい