kubernetes-installation/sc-provider
Sambo Chea 990300c269
Create local-path.md
2022-03-09 09:07:55 +07:00
..
bind-cluster-ac.yaml Add sc and pv, pvc not clear implements 2021-10-25 10:36:23 +07:00
cluster-role.yaml Add sc and pv, pvc not clear implements 2021-10-25 10:36:23 +07:00
deployment.yaml Add sc and pv, pvc not clear implements 2021-10-25 10:36:23 +07:00
local-path.md Create local-path.md 2022-03-09 09:07:55 +07:00
README.md Add sc and pv, pvc not clear implements 2021-10-25 10:36:23 +07:00
sc.yaml Add sc and pv, pvc not clear implements 2021-10-25 10:36:23 +07:00
service-account-all.yaml Add sc and pv, pvc not clear implements 2021-10-25 10:36:23 +07:00
service-account.yaml Add sc and pv, pvc not clear implements 2021-10-25 10:36:23 +07:00

Configure Storage Class Provider with NFS

  1. Create storage class
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: nfs-k8s-data
  annotations:
    storageclass.kubernetes.io/is-default-class: "true"
provisioner: k8s/nfs
allowVolumeExpansion: true
  1. Create service account and permission
  • Create service account
apiVersion: v1
kind: ServiceAccount
metadata:
  name: nfs-client-provisioner
  • Define cluster role
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: nfs-client-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: ["list", "watch", "create", "update", "patch"]
  - apiGroups: [""]
    resources: ["endpoints"]
    verbs: ["get", "list", "watch", "create", "update", "patch"]
  • Bind cluster to service account
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: run-nfs-client-provisioner
subjects:
  - kind: ServiceAccount
    name: nfs-client-provisioner
    namespace: default
roleRef:
  kind: ClusterRole
  name: nfs-client-provisioner-runner
  apiGroup: rbac.authorization.k8s.io
  1. Deploy provisioner as pod
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: quay.io/external_storage/nfs-client-provisioner:v3.1.0-k8s1.11
          volumeMounts:
            - name: nfs-client-root
              mountPath: /persistentvolumes
          env:
            - name: PROVISIONER_NAME
              value: k8s/nfs
            - name: NFS_SERVER
              value: 192.168.1.119 # nodes will need nfs-common to access nfs protocol
            - name: NFS_PATH
              value: /export/k8sdynamic
      volumes:
        - name: nfs-client-root
          nfs:
            server: 192.168.1.119
            path: /export/k8sdynamic