一、使用Deployment启动3个Pod
apiVersion: apps/v1
kind: Deployment
metadata:
name: deployment-nginx-raven
namespace: raven
labels:
app: deployment-nginx-raven
spec:
selector:
matchLabels:
appt: raven-nginx
replicas: 3
template: # 定义 Pod
metadata:
labels:
appt: raven-nginx
spec:
containers:
- name: raven-nginx-container
image: nginx:1.16.1
- 启动Pod标签为 appt: raven-nginx
二、Service-yaml
apiVersion: v1
kind: Service
metadata:
name: svc-02
namespace: raven
spec:
selector:
appt: raven-nginx
type: ClusterIP
clusterIP: None
ports:
- name: http
protocol: TCP
port: 80
targetPort: 80
无头Service.png
-
通过访问服务名来访问集群
image.png
网友评论