k8sstorageclass代码实例展示
今天小编就为大家带来一篇k8s storageclass实例展示的文章。小编觉得挺不错的,为此分享给大家做个参考。一起跟随小编过来看看吧。
目前创新互联已为成百上千的企业提供了网站建设、域名、虚拟空间、成都网站托管、企业网站设计、宁明网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。
代码
apiVersion: v1
kind: ServiceAccount
metadata:
name: nfs-client-provisioner
---
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: nfs-client-provisioner
spec:
replicas: 1
strategy:
type: Recreate
template:
metadata:
labels:
app: nfs-client-provisioner
spec:
serviceAccount: nfs-client-provisioner
containers:
- name: nfs-client-provisioner
image: registry.cn-hangzhou.aliyuncs.com/open-ali/nfs-client-provisioner
volumeMounts:
- name: nfs-client-root
mountPath: /persistentvolumes
env:
- name: PROVISIONER_NAME
value: hequan.com/nfs
- name: NFS_SERVER
value: 192.168.100.111
- name: NFS_PATH
value: /data1
volumes:
- name: nfs-client-root
nfs:
server: 192.168.100.111
path: /data1
vim clusterrole.yaml
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: nfs-provisioner-runner
rules:
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "create", "delete"]
- apiGroups: [""]
resources: ["persistentvolumeclaims"]
verbs: ["get", "list", "watch", "update"]
- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["events"]
verbs: ["watch", "create", "update", "patch"]
- apiGroups: [""]
resources: ["services", "endpoints"]
verbs: ["get"]
- apiGroups: ["extensions"]
resources: ["podsecuritypolicies"]
resourceNames: ["nfs-provisioner"]
verbs: ["use"]
vim clusterrolebinding.yaml
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: run-nfs-provisioner
subjects:
- kind: ServiceAccount
name: nfs-client-provisioner
namespace: default
roleRef:
kind: ClusterRole
name: nfs-provisioner-runner
apiGroup: rbac.authorization.k8s.io
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: nfs
provisioner: hequan.com/nfs
parameters:
archiveOnDelete: "false"
测试
kind: PersistentVolumeClaim
apiVersion: v1
metadata: name: test-claim annotations: volume.beta.kubernetes.io/storage-class: "nfs" spec: accessModes: - ReadWriteMany resources: requests: storage: 1Mi
以上就是k8s storageclass的 代码实例展示,内容较为全面,而且我也相信有相当的一些知识点可能是我们日常工作可能会见到或用到的。通过这篇文章,希望你能收获更多。
文章标题:k8sstorageclass代码实例展示
文章URL:http://azwzsj.com/article/gpdiie.html