Slide 25
Slide 25 text
Serviceのmanifest
25
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
type:ClusterIP # Serviceのtypeを指定する
selector:
app: nginx # app:nginxのラベルを持つPodにトラフィックを流す
ports:
- protocol: TCP
port: 80 # Serviceが公開するポート
targetPort: 80 # トラフィックを流す先のPodのポート
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3 # Podのレプリカ数
selector:
matchLabels: # app:nginxのラベルを持つPodを配下にする
app: nginx
template: # 作成するPodのテンプレート
metadata:
labels:
app: nginx # app:nginxのラベルをつける
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
↓のDeploymentに対するService
.spec.typeでServiceのtypeを
ClusterIP, NodePort, LoadBalancer, ExternalName
から選ぶ
.spec.selectorで対象のPodを選択する
.spec.portsでプロトコルやポートの設定を行う