Service is an abstract way to expose your application running on a set of Pods. This one is a manifest for creating a service
, here targetPort: 8080
is the pod port. In this manifest there are basically two parts, one is metadata
which gives the service name and also give it a label. Then the spec
part, which is short form of specification, it basically the specification of the service, here the selector
is given, and also the ports are specified here, port
represents the service port, targetPort
represents the port on which the service will send requests. By nodePort
the outside world (from outside the cluster) can communicate to the service, and finally type
represents the type of the service. If the type = NodePort
then it is basically means from outside the cluster the service will expose a port (nodePort
).
apiVersion: v1
kind: Service
metadata:
name: apiserver-service
labels:
app: apiserver
spec:
selector:
app: apiserver
ports:
- protocol: TCP
port: 8080
targetPort: 8080
nodePort: 30005
type: NodePort
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…