apiVersion: apps/v1beta2 # for versions before 1.8.0 use apps/v1beta1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9 # replace it with your exactly <image_name:tags>
ports:
- containerPort: 80
---
apiVersion: v1 # for versions before 1.8.0 use apps/v1beta1
kind: Service
metadata:
name: my-service1 #TODO: to specify your service name
labels:
app: nginx
spec:
selector:
app: nginx #TODO: change label selector to match your backend pod
ports:
- protocol: TCP
name: http
port: 30080 #TODO: choose an unique port on each node to avoid port conflict
targetPort: 80
type: LoadBalancer ##本例中將type從Nodeport修改為LoadBalancer