...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
apiVersion: apps/v1 kind: Deployment metadata: name: coffee spec: replicas: 2 selector: matchLabels: app: coffee template: metadata: labels: app: coffee spec: containers: - name: coffee image: nginxdemos/nginx-hello:plain-text ports: - containerPort: 8080 --- apiVersion: v1 kind: Service metadata: name: coffee-svc labels: app: coffee spec: ports: - port: 80 targetPort: 8080 protocol: TCP name: http selector: app: coffee type: NodePort # <--- Pay attention --- apiVersion: apps/v1 kind: Deployment metadata: name: tea spec: replicas: 3 selector: matchLabels: app: tea template: metadata: labels: app: tea spec: containers: - name: tea image: nginxdemos/nginx-hello:plain-text ports: - containerPort: 8080 --- apiVersion: v1 kind: Service metadata: name: tea-svc labels: app: tea spec: ports: - port: 80 targetPort: 8080 protocol: TCP name: http selector: app: tea type: NodePort # <--- Pay attention |
We could verify the service using its CLUSTER-IP on Kubernetes master nodeFor a quick check, we can contact, for example with a curl
, the services at the address in the CLUSTER-IP
column. Note the system-generated values for the NodePorts of the two services (in this case 31156 and 30458).
...