From 8e67de44aeae1037f8f920ccb6a1bb1e2cf5077c Mon Sep 17 00:00:00 2001 From: Rimas Mocevicius Date: Sat, 2 Mar 2019 20:26:40 +0000 Subject: [PATCH] Update kind cluster example with working local storage for all nodes (#116) Signed-off-by: rimas --- examples/kind/test/e2e-kind.sh | 17 ++- .../kind/test/local-path-provisioner.yaml | 108 ++++++++++++++++++ 2 files changed, 115 insertions(+), 10 deletions(-) create mode 100644 examples/kind/test/local-path-provisioner.yaml diff --git a/examples/kind/test/e2e-kind.sh b/examples/kind/test/e2e-kind.sh index cc1068c..df5035a 100755 --- a/examples/kind/test/e2e-kind.sh +++ b/examples/kind/test/e2e-kind.sh @@ -74,18 +74,15 @@ install_tiller() { echo } -install_hostpath-provisioner() { - # kind doesn't support Dynamic PVC provisioning yet, this is one way to get it working - # https://github.com/rimusz/charts/tree/master/stable/hostpath-provisioner +install_local-path-provisioner() { + # kind doesn't support Dynamic PVC provisioning yet, this is one ways to get it working + # https://github.com/rancher/local-path-provisioner - echo 'Installing hostpath-provisioner...' - - # Remove default storage class. Will be recreated by hostpath -provisioner + # Remove default storage class. It will be recreated by local-path-provisioner docker_exec kubectl delete storageclass standard - docker_exec helm repo add rimusz https://charts.rimusz.net - docker_exec helm repo update - docker_exec helm install rimusz/hostpath-provisioner --name hostpath-provisioner --namespace kube-system --wait + echo 'Installing local-path-provisioner...' + docker_exec kubectl apply -f test/local-path-provisioner.yaml echo } @@ -99,8 +96,8 @@ main() { trap cleanup EXIT create_kind_cluster + install_local-path-provisioner install_tiller - install_hostpath-provisioner install_charts } diff --git a/examples/kind/test/local-path-provisioner.yaml b/examples/kind/test/local-path-provisioner.yaml new file mode 100644 index 0000000..d296323 --- /dev/null +++ b/examples/kind/test/local-path-provisioner.yaml @@ -0,0 +1,108 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: local-path-storage +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: local-path-provisioner-service-account + namespace: local-path-storage +--- +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRole +metadata: + name: local-path-provisioner-role + namespace: local-path-storage +rules: +- apiGroups: [""] + resources: ["nodes", "persistentvolumeclaims"] + verbs: ["get", "list", "watch"] +- apiGroups: [""] + resources: ["endpoints", "persistentvolumes", "pods"] + verbs: ["*"] +- apiGroups: [""] + resources: ["events"] + verbs: ["create", "patch"] +- apiGroups: ["storage.k8s.io"] + resources: ["storageclasses"] + verbs: ["get", "list", "watch"] +--- +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRoleBinding +metadata: + name: local-path-provisioner-bind + namespace: local-path-storage +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: local-path-provisioner-role +subjects: +- kind: ServiceAccount + name: local-path-provisioner-service-account + namespace: local-path-storage +--- +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: local-path-provisioner + namespace: local-path-storage +spec: + replicas: 1 + selector: + matchLabels: + app: local-path-provisioner + template: + metadata: + labels: + app: local-path-provisioner + spec: + serviceAccountName: local-path-provisioner-service-account + containers: + - name: local-path-provisioner + image: rancher/local-path-provisioner:v0.0.4 + imagePullPolicy: Always + command: + - local-path-provisioner + - --debug + - start + - --config + - /etc/config/config.json + volumeMounts: + - name: config-volume + mountPath: /etc/config/ + env: + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + volumes: + - name: config-volume + configMap: + name: local-path-config +--- +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: local-path + annotations: + storageclass.kubernetes.io/is-default-class: "true" +provisioner: rancher.io/local-path +volumeBindingMode: WaitForFirstConsumer +reclaimPolicy: Delete +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: local-path-config + namespace: local-path-storage +data: + config.json: |- + { + "nodePathMap":[ + { + "node":"DEFAULT_PATH_FOR_NON_LISTED_NODES", + "paths":["/opt/local-path-provisioner"] + } + ] + }