1.yaml文件
[root@k8s-matser01 nfs.rbac]
apiVersion: v1
kind: Service
metadata:
name: nginx
labels:
app: nginx
spec:
ports:
- port: 80
name: web
selector:
app: nginx
type: ClusterIP
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: nginx-share-pvc
spec:
storageClassName: managed-nfs-storage
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
selector:
matchLabels:
app: nginx
replicas: 3
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
name: web
volumeMounts:
- name: www
mountPath: /usr/share/nginx/html
volumes:
- name: www
persistentVolumeClaim:
claimName: nginx-share-pvc
其他容器查看
[root@k8s-matser01 ~]
web-7bf54cbc8d-b2wwp 1/1 Running 0 8m10s
web-7bf54cbc8d-pz4f4 1/1 Running 0 8m10s
web-7bf54cbc8d-tw9wg 1/1 Running 0 8m10s
[root@k8s-matser01 ~]
root@web-7bf54cbc8d-pz4f4:/
root@web-7bf54cbc8d-pz4f4:/
Mon Nov 15 05:33:56 UTC 2021
3.其他容器查看
[root@k8s-matser01 ~]
Mon Nov 15 05:33:56 UTC 2021
[root@k8s-matser01 ~]
Mon Nov 15 05:33:56 UTC 2021
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步