Nginx アプリケーションのサンプルオーケストレーションは、以下のようになります。 オーケストレーションは 、Container Service でビルドされたオーケストレーションテンプレートをベースにしています。
このオーケストレーションテンプレートを使用することで、Nginx アプリケーションに属するデプロイを迅速に作成できます。
注 Container Service は、Kubernetes YAML オーケストレーションをサポートします。このオーケストレーションでは、 --- 記号を使用してリソースオブジェクトを分離できます。これにより、1 つのテンプレートから複数のリソースオブジェクトを作成できます。
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 ##In this example, change the type from NodePort to LoadBalancer.