May 2018
Intermediate to advanced
554 pages
13h 51m
English
Let's create a LoadBalancer Service with Pods underneath, which is what we learned in Chapter 3, Playing with Containers:
# cat aws-service.yamlapiVersion: apps/v1kind: Deploymentmetadata: name: nginxspec: replicas: 3 selector: matchLabels: run: nginx template: metadata: labels: run: nginx spec: containers: - image: nginx name: nginx ports: - containerPort: 80---apiVersion: v1kind: Servicemetadata: name: nginxspec: ports: - port: 80 targetPort: 80 type: LoadBalancer selector: run: nginx
In the preceding template, we declared one nginx Pod and associated it with the LoadBalancer service. The service will direct the packet to container port 80:
# kubectl create -f aws-service.yaml deployment.apps ...
Read now
Unlock full access