From e7138cc1ad9e6a649addd98577ef46074c692ad7 Mon Sep 17 00:00:00 2001 From: Nitish Tiwari Date: Thu, 8 Jun 2023 20:50:17 +0530 Subject: [PATCH] Add support for env vars as map (#39) --- api/v1beta1/parseabletenant_types.go | 6 +- api/v1beta1/zz_generated.deepcopy.go | 7 +++ .../bases/parseable.io_parseabletenants.yaml | 4 +- config/samples/parseable-multi-server.yaml | 55 +++++-------------- .../crds/parseable.io_parseabletenants.yaml | 4 +- .../tenant_controller/internal_builder.go | 4 +- 6 files changed, 30 insertions(+), 50 deletions(-) diff --git a/api/v1beta1/parseabletenant_types.go b/api/v1beta1/parseabletenant_types.go index 3373571..2e35e7c 100644 --- a/api/v1beta1/parseabletenant_types.go +++ b/api/v1beta1/parseabletenant_types.go @@ -73,9 +73,9 @@ type StorageConfig struct { } type ParseableConfigSpec struct { - Name string `json:"name"` - EnvVars string `json:"env"` - CliArgs []string `json:"cliArgs"` + Name string `json:"name"` + EnvVars map[string]string `json:"env"` + CliArgs []string `json:"cliArgs"` } type NodeSpec struct { diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 261b7f2..0cd22a9 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -186,6 +186,13 @@ func (in *ObjectStoreSpec) DeepCopy() *ObjectStoreSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ParseableConfigSpec) DeepCopyInto(out *ParseableConfigSpec) { *out = *in + if in.EnvVars != nil { + in, out := &in.EnvVars, &out.EnvVars + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } if in.CliArgs != nil { in, out := &in.CliArgs, &out.CliArgs *out = make([]string, len(*in)) diff --git a/config/crd/bases/parseable.io_parseabletenants.yaml b/config/crd/bases/parseable.io_parseabletenants.yaml index 98ce228..b1aef3a 100644 --- a/config/crd/bases/parseable.io_parseabletenants.yaml +++ b/config/crd/bases/parseable.io_parseabletenants.yaml @@ -2613,7 +2613,9 @@ spec: type: string type: array env: - type: string + additionalProperties: + type: string + type: object name: type: string required: diff --git a/config/samples/parseable-multi-server.yaml b/config/samples/parseable-multi-server.yaml index 13bef38..359b8e4 100644 --- a/config/samples/parseable-multi-server.yaml +++ b/config/samples/parseable-multi-server.yaml @@ -21,19 +21,12 @@ spec: k8sConfig: parseable-ingestion-2 parseableConfig: parseable-server-config - - name: parseable-ingestion-3 - type: server - kind: Deployment - replicas: 1 - k8sConfig: parseable-ingestion-3 - parseableConfig: parseable-server-config - deploymentOrder: - server k8sConfig: - name: parseable-ingestion-1 - image: parseable/parseable:edge + image: parseable/parseable:edge-debug service: type: ClusterIP ports: @@ -59,33 +52,7 @@ spec: memory: 128Mi - name: parseable-ingestion-2 - image: parseable/parseable:edge - service: - type: ClusterIP - ports: - - protocol: TCP - port: 80 - targetPort: 8000 - volumes: - - emptyDir: {} - name: stage-volume - - emptyDir: {} - name: data-volume - volumeMount: - - mountPath: /parseable/data - name: data-volume - - mountPath: /parseable/staging - name: stage-volume - resources: - limits: - cpu: 1000m - memory: 1Gi - requests: - cpu: 100m - memory: 128Mi - - - name: parseable-ingestion-3 - image: parseable/parseable:edge + image: parseable/parseable:edge-debug service: type: ClusterIP ports: @@ -113,10 +80,14 @@ spec: parseableConfig: - name: parseable-server-config cliArgs: - - local-store - env: |- - P_ADDR=0.0.0.0:8000 - P_STAGING_DIR=/parseable/staging - P_FS_DIR=./data - P_USERNAME=admin - P_PASSWORD=admin + - s3-store + env: + P_ADDR: "0.0.0.0:8000" + P_USERNAME: "admin" + P_PASSWORD: "admin" + P_STAGING_DIR: "/parseable/staging" + P_S3_URL: "http://minio.minio.svc.cluster.local:9000" + P_S3_ACCESS_KEY: "minioadmin" + P_S3_SECRET_KEY: "minioadmin" + P_S3_BUCKET: "parseable" + P_S3_REGION: "us-east-1" diff --git a/helm/operator/crds/parseable.io_parseabletenants.yaml b/helm/operator/crds/parseable.io_parseabletenants.yaml index 98ce228..b1aef3a 100644 --- a/helm/operator/crds/parseable.io_parseabletenants.yaml +++ b/helm/operator/crds/parseable.io_parseabletenants.yaml @@ -2613,7 +2613,9 @@ spec: type: string type: array env: - type: string + additionalProperties: + type: string + type: object name: type: string required: diff --git a/internal/tenant_controller/internal_builder.go b/internal/tenant_controller/internal_builder.go index 5161e8f..798de05 100644 --- a/internal/tenant_controller/internal_builder.go +++ b/internal/tenant_controller/internal_builder.go @@ -74,9 +74,7 @@ func (ib *internalBuilder) makeParseableConfigMap( CrObject: ib.parseableTenant, OwnerRef: *ib.ownerRef, }, - Data: map[string]string{ - "data": fmt.Sprintf("%s", parseableConfig.EnvVars), - }, + Data: parseableConfig.EnvVars, } return configMap