From 5f3d4e173272c682a18363e892bd3344ee176860 Mon Sep 17 00:00:00 2001 From: Sunny Date: Fri, 14 Aug 2020 01:58:38 +0530 Subject: [PATCH 1/3] Add kustomization files --- deploy/crds/kustomization.yaml | 5 +++++ deploy/kustomization.yaml | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 deploy/crds/kustomization.yaml create mode 100644 deploy/kustomization.yaml diff --git a/deploy/crds/kustomization.yaml b/deploy/crds/kustomization.yaml new file mode 100644 index 000000000..923d30310 --- /dev/null +++ b/deploy/crds/kustomization.yaml @@ -0,0 +1,5 @@ +resources: +- storageos.com_jobs_crd.yaml +- storageos.com_nfsservers_crd.yaml +- storageos.com_storageosclusters_crd.yaml +- storageos.com_storageosupgrades_crd.yaml diff --git a/deploy/kustomization.yaml b/deploy/kustomization.yaml new file mode 100644 index 000000000..35081ba8a --- /dev/null +++ b/deploy/kustomization.yaml @@ -0,0 +1,21 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: storageos-operator + +resources: +- crds +- namespace.yaml +- role.yaml +- service_account.yaml +- role_binding.yaml +- operator.yaml + +configMapGenerator: +- envs: + - config.env + name: storageos-cluster-operator + +images: +- name: storageos/cluster-operator + newName: storageos/cluster-operator + newTag: test From b2c24a419d9365c824065d053388ead63d057e95 Mon Sep 17 00:00:00 2001 From: Sunny Date: Fri, 14 Aug 2020 02:00:40 +0530 Subject: [PATCH 2/3] Remove namespace and use configmap for env vars kustomize applies the kustomize namespace on all the namespaced resources. Also, move operator optional environment variables to be populated using configmap via config.env file. These variables are read from the execution environment when unset. --- deploy/config.env | 16 ++++++++++++ deploy/operator.yaml | 36 +++----------------------- deploy/secret.yaml | 16 ++++++------ deploy/service_account.yaml | 1 - deploy/storageos-operators.olm.cr.yaml | 2 ++ 5 files changed, 29 insertions(+), 42 deletions(-) create mode 100644 deploy/config.env diff --git a/deploy/config.env b/deploy/config.env new file mode 100644 index 000000000..74a742cbd --- /dev/null +++ b/deploy/config.env @@ -0,0 +1,16 @@ +RELATED_IMAGE_STORAGEOS_NODE +RELATED_IMAGE_STORAGEOS_INIT +RELATED_IMAGE_CSIV1_CLUSTER_DRIVER_REGISTRAR +RELATED_IMAGE_CSIV1_NODE_DRIVER_REGISTRAR +RELATED_IMAGE_CSIV1_EXTERNAL_PROVISIONER +RELATED_IMAGE_CSIV1_EXTERNAL_ATTACHER +RELATED_IMAGE_CSIV1_EXTERNAL_ATTACHER_V2 +RELATED_IMAGE_CSIV1_EXTERNAL_RESIZER +RELATED_IMAGE_CSIV1_LIVENESS_PROBE +RELATED_IMAGE_CSIV0_DRIVER_REGISTRAR +RELATED_IMAGE_CSIV0_EXTERNAL_PROVISIONER +RELATED_IMAGE_CSIV0_EXTERNAL_ATTACHER +RELATED_IMAGE_NFS +RELATED_IMAGE_KUBE_SCHEDULER +JAEGER_ENDPOINT +JAEGER_SERVICE_NAME diff --git a/deploy/operator.yaml b/deploy/operator.yaml index c8c956ed5..81df79a82 100644 --- a/deploy/operator.yaml +++ b/deploy/operator.yaml @@ -2,7 +2,6 @@ apiVersion: apps/v1 kind: Deployment metadata: name: storageos-cluster-operator - namespace: storageos-operator labels: app.kubernetes.io/name: storageos-operator app.kubernetes.io/instance: storageos-cluster-operator @@ -33,34 +32,6 @@ spec: - cluster-operator imagePullPolicy: IfNotPresent env: - - name: RELATED_IMAGE_STORAGEOS_NODE - value: "" - - name: RELATED_IMAGE_STORAGEOS_INIT - value: "" - - name: RELATED_IMAGE_CSIV1_CLUSTER_DRIVER_REGISTRAR - value: "" - - name: RELATED_IMAGE_CSIV1_NODE_DRIVER_REGISTRAR - value: "" - - name: RELATED_IMAGE_CSIV1_EXTERNAL_PROVISIONER - value: "" - - name: RELATED_IMAGE_CSIV1_EXTERNAL_ATTACHER - value: "" - - name: RELATED_IMAGE_CSIV1_EXTERNAL_ATTACHER_V2 - value: "" - - name: RELATED_IMAGE_CSIV1_EXTERNAL_RESIZER - value: "" - - name: RELATED_IMAGE_CSIV1_LIVENESS_PROBE - value: "" - - name: RELATED_IMAGE_CSIV0_DRIVER_REGISTRAR - value: "" - - name: RELATED_IMAGE_CSIV0_EXTERNAL_PROVISIONER - value: "" - - name: RELATED_IMAGE_CSIV0_EXTERNAL_ATTACHER - value: "" - - name: RELATED_IMAGE_NFS - value: "" - - name: RELATED_IMAGE_KUBE_SCHEDULER - value: "" - name: WATCH_NAMESPACE valueFrom: fieldRef: @@ -77,10 +48,9 @@ spec: value: "storageos-cluster-operator" - name: DISABLE_SCHEDULER_WEBHOOK value: "false" - - name: JAEGER_ENDPOINT - value: "" - - name: JAEGER_SERVICE_NAME - value: "" + envFrom: + - configMapRef: + name: storageos-cluster-operator tolerations: - key: "key" operator: "Equal" diff --git a/deploy/secret.yaml b/deploy/secret.yaml index 882ce567b..0b2c02f9e 100644 --- a/deploy/secret.yaml +++ b/deploy/secret.yaml @@ -14,11 +14,11 @@ data: # tls.crt: # tls.key: # Add base64 encoded creds below for CSI credentials. - # csiProvisionUsername: - # csiProvisionPassword: - # csiControllerPublishUsername: - # csiControllerPublishPassword: - # csiNodePublishUsername: - # csiNodePublishPassword: - # csiControllerExpandUsername: - # csiControllerExpandPassword: + csiProvisionUsername: c3RvcmFnZW9z + csiProvisionPassword: c3RvcmFnZW9z + csiControllerPublishUsername: c3RvcmFnZW9z + csiControllerPublishPassword: c3RvcmFnZW9z + csiNodePublishUsername: c3RvcmFnZW9z + csiNodePublishPassword: c3RvcmFnZW9z + csiControllerExpandUsername: c3RvcmFnZW9z + csiControllerExpandPassword: c3RvcmFnZW9z diff --git a/deploy/service_account.yaml b/deploy/service_account.yaml index cc9d4c297..812557af0 100644 --- a/deploy/service_account.yaml +++ b/deploy/service_account.yaml @@ -2,7 +2,6 @@ apiVersion: v1 kind: ServiceAccount metadata: name: storageoscluster-operator-sa - namespace: storageos-operator labels: app: storageos app.kubernetes.io/name: storageos-operator diff --git a/deploy/storageos-operators.olm.cr.yaml b/deploy/storageos-operators.olm.cr.yaml index f35c81ef6..dec0c969d 100644 --- a/deploy/storageos-operators.olm.cr.yaml +++ b/deploy/storageos-operators.olm.cr.yaml @@ -21,6 +21,8 @@ metadata: type: "kubernetes.io/storageos" data: # echo -n '' | base64 + apiUsername: c3RvcmFnZW9z + apiPassword: c3RvcmFnZW9z csiProvisionUsername: c3RvcmFnZW9z csiProvisionPassword: c3RvcmFnZW9z csiControllerPublishUsername: c3RvcmFnZW9z From 7056cfaaf1fe59c3239b083864ae6b84df1e351f Mon Sep 17 00:00:00 2001 From: Sunny Date: Fri, 14 Aug 2020 02:04:39 +0530 Subject: [PATCH 3/3] Update makefile, remove old script for manifest gen scripts/create-manifest.sh is no longer required. --- Makefile | 19 ++++++++++--- scripts/create-manifest.sh | 55 -------------------------------------- 2 files changed, 15 insertions(+), 59 deletions(-) delete mode 100644 scripts/create-manifest.sh diff --git a/Makefile b/Makefile index 967b70d22..0386e52b2 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,11 @@ SDK_VERSION = v0.17.2 MACHINE = $(shell uname -m) BUILD_IMAGE = golang:1.14.2 BASE_IMAGE = storageos/base-image:0.2.1 -BUILD_DIR = "build" +BUILD_DIR = "${CURDIR}/build" OPERATOR_SDK = $(BUILD_DIR)/operator-sdk YQ = $(BUILD_DIR)/yq GOLANGCI_LINT = $(BUILD_DIR)/golangci-lint +KUSTOMIZE = $(BUILD_DIR)/kustomize OUTPUT_DIR = $(BUILD_DIR)/_output # Set the new version before running the release target. @@ -160,7 +161,7 @@ dev-image: operator-sdk operator-docker ## Build an image quickly for testing (f ##@ Third-party tools -.PHONY: operator-sdk yq golangci-lint +.PHONY: operator-sdk yq golangci-lint kustomize operator-sdk: ## Download operator-sdk. # Download sdk only if it's not available. @@ -180,6 +181,13 @@ golangci-lint: ## Install golangci-lint curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(BUILD_DIR) v1.27.0; \ fi +kustomize: ## Install kustomize. + @if [ ! -f $(KUSTOMIZE) ]; then \ + curl -s https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh | bash && \ + mv kustomize $(KUSTOMIZE); \ + fi + + ############################## # Tests # ############################## @@ -224,9 +232,12 @@ metadata-zip: ## Generate OLM metadata-zip bundle. deploy/olm/storageos/storageosnfsserver.crd.yaml \ deploy/olm/csv-rhel/storageos.v*.clusterserviceversion.yaml +update-image: kustomize + cd deploy/ && $(KUSTOMIZE) edit set image storageos/cluster-operator=$(OPERATOR_IMAGE) + # Generates a single manifest for installing the operator. -install-manifest: yq ## Generate operator install manifest file. - bash scripts/create-manifest.sh $(OPERATOR_IMAGE) +install-manifest: kustomize update-image ## Generate operator install manifest file. + $(KUSTOMIZE) build deploy/ > storageos-operator.yaml diff --git a/scripts/create-manifest.sh b/scripts/create-manifest.sh deleted file mode 100644 index c687cd9ba..000000000 --- a/scripts/create-manifest.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -set -e - -# This script generates a single manifest file for installing the operator. -# This file is attached to each release with the appropriate container image for -# quick installation. - -# Set the first argument as the operator container image tag. Default to "test". -OPERATOR_IMAGE="${1:-test}" - -# List of manifests files to combine to form a single operator manifest file. -declare -a manifestfiles=( - "deploy/crds/storageos.com_storageosclusters_crd.yaml" - "deploy/crds/storageos.com_storageosupgrades_crd.yaml" - "deploy/crds/storageos.com_jobs_crd.yaml" - "deploy/crds/storageos.com_nfsservers_crd.yaml" - "deploy/namespace.yaml" - "deploy/role.yaml" - "deploy/service_account.yaml" - "deploy/role_binding.yaml" -) - -# Path of the operator install manifest file. -INSTALL_MANIFEST="storageos-operator.yaml" - -# Delete the existing manifest. -rm -f $INSTALL_MANIFEST - -for i in "${manifestfiles[@]}" -do - echo "---" >> $INSTALL_MANIFEST - echo "Copying $i" - cat $i >> $INSTALL_MANIFEST -done - -# Set operator install env vars. Be careful of the ordering if they change! -OPERATOR_MANIFEST=deploy/operator-generated.yaml -cp deploy/operator.yaml $OPERATOR_MANIFEST - -if [ -n "$JAEGER_ENDPOINT" ]; then - build/yq w -i $OPERATOR_MANIFEST spec.template.spec.containers[0].env[19].value $JAEGER_ENDPOINT -fi -if [ -n "$JAEGER_SERVICE_NAME" ]; then - build/yq w -i $OPERATOR_MANIFEST spec.template.spec.containers[0].env[20].value $JAEGER_SERVICE_NAME -fi - -# Write the operator manifest with the proper container image tag. -echo "---" >> $INSTALL_MANIFEST -echo "Copying $OPERATOR_MANIFEST with image $OPERATOR_IMAGE" -build/yq w $OPERATOR_MANIFEST spec.template.spec.containers[0].image $OPERATOR_IMAGE >> $INSTALL_MANIFEST - -if [ -f "$OPERATOR_MANIFEST" ]; then - rm -f "$OPERATOR_MANIFEST" -fi -