selector : : # selector for the target pods. The service can be accessed from outside via your host node. apiVersion : v1 kind : Service metadata : name : namespace : spec : type : NodePort # the NodePort service type. ports : - protocol : # the protocol the service uses, e.g., TCP port : # the port exposed to the cluster, e.g., 80 targetPort : # the port requests are sent to in the pod, e.g., 9736 # NodePort Service.
ClusterIP service is only accessible from within the cluster. apiVersion : v1 kind : Service metadata : name : namespace : spec : type : ClusterIP # the ClusterIP service type. For any namespaced resource, the command has to be appended with -n.Either the resource kind or the short name can be used as in the following commands in this page.