From 2f05f447efd636919fc3397728274129ff6d0600 Mon Sep 17 00:00:00 2001 From: David Marchant Date: Wed, 23 Mar 2022 19:00:42 +0000 Subject: [PATCH] Use lookup function to remove .createNamespace Hopefully simplify the UX --- charts/ondat-operator/README.md | 1 - charts/ondat-operator/questions.yml | 6 ------ charts/ondat-operator/templates/namespaces.yaml | 10 ++++++---- charts/ondat-operator/values.yaml | 2 -- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/charts/ondat-operator/README.md b/charts/ondat-operator/README.md index 44b7d4e..797b09f 100644 --- a/charts/ondat-operator/README.md +++ b/charts/ondat-operator/README.md @@ -212,7 +212,6 @@ Parameter | Description | Default `cluster.name` | Name of the storageos deployment | `storageos` `cluster.namespace` | Namespace to install the StorageOS cluster into | `storageos` -`cluster.createNamespace` | If true, create the namespace used by the cluster | `true` `cluster.secretRefName` | Name of the secret containing StorageOS API credentials | `storageos-api` `cluster.admin.username` | Username to authenticate to the StorageOS API with | `storageos` `cluster.admin.password` | Password to authenticate to the StorageOS API with | diff --git a/charts/ondat-operator/questions.yml b/charts/ondat-operator/questions.yml index 1a5ed56..5055157 100644 --- a/charts/ondat-operator/questions.yml +++ b/charts/ondat-operator/questions.yml @@ -64,12 +64,6 @@ questions: description: "Namespace of the StorageOS cluster deployment" type: string label: Cluster Namespace - - variable: cluster.createNamespace - default: true - description: "If true, create the namespace for the cluster deployment" - type: boolean - label: Create Cluster Namespace - # Node container image. - variable: cluster.images.node.repository diff --git a/charts/ondat-operator/templates/namespaces.yaml b/charts/ondat-operator/templates/namespaces.yaml index b0e6a9d..c96a177 100644 --- a/charts/ondat-operator/templates/namespaces.yaml +++ b/charts/ondat-operator/templates/namespaces.yaml @@ -1,8 +1,10 @@ -{{- if .Values.cluster.createNamespace }} +# We want to create the storageoscluster namespace if and only if it isn't the +# same namespace as used for the release AND it doesn't already exist in the +# cluster. +# The 'lookup' function takes the state of the cluster before the start of the +# helm install. +{{- if not (lookup "v1" "Namespace" "" .Values.cluster.namespace) }} -# Don't want to attempt to create the ns if user has specificied the same ns -# for both the release and the StorageOS cluster. -# As otherwise it would fail & this could be confusing UX for them. {{- if not (eq .Release.Namespace .Values.cluster.namespace) }} apiVersion: v1 diff --git a/charts/ondat-operator/values.yaml b/charts/ondat-operator/values.yaml index 271fa23..d80da78 100644 --- a/charts/ondat-operator/values.yaml +++ b/charts/ondat-operator/values.yaml @@ -48,8 +48,6 @@ cluster: # This is opposed to the namespace of the operator, which is refered to # with .Release.Namespace namespace: storageos - # Set to false if you'd like to use a pre-existing namespace - createNamespace: true # Name of the secret containing StorageOS API credentials. secretRefName: storageos-api