apiVersion: v1
kind: Service
metadata:
name: mongodb-service
spec:
selector:
app: mongodb
ports:
- protocol: TCP
port: 27017
targetPort: 27017
Note: selector
will be used to find the corresponding labels
defined in 202202181227 to connect 202201311630.
Note: port
is the port that Service is listen to.
Note: For LoadBalancer
, nodePort
should be defined.