From d7bf6b15d13b297c99303da5e671bf6a5dc6f32d Mon Sep 17 00:00:00 2001 From: Cedric Verstraeten Date: Sun, 23 Feb 2025 10:16:55 +0100 Subject: [PATCH] move storage class in base and modify through overlay --- Dockerfile | 8 ++++++ README.kustomize.md | 43 +++++++++------------------- base/kustomization.yaml | 1 + base/ssd-hostpath-storageclass.yaml | 9 ++++++ overlays/microk8s/kustomization.yaml | 9 +++++- 5 files changed, 40 insertions(+), 30 deletions(-) create mode 100644 Dockerfile create mode 100644 base/ssd-hostpath-storageclass.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..323d032 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM ubuntu:latest +LABEL maintainer="Cedric Verstraeten" + +# Install dependencies +RUN apt-get update && apt-get install snapd snap-confine -y + +# Install microk8s +RUN snap install microk8s --classic --channel=1.32/stable \ No newline at end of file diff --git a/README.kustomize.md b/README.kustomize.md index 9c3e739..ce08af2 100644 --- a/README.kustomize.md +++ b/README.kustomize.md @@ -95,34 +95,6 @@ Or view the pod status with: kubectl get po -w -A ``` -### Storage class - -By default, the `hostpath-storage` module uses a dedicated directory on your filesystem. In most cases, you may prefer to use a dedicated hard drive for storing your recordings, database, and other data. To achieve this, you can create your own storage class and assign it to the desired directory. Create a file `ssd-hostpath-sc.yaml` with following contents. - -```yaml -kind: StorageClass -apiVersion: storage.k8s.io/v1 -metadata: - name: ssd-hostpath -provisioner: microk8s.io/hostpath -reclaimPolicy: Delete -parameters: - pvDir: /media/Storage -volumeBindingMode: WaitForFirstConsumer -``` - -Save the previously mentioned file `CTRL+O` and apply the Kubernetes resource. - -```bash -kubectl apply -f ssd-hostpath-sc.yaml -``` - -You can verify the creation of the `storage class` using the following command. This `storage class` will be used in the subsequent installation steps, where each component, such as MongoDB, will create a `persistent volume` using the previously created `storage class`. - -```bash -kubectl get sc -A -``` - ### Clone repository Next, we will clone this repository to our local environment. This will allow us to execute the necessary configuration files for installing the Minio operator, MongoDB Helm chart, and other required components. @@ -136,7 +108,7 @@ cd deployment In contrast to the detailed installation instructions, as mentioned here, an easier option to install is to use our Kustomize configure. This will allow you to specify and create your own overlays to install all the different components through a single command line. -Kustomize uses the concept of `bases` and `overlays`, allowing you to customize the base installation with different settings (an overlay). Before executing the `kustomize` command below, navigate to the `overlays/microk8s/kustomization.yaml` file and modify the `inlineValues` of the Hub to match the IP address of your node. +Kustomize uses the concept of `bases` and `overlays`, allowing you to customize the base installation with different settings (an overlay). Before executing the `kustomize` command below, navigate to the `overlays/microk8s/kustomization.yaml` file and modify the `inlineValues` of the Hub to match the IP address of your node. Please note that when you use multipass, WSL or any other type of virtualisation, your IP address will be different than the IP address of your host machine. Verify your IP address using the `ifconfig` command. ```yaml valuesInline: @@ -153,6 +125,19 @@ valuesInline: url: ":32081" ``` +Within the deployment we are creating a new storage class, pointing to the desired location on disk to store database information, recordings and more. Change the `/media/Storage` value to point to the desired location. + +```yaml +patches: + - target: + kind: StorageClass + name: ssd-hostpath + patch: |- + - op: replace + path: /parameters/pvDir + value: /media/Storage +``` + Run the modified overlay using the following command: ```bash diff --git a/base/kustomization.yaml b/base/kustomization.yaml index 6473b50..8a6a501 100644 --- a/base/kustomization.yaml +++ b/base/kustomization.yaml @@ -1,4 +1,5 @@ resources: + - ssd-hostpath-storageclass.yaml - prometheus/base.yaml - namespaces - agent diff --git a/base/ssd-hostpath-storageclass.yaml b/base/ssd-hostpath-storageclass.yaml new file mode 100644 index 0000000..9bbb1f4 --- /dev/null +++ b/base/ssd-hostpath-storageclass.yaml @@ -0,0 +1,9 @@ +kind: StorageClass +apiVersion: storage.k8s.io/v1 +metadata: + name: ssd-hostpath +provisioner: microk8s.io/hostpath +reclaimPolicy: Delete +parameters: + pvDir: /media/Storage +volumeBindingMode: WaitForFirstConsumer \ No newline at end of file diff --git a/overlays/microk8s/kustomization.yaml b/overlays/microk8s/kustomization.yaml index ebe608e..fa1e6d5 100644 --- a/overlays/microk8s/kustomization.yaml +++ b/overlays/microk8s/kustomization.yaml @@ -3,7 +3,14 @@ metadata: resources: - ../../base - +patches: + - target: + kind: StorageClass + name: ssd-hostpath + patch: |- + - op: replace + path: /parameters/pvDir + value: /media/Storage helmCharts: - name: hub releaseName: hub