k8s部署nginx简单版
详细的yam文件如下:## cat nginx.yamlapiVersion: apps/v1kind: Deploymentmetadata:name: nginxspec:replicas: 2selector:matchLabels:name: nginxtemplate:metadata:labels:...
·
一、详细的yaml文件如下:
## cat nginx.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 2
selector:
matchLabels:
name: nginx
template:
metadata:
labels:
name: nginx
spec:
containers:
- name: nginx
image: nginx:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
ports:
- port: 80
targetPort: 80
protocol: TCP
type: NodePort
selector:
name: nginx
二、应用以上yaml文件
kubectl apply -f nginx.yaml
更多推荐
已为社区贡献45条内容
所有评论(0)