December 2017
Intermediate to advanced
404 pages
9h 28m
English
Currently, we have four NGINX containers running, but no way to actually access them. This is where Services come into play. Create a new YAML file named nginx-service.yaml:
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
type: NodePort
selector:
app: nginx
ports:
- name: http
port: 80
Note that the spec.selector property matches the metadata.labels property that you have specified in the Deployment manifest. All Pods created by a Deployment controller will have a given set of labels (which are really just arbitrary key/value mappings). The spec.selector property of a Service now specifies which labels a Pod should have to be recognized by this Service. Also, note the type: NodePort property, which is going to be important ...
Read now
Unlock full access