v1 · Cluster Resource
Service
Service is a named abstraction of software service (for example, mysql) consisting of local port (for example 3306) that the proxy listens on, and the selector that determines which pods will answer requests sent through the proxy.
Click on Property Name to see the description, and Pink Types to expand schema.
Looking for some examples?
There are 3 examples of Service that you can use as a starting point to create your own.
apiVersion: v1 kind: Service metadata: name: my-loadbalancer-service namespace: default # Service is a namespaced resource spec: type: LoadBalancer selector: app: my-app ports: - port: 80 # port that will be externally exposed on the load balancer targetPort: 8080 # pod's port for internal routing - port: 443 # port that will be externally exposed on the load balancer targetPort: 8443 # pod's port for internal routing
apiVersion: v1
kind: Service
metadata:
name: my-nodeport-service
namespace: default # Service is a namespaced resource
spec:
type: NodePort
selector:
app: my-app
ports:
- port: 80 # the internal port of the service that can be reached from inside the cluster
nodePort: 30000 # port that will be externally exposed on each node
targetPort: 8080 # pod's port for internal routing
apiVersion: v1
kind: Service
metadata:
name: my-clusterip-service
namespace: default # Service is a namespaced resource
spec:
type: ClusterIP # this is the default, but it's good to be explicit!
selector:
app: my-app
ports:
- port: 80 # the internal port of the service that can be reached from inside the cluster
targetPort: 8080 # pod's port for internal routing