K8S的statefulset怎么在pvc中挂载多个路径
时间: 2024-05-02 16:17:47 浏览: 22
K8S的statefulset可以在pvc中挂载多个路径,只需在statefulset的volumeMounts中添加多个mountPath即可。例如:
```
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: example
spec:
serviceName: example
replicas: 3
selector:
matchLabels:
app: example
template:
metadata:
labels:
app: example
spec:
containers:
- name: example
image: nginx
volumeMounts:
- name: data
mountPath: /var/www/html
- name: config
mountPath: /etc/nginx/conf.d
volumes:
- name: data
persistentVolumeClaim:
claimName: example-pvc
- name: config
persistentVolumeClaim:
claimName: example-pvc
```
在上述例子中,statefulset的container挂载了两个volumeMounts,分别为"/var/www/html"和"/etc/nginx/conf.d",并且这两个volume都是从同一个pvc中挂载的。
相关推荐
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)