k8s volumes.provisioner怎么配置
时间: 2024-06-01 22:13:03 浏览: 13
您可以在kubernetes的yaml文件中,针对不同的存储类型设置不同的provisioner。例如,针对NFS类型的存储,可以设置为:
volumes:
- name: nfs
nfs:
server: nfs.example.com
path: /share
persistentVolumeClaim:
claimName: myclaim
nfs:
path: /share
server: nfs.example.com
而针对AWS EBS类型的存储,则需要设置为:
volumes:
- name: ebs
awsElasticBlockStore:
volumeID: <volume-id>
fsType: ext4
readOnly: false
persistentVolumeClaim:
claimName: ebs
awsElasticBlockStore:
volumeID: <volume-id>
fsType: ext4
希望对您有所帮助。
相关问题
Failed to list *v1.StorageClass: storageclasses.storage.k8s.io is forbidden: User "system:serviceaccount:default:nfs-client-provisioner" cannot list resource "storageclasses" in API group "storage.k8s.io" at the cluster scope: RBAC: clusterrole.rbac.authorization.k8s.io "nfs-client-provisioner-role" not found的yaml怎么写
您可以尝试创建一个新的 ClusterRole 来授权您的 ServiceAccount 访问存储类资源。具体操作步骤如下:
1. 创建一个新的 ClusterRole,例如:
```
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: nfs-client-provisioner-role
rules:
- apiGroups: [""]
resources: ["persistentvolumes", "persistentvolumeclaims", "services"]
verbs: ["get", "list", "watch", "create", "update", "delete"]
- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses"]
verbs: ["get", "list", "watch"]
```
2. 授权给您的 ServiceAccount,例如:
```
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: nfs-client-provisioner-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: nfs-client-provisioner-role
subjects:
- kind: ServiceAccount
name: nfs-client-provisioner
namespace: default
```
3. 检查您的 ServiceAccount 是否已经获得了新的权限,例如:
```
kubectl auth can-i list storageclasses --as=system:serviceaccount:default:nfs-client-provisioner
```
如果返回结果为 `yes`,则说明您的 ServiceAccount 已经获得了访问存储类资源的权限。
k8s 部署 elasticsearch 存储使用StorageClass 配置文档
您好,感谢您的提问。关于 k8s 部署 elasticsearch 存储使用 StorageClass 配置文档,您可以参考以下步骤:
1. 创建一个 StorageClass,例如:
```
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: fast-disks
provisioner: kubernetes.io/gce-pd
parameters:
type: pd-ssd
zone: us-central1-a
```
2. 创建一个 PVC(Persistent Volume Claim):
```
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: elasticsearch-pvc
annotations:
volume.beta.kubernetes.io/storage-class: fast-disks
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Gi
```
3. 在 elasticsearch 的 deployment 中绑定这个 PVC:
```
apiVersion: apps/v1
kind: Deployment
metadata:
name: elasticsearch
spec:
replicas: 1
template:
...
spec:
containers:
- name: elasticsearch
image: docker.io/elasticsearch:6.2.4
volumeMounts:
- name: elasticsearch-storage
mountPath: /usr/share/elasticsearch/data
volumes:
- name: elasticsearch-storage
persistentVolumeClaim:
claimName: elasticsearch-pvc
```
以上是一个简单的示例,您可以根据自己的实际情况进行修改。希望能帮到您,如有疑问请随时提出。
相关推荐
![js](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.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)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)