diff --git a/models/kube/backend/job_backend.k b/models/kube/backend/job_backend.k index 313d50b..d724644 100644 --- a/models/kube/backend/job_backend.k +++ b/models/kube/backend/job_backend.k @@ -32,7 +32,7 @@ schema JobBackend[inputConfig: frontend.Job]: mainContainerDict = { **config.mainContainer if config.mainContainer.useBuiltInEnv: - env += app.envs + env = config.mainContainer.env | app.envs name = config.mainContainer.name or "main" image = config.image resource = config?.schedulingStrategy?.resource diff --git a/models/kube/backend/server_backend.k b/models/kube/backend/server_backend.k index 0e88988..196cf7e 100644 --- a/models/kube/backend/server_backend.k +++ b/models/kube/backend/server_backend.k @@ -41,7 +41,7 @@ schema ServerBackend[inputConfig: server.Server]: mainContainer = utils.volume_patch(config.volumes, [utils.ContainerFrontend2Kube({ **config.mainContainer if config.mainContainer.useBuiltInEnv: - env += app.envs + env = config.mainContainer.env | app.envs name = config.mainContainer.name or "main" image = config.image resource = config?.schedulingStrategy?.resource diff --git a/models/kube/metadata/metadata.k b/models/kube/metadata/metadata.k index c15bbeb..3227187 100644 --- a/models/kube/metadata/metadata.k +++ b/models/kube/metadata/metadata.k @@ -1,4 +1,4 @@ -__META_APP_NAME = option("app") or "sampleapp" -__META_APP_NAMESPACE = option("appns") or "sampleappns" -__META_ENV_TYPE_NAME = option("env") or "prod" -__META_CLUSTER_NAME = option("cluster") or Undefined +__META_APP_NAME = option("app") or option("params")?.app or "sampleapp" +__META_APP_NAMESPACE = option("appns") or option("params")?.appns or "sampleappns" +__META_ENV_TYPE_NAME = option("appenv") or option("params")?.appenv or "prod" +__META_CLUSTER_NAME = option("appcluster") or option("params")?.appcluster or Undefined diff --git a/models/kube/utils/application_builder.k b/models/kube/utils/application_builder.k index e74d838..3723355 100644 --- a/models/kube/utils/application_builder.k +++ b/models/kube/utils/application_builder.k @@ -1,4 +1,5 @@ import models.kube.metadata +import models.kube.frontend.container.env as e schema ApplicationBuilder: """ApplicationBuilder contains the workload labels, selector and environments about the application @@ -9,26 +10,24 @@ schema ApplicationBuilder: "app.kubernetes.io/name": metadata.__META_APP_NAME "app.kubernetes.io/env": metadata.__META_ENV_TYPE_NAME "app.kubernetes.io/instance": "{}-{}".format(metadata.__META_APP_NAME, metadata.__META_ENV_TYPE_NAME).lower() - "cluster.x-k8s.io/cluster-name": metadata.__META_CLUSTER_NAME + if metadata.__META_CLUSTER_NAME: + "cluster.x-k8s.io/cluster-name": metadata.__META_CLUSTER_NAME } selector: {str:str} = labels - envs: [{str:}] = [ - { - name: "APP_NAME" + envs: e.EnvMap = { + APP_NAME: { value: metadata.__META_APP_NAME } - { - name: "ENVIRONMENT" + ENVIRONMENT: { value: metadata.__META_ENV_TYPE_NAME } - { - name: "INSTANCE" + INSTANCE: { value: "{}-{}".format(metadata.__META_APP_NAME, metadata.__META_ENV_TYPE_NAME).lower() } - { - name: "CLUSTER" - value: metadata.__META_CLUSTER_NAME - } - ] + if metadata.__META_CLUSTER_NAME: + CLUSTER: { + value: metadata.__META_CLUSTER_NAME + } + }