From 84446371f704b861a11798bb5c4e37fad7bf5512 Mon Sep 17 00:00:00 2001 From: Sirisha Gopigiri Date: Wed, 17 Feb 2021 13:41:19 +0000 Subject: [PATCH] Local Persistence Volume Static Provisioner This patchset provides the local volume provisioner manifests function for deploying it in a Target cluster, based on Helm charts. Closes: #27 Change-Id: I4d02727fb71c838c6791cc217d7a652a0011ff40 --- manifests/function/local-storage/README.md | 82 +++++++++++++++++++ .../function/local-storage/helmrelease.yaml | 33 ++++++++ .../function/local-storage/kustomization.yaml | 5 ++ .../replacements/kustomization.yaml | 2 + .../local-storage/replacements/versions.yaml | 39 +++++++++ .../versions-treasuremap.yaml | 7 ++ .../target/workload/kustomization.yaml | 1 + .../workload/replacements/kustomization.yaml | 1 + .../target/workload/kustomization.yaml | 3 +- .../workload/replacements/kustomization.yaml | 3 +- 10 files changed, 174 insertions(+), 2 deletions(-) create mode 100644 manifests/function/local-storage/README.md create mode 100644 manifests/function/local-storage/helmrelease.yaml create mode 100644 manifests/function/local-storage/kustomization.yaml create mode 100644 manifests/function/local-storage/replacements/kustomization.yaml create mode 100644 manifests/function/local-storage/replacements/versions.yaml diff --git a/manifests/function/local-storage/README.md b/manifests/function/local-storage/README.md new file mode 100644 index 000000000..b4f5588c9 --- /dev/null +++ b/manifests/function/local-storage/README.md @@ -0,0 +1,82 @@ +# Local-Storage function + +This function implements the local-volume-static-provisioner which +manages the lifecycle of the persistent volumes for pre-allocated +disks by detecting and creating PVs for each local disk on the host, +and cleaning up the disks when released. It does not support dynamic +provisioning. + +Manual creation of PV on a particular host: + +``` +apiVersion: v1 +kind: PersistentVolume +metadata: + name: example-local-pv +spec: + capacity: + storage: 5Gi + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Delete + storageClassName: local-storage + local: + path: /mnt/disks/ssd1 + nodeAffinity: + required: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - my-node # node on which the local disk exists +``` + +Creating a simple PVC and attaching it to the pod in the Deployment: + +``` +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: example-local-claim +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 5Gi + storageClassName: local-storage +``` + +``` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: local-test-reader +spec: + replicas: 1 + selector: + matchLabels: + app: local-test-reader + template: + metadata: + labels: + app: local-test-reader + spec: + terminationGracePeriodSeconds: 10 + containers: + - name: reader + image: k8s.gcr.io/busybox + command: + - "/bin/sh" + args: + - "-c" + - "tail -f /usr/test-pod/test_file" + volumeMounts: + - name: local-vol + mountPath: /usr/test-pod + volumes: + - name: local-vol + persistentVolumeClaim: + claimName: "example-local-claim" +``` diff --git a/manifests/function/local-storage/helmrelease.yaml b/manifests/function/local-storage/helmrelease.yaml new file mode 100644 index 000000000..df91c3ca3 --- /dev/null +++ b/manifests/function/local-storage/helmrelease.yaml @@ -0,0 +1,33 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: local-storage +--- +apiVersion: "helm.toolkit.fluxcd.io/v2beta1" +kind: HelmRelease +metadata: + name: provisioner + namespace: local-storage +spec: + timeout: 10m + interval: 5m + chart: + spec: + chart: provisioner + sourceRef: + kind: HelmRepository + name: collator + namespace: helm-chart-collator + values: + classes: + - name: local-storage + hostDir: /local-storage + volumeMode: Filesystem + storageClass: + reclaimPolicy: Delete + isDefaultClass: false + fsType: ext4 + daemonset: + image: k8s.gcr.io/sig-storage/local-volume-provisioner:v2.4.0 + serviceMonitor: + enabled: false diff --git a/manifests/function/local-storage/kustomization.yaml b/manifests/function/local-storage/kustomization.yaml new file mode 100644 index 000000000..b1ad0a0e6 --- /dev/null +++ b/manifests/function/local-storage/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - helmrelease.yaml diff --git a/manifests/function/local-storage/replacements/kustomization.yaml b/manifests/function/local-storage/replacements/kustomization.yaml new file mode 100644 index 000000000..476638a21 --- /dev/null +++ b/manifests/function/local-storage/replacements/kustomization.yaml @@ -0,0 +1,2 @@ +resources: + - versions.yaml \ No newline at end of file diff --git a/manifests/function/local-storage/replacements/versions.yaml b/manifests/function/local-storage/replacements/versions.yaml new file mode 100644 index 000000000..7e83a3639 --- /dev/null +++ b/manifests/function/local-storage/replacements/versions.yaml @@ -0,0 +1,39 @@ +apiVersion: airshipit.org/v1alpha1 +kind: ReplacementTransformer +metadata: + name: localvolume-provisioner-replacements + annotations: + config.kubernetes.io/function: |- + container: + image: quay.io/airshipit/replacement-transformer:latest +replacements: +- source: + objref: + kind: VersionsCatalogue + name: versions-treasuremap + fieldref: "{.spec.images.localstorage.provisioner.provisioner.image}" + target: + objref: + kind: HelmRelease + name: provisioner + fieldrefs: ["{.spec.values.daemonset.image}"] +- source: + objref: + kind: VersionsCatalogue + name: versions-treasuremap + fieldref: "{.spec.charts.provisioner.chart}" + target: + objref: + kind: HelmRelease + name: provisioner + fieldrefs: ["{.spec.chart.spec.chart}"] +- source: + objref: + kind: VersionsCatalogue + name: versions-treasuremap + fieldref: "{.spec.charts.provisioner.version}" + target: + objref: + kind: HelmRelease + name: provisioner + fieldrefs: ["{.spec.chart.spec.version}"] diff --git a/manifests/function/treasuremap-base-catalogues/versions-treasuremap.yaml b/manifests/function/treasuremap-base-catalogues/versions-treasuremap.yaml index 3d03dd04e..0ad1ecb52 100644 --- a/manifests/function/treasuremap-base-catalogues/versions-treasuremap.yaml +++ b/manifests/function/treasuremap-base-catalogues/versions-treasuremap.yaml @@ -66,6 +66,9 @@ spec: dex-aio: chart: dex-aio version: 0.1.0 + provisioner: + chart: provisioner + version: "" images: # images are organized by @@ -150,6 +153,10 @@ spec: image: ceph/ceph:v15.2.11 rook-ceph-tools: image: rook/ceph:v1.6.3 + localstorage: + provisioner: + provisioner: + image: k8s.gcr.io/sig-storage/local-volume-provisioner:v2.4.0 image_components: # image_components are organized by diff --git a/manifests/type/airship-core/target/workload/kustomization.yaml b/manifests/type/airship-core/target/workload/kustomization.yaml index cf3819c0c..3cd83edca 100644 --- a/manifests/type/airship-core/target/workload/kustomization.yaml +++ b/manifests/type/airship-core/target/workload/kustomization.yaml @@ -2,4 +2,5 @@ resources: - ../../../../composite/storage-cluster - ../../../../function/ingress - ../../../../function/helm-chart-repository + - ../../../../function/local-storage - dex-aio diff --git a/manifests/type/airship-core/target/workload/replacements/kustomization.yaml b/manifests/type/airship-core/target/workload/replacements/kustomization.yaml index 05b0b74cc..f782ff976 100644 --- a/manifests/type/airship-core/target/workload/replacements/kustomization.yaml +++ b/manifests/type/airship-core/target/workload/replacements/kustomization.yaml @@ -3,3 +3,4 @@ resources: - ../../../../../function/ingress/replacements - ../../../../../function/dex-aio/replacements - ../../../../../function/helm-chart-repository/replacements + - ../../../../../function/local-storage/replacements diff --git a/manifests/type/multi-tenant/target/workload/kustomization.yaml b/manifests/type/multi-tenant/target/workload/kustomization.yaml index 89444046a..daea8dabe 100644 --- a/manifests/type/multi-tenant/target/workload/kustomization.yaml +++ b/manifests/type/multi-tenant/target/workload/kustomization.yaml @@ -4,4 +4,5 @@ resources: - ../../../../function/sip - ../../../../function/synclabeller - ../../../../function/vino - - ../../../../function/helm-chart-repository/ \ No newline at end of file + - ../../../../function/helm-chart-repository/ + - ../../../../function/local-storage diff --git a/manifests/type/multi-tenant/target/workload/replacements/kustomization.yaml b/manifests/type/multi-tenant/target/workload/replacements/kustomization.yaml index 593cd21f1..6cb8165f7 100644 --- a/manifests/type/multi-tenant/target/workload/replacements/kustomization.yaml +++ b/manifests/type/multi-tenant/target/workload/replacements/kustomization.yaml @@ -4,4 +4,5 @@ resources: - ../../../../../function/sip/replacements - ../../../../../function/synclabeller/replacements - ../../../../../function/vino/replacements - - ../../../../../function/helm-chart-repository/replacements \ No newline at end of file + - ../../../../../function/helm-chart-repository/replacements + - ../../../../../function/local-storage/replacements