diff --git a/docs/v3_spec.md b/docs/v3_spec.md index b245bb46..e6362572 100644 --- a/docs/v3_spec.md +++ b/docs/v3_spec.md @@ -680,6 +680,21 @@ Kubernetes apiserver. If in doubt, leave this disabled. admin_access: False ``` +## config_maps + +| **Type** | **Required** | +|----------|--------------| +| list | no | + +Add extra ConfigMaps to your application. A ConfigMap named the same as your application will always be added to the end of the list. + +```yaml +config_maps: + - yourconfigmap +``` + +##### A note about file-paths: + The default ConfigMap is mounted at `/var/run/config/fiaas/` while other configmaps will be mounted at `/var/run/config/` ## extensions diff --git a/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py b/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py index 76602686..363f4a4e 100644 --- a/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py +++ b/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py @@ -65,7 +65,8 @@ def deploy(self, app_spec, selector, labels, besteffort_qos_is_required): env = self._make_env(app_spec) pull_policy = "IfNotPresent" if (":" in app_spec.image and ":latest" not in app_spec.image) else "Always" - env_from = [EnvFromSource(configMapRef=ConfigMapEnvSource(name=app_spec.name, optional=True))] + env_from = _add_config_maps(app_spec) + containers = [ Container(name=app_spec.name, image=app_spec.image, @@ -103,8 +104,10 @@ def deploy(self, app_spec, selector, labels, besteffort_qos_is_required): # the autoscaler won't scale up the deployment if the current number of replicas is 0 if deployment.spec.replicas > 0: replicas = deployment.spec.replicas - LOG.info("Configured replica size (%d) for deployment is being ignored, as current running replica size" - " is different (%d) for %s", app_spec.autoscaler.min_replicas, deployment.spec.replicas, app_spec.name) + LOG.info( + "Configured replica size (%d) for deployment is being ignored, as current running replica size" + " is different (%d) for %s", app_spec.autoscaler.min_replicas, deployment.spec.replicas, + app_spec.name) except NotFound: pass @@ -135,6 +138,10 @@ def delete(self, app_spec): def _make_volumes(self, app_spec): volumes = [] + if app_spec.config_maps: + for config_map in app_spec.config_maps: + volumes.append(Volume(name="{}-config".format(config_map), + configMap=ConfigMapVolumeSource(name=config_map, optional=True))) volumes.append(Volume(name="{}-config".format(app_spec.name), configMap=ConfigMapVolumeSource(name=app_spec.name, optional=True))) if self._use_in_memory_emptydirs: @@ -146,6 +153,10 @@ def _make_volumes(self, app_spec): def _make_volume_mounts(self, app_spec): volume_mounts = [] + if app_spec.config_maps: + for config_map in app_spec.config_maps: + volume_mounts.append(VolumeMount(name="{}-config".format(config_map), + readOnly=True, mountPath="/var/run/config/{}/".format(config_map))) volume_mounts.append( VolumeMount(name="{}-config".format(app_spec.name), readOnly=True, mountPath="/var/run/config/fiaas/")) volume_mounts.append(VolumeMount(name="tmp", readOnly=False, mountPath="/tmp")) @@ -244,6 +255,19 @@ def _build_fiaas_env(config): return env +def _add_config_maps(app_spec): + """ + adds the configMaps to envFrom. Inserts user-defined configMaps first so the default configMap takes precedence in + case of key-collisions + """ + config_maps = [] + if app_spec.config_maps: + for config_map in app_spec.config_maps: + config_maps.append(EnvFromSource(configMapRef=ConfigMapEnvSource(name=config_map, optional=True))) + config_maps.append(EnvFromSource(configMapRef=ConfigMapEnvSource(name=app_spec.name, optional=True))) + return config_maps + + def _build_global_env(global_env): """ global_env key/value are added as is and with the key prefix FIAAS_ diff --git a/fiaas_deploy_daemon/specs/models.py b/fiaas_deploy_daemon/specs/models.py index 4587e862..2d49867f 100644 --- a/fiaas_deploy_daemon/specs/models.py +++ b/fiaas_deploy_daemon/specs/models.py @@ -39,7 +39,8 @@ class AppSpec(namedtuple("AppSpec", [ "strongbox", "singleton", "ingress_tls", - "secrets" + "secrets", + "config_maps" ])): __slots__ = () diff --git a/fiaas_deploy_daemon/specs/v3/defaults.yml b/fiaas_deploy_daemon/specs/v3/defaults.yml index fba00214..bfc705e6 100644 --- a/fiaas_deploy_daemon/specs/v3/defaults.yml +++ b/fiaas_deploy_daemon/specs/v3/defaults.yml @@ -100,3 +100,4 @@ extensions: enabled: false # This is dynamically set based on the value for --use-ingress-tls passed to the instance certificate_issuer: # the name of certificate-issuer cert-manager should use secrets: {} +config_maps: [] diff --git a/fiaas_deploy_daemon/specs/v3/factory.py b/fiaas_deploy_daemon/specs/v3/factory.py index a765fd1e..88fa1560 100644 --- a/fiaas_deploy_daemon/specs/v3/factory.py +++ b/fiaas_deploy_daemon/specs/v3/factory.py @@ -67,6 +67,7 @@ def __call__(self, uid, name, image, teams, tags, app_config, deployment_id, nam ingress_tls=IngressTlsSpec(enabled=lookup["extensions"]["tls"]["enabled"], certificate_issuer=lookup["extensions"]["tls"]["certificate_issuer"]), secrets=self._secrets_specs(lookup["extensions"]["secrets"]), + config_maps=lookup["config_maps"], ) return app_spec diff --git a/tests/fiaas_deploy_daemon/conftest.py b/tests/fiaas_deploy_daemon/conftest.py index b5db78b3..69854ec6 100644 --- a/tests/fiaas_deploy_daemon/conftest.py +++ b/tests/fiaas_deploy_daemon/conftest.py @@ -65,7 +65,8 @@ def app_spec(): strongbox=StrongboxSpec(enabled=False, iam_role=None, aws_region="eu-west-1", groups=None), singleton=False, ingress_tls=IngressTlsSpec(enabled=False, certificate_issuer=None), - secrets=[] + secrets=[], + config_maps=[] ) diff --git a/tests/fiaas_deploy_daemon/deployer/kubernetes/test_ingress_deploy.py b/tests/fiaas_deploy_daemon/deployer/kubernetes/test_ingress_deploy.py index f9c0dabe..3e78331b 100644 --- a/tests/fiaas_deploy_daemon/deployer/kubernetes/test_ingress_deploy.py +++ b/tests/fiaas_deploy_daemon/deployer/kubernetes/test_ingress_deploy.py @@ -69,7 +69,8 @@ def app_spec(**kwargs): strongbox=StrongboxSpec(enabled=False, iam_role=None, aws_region="eu-west-1", groups=None), singleton=False, ingress_tls=IngressTlsSpec(enabled=False, certificate_issuer=None), - secrets=[] + secrets=[], + config_maps=[] ) return default_app_spec._replace(**kwargs) diff --git a/tests/fiaas_deploy_daemon/e2e_expected/v3-multiple-configmap-deployment.yml b/tests/fiaas_deploy_daemon/e2e_expected/v3-multiple-configmap-deployment.yml new file mode 100644 index 00000000..f6e3a6ff --- /dev/null +++ b/tests/fiaas_deploy_daemon/e2e_expected/v3-multiple-configmap-deployment.yml @@ -0,0 +1,215 @@ + +# Copyright 2017-2020 The FIAAS Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + annotations: {} + labels: + app: v3-data-examples-multiple-config-maps + fiaas/deployed_by: "" + fiaas/deployment_id: DEPLOYMENT_ID + fiaas/version: VERSION + global/label: "true" + deployment/label: "true" + name: v3-data-examples-multiple-config-maps + namespace: default + ownerReferences: + - apiVersion: fiaas.schibsted.io/v1 + blockOwnerDeletion: true + controller: true + kind: Application + name: v3-data-examples-multiple-config-maps + finalizers: [] +spec: + replicas: 2 + revisionHistoryLimit: 5 + selector: + matchLabels: + app: v3-data-examples-multiple-config-maps + strategy: + rollingUpdate: + maxSurge: "25%" + maxUnavailable: 0 + type: RollingUpdate + template: + metadata: + annotations: + prometheus.io/path: /_/metrics + prometheus.io/port: "8080" + prometheus.io/scrape: "true" + labels: + app: v3-data-examples-multiple-config-maps + fiaas/deployed_by: "" + fiaas/deployment_id: DEPLOYMENT_ID + fiaas/status: active + fiaas/version: VERSION + global/label: "true" + pod/label: "true" + name: v3-data-examples-multiple-config-maps + namespace: default + ownerReferences: [] + finalizers: [] + spec: + automountServiceAccountToken: false + containers: + - command: [] + env: + - name: ARTIFACT_NAME + value: v3-data-examples-multiple-config-maps + - name: CONSTRETTO_TAGS + value: kubernetes-test,kubernetes,test + - name: FIAAS_ARTIFACT_NAME + value: v3-data-examples-multiple-config-maps + - name: FIAAS_ENVIRONMENT + value: test + - name: FIAAS_IMAGE + value: IMAGE + - name: FIAAS_INFRASTRUCTURE + value: diy + - name: FIAAS_LIMITS_CPU + valueFrom: + resourceFieldRef: + containerName: v3-data-examples-multiple-config-maps + resource: limits.cpu + divisor: "1" + - name: FIAAS_LIMITS_MEMORY + valueFrom: + resourceFieldRef: + containerName: v3-data-examples-multiple-config-maps + resource: limits.memory + divisor: "1" + - name: FIAAS_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + apiVersion: "v1" + - name: FIAAS_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + apiVersion: "v1" + - name: FIAAS_REQUESTS_CPU + valueFrom: + resourceFieldRef: + containerName: v3-data-examples-multiple-config-maps + resource: requests.cpu + divisor: "1" + - name: FIAAS_REQUESTS_MEMORY + valueFrom: + resourceFieldRef: + containerName: v3-data-examples-multiple-config-maps + resource: requests.memory + divisor: "1" + - name: FIAAS_VERSION + value: VERSION + - name: FINN_ENV + value: test + - name: IMAGE + value: IMAGE + - name: LOG_FORMAT + value: plain + - name: LOG_STDOUT + value: "true" + - name: VERSION + value: VERSION + envFrom: + - configMapRef: + name: test1 + optional: true + - configMapRef: + name: test2 + optional: true + - configMapRef: + name: v3-data-examples-multiple-config-maps + optional: true + image: IMAGE + imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 3 + httpGet: + path: /_/health + port: http + scheme: HTTP + httpHeaders: [] + initialDelaySeconds: 10 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + name: v3-data-examples-multiple-config-maps + ports: + - containerPort: 8080 + name: http + protocol: TCP + readinessProbe: + failureThreshold: 3 + httpGet: + path: /_/ready + port: http + scheme: HTTP + httpHeaders: [] + initialDelaySeconds: 10 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + resources: + limits: + cpu: 400m + memory: 512Mi + requests: + cpu: 200m + memory: 256Mi + volumeMounts: + - mountPath: /var/run/secrets/fiaas/ + name: v3-data-examples-multiple-config-maps-secret + readOnly: true + - mountPath: /var/run/config/test1/ + name: test1-config + readOnly: true + - mountPath: /var/run/config/test2/ + name: test2-config + readOnly: true + - mountPath: /var/run/config/fiaas/ + name: v3-data-examples-multiple-config-maps-config + readOnly: true + - mountPath: /tmp + name: tmp + dnsPolicy: ClusterFirst + restartPolicy: Always + serviceAccountName: default + terminationGracePeriodSeconds: 30 + volumes: + - name: v3-data-examples-multiple-config-maps-secret + secret: + defaultMode: 420 + optional: true + secretName: v3-data-examples-multiple-config-maps + - configMap: + defaultMode: 420 + name: test1 + optional: true + name: test1-config + - configMap: + defaultMode: 420 + name: test2 + optional: true + name: test2-config + - configMap: + defaultMode: 420 + name: v3-data-examples-multiple-config-maps + optional: true + name: v3-data-examples-multiple-config-maps-config + - name: tmp + initContainers: [] + imagePullSecrets: [] diff --git a/tests/fiaas_deploy_daemon/e2e_expected/v3-no-extra-configmap-deployment.yml b/tests/fiaas_deploy_daemon/e2e_expected/v3-no-extra-configmap-deployment.yml new file mode 100644 index 00000000..3606bd0b --- /dev/null +++ b/tests/fiaas_deploy_daemon/e2e_expected/v3-no-extra-configmap-deployment.yml @@ -0,0 +1,193 @@ + +# Copyright 2017-2020 The FIAAS Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + annotations: {} + labels: + app: v3-data-examples-v3minimal + fiaas/deployed_by: "" + fiaas/deployment_id: DEPLOYMENT_ID + fiaas/version: VERSION + global/label: "true" + deployment/label: "true" + name: v3-data-examples-v3minimal + namespace: default + ownerReferences: + - apiVersion: fiaas.schibsted.io/v1 + blockOwnerDeletion: true + controller: true + kind: Application + name: v3-data-examples-v3minimal + finalizers: [] +spec: + replicas: 2 + revisionHistoryLimit: 5 + selector: + matchLabels: + app: v3-data-examples-v3minimal + strategy: + rollingUpdate: + maxSurge: "25%" + maxUnavailable: 0 + type: RollingUpdate + template: + metadata: + annotations: + prometheus.io/path: /_/metrics + prometheus.io/port: "8080" + prometheus.io/scrape: "true" + labels: + app: v3-data-examples-v3minimal + fiaas/deployed_by: "" + fiaas/deployment_id: DEPLOYMENT_ID + fiaas/status: active + fiaas/version: VERSION + global/label: "true" + pod/label: "true" + name: v3-data-examples-v3minimal + namespace: default + ownerReferences: [] + finalizers: [] + spec: + automountServiceAccountToken: false + containers: + - command: [] + env: + - name: ARTIFACT_NAME + value: v3-data-examples-v3minimal + - name: CONSTRETTO_TAGS + value: kubernetes-test,kubernetes,test + - name: FIAAS_ARTIFACT_NAME + value: v3-data-examples-v3minimal + - name: FIAAS_ENVIRONMENT + value: test + - name: FIAAS_IMAGE + value: IMAGE + - name: FIAAS_INFRASTRUCTURE + value: diy + - name: FIAAS_LIMITS_CPU + valueFrom: + resourceFieldRef: + containerName: v3-data-examples-v3minimal + resource: limits.cpu + divisor: "1" + - name: FIAAS_LIMITS_MEMORY + valueFrom: + resourceFieldRef: + containerName: v3-data-examples-v3minimal + resource: limits.memory + divisor: "1" + - name: FIAAS_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + apiVersion: "v1" + - name: FIAAS_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + apiVersion: "v1" + - name: FIAAS_REQUESTS_CPU + valueFrom: + resourceFieldRef: + containerName: v3-data-examples-v3minimal + resource: requests.cpu + divisor: "1" + - name: FIAAS_REQUESTS_MEMORY + valueFrom: + resourceFieldRef: + containerName: v3-data-examples-v3minimal + resource: requests.memory + divisor: "1" + - name: FIAAS_VERSION + value: VERSION + - name: FINN_ENV + value: test + - name: IMAGE + value: IMAGE + - name: LOG_FORMAT + value: plain + - name: LOG_STDOUT + value: "true" + - name: VERSION + value: VERSION + envFrom: + - configMapRef: + name: v3-data-examples-v3minimal + optional: true + image: IMAGE + imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 3 + httpGet: + path: /_/health + port: http + scheme: HTTP + httpHeaders: [] + initialDelaySeconds: 10 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + name: v3-data-examples-v3minimal + ports: + - containerPort: 8080 + name: http + protocol: TCP + readinessProbe: + failureThreshold: 3 + httpGet: + path: /_/ready + port: http + scheme: HTTP + httpHeaders: [] + initialDelaySeconds: 10 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + resources: + limits: + cpu: 400m + memory: 512Mi + requests: + cpu: 200m + memory: 256Mi + volumeMounts: + - mountPath: /var/run/secrets/fiaas/ + name: v3-data-examples-v3minimal-secret + readOnly: true + - mountPath: /var/run/config/fiaas/ + name: v3-data-examples-v3minimal-config + readOnly: true + - mountPath: /tmp + name: tmp + dnsPolicy: ClusterFirst + restartPolicy: Always + serviceAccountName: default + terminationGracePeriodSeconds: 30 + volumes: + - name: v3-data-examples-v3minimal-secret + secret: + defaultMode: 420 + optional: true + secretName: v3-data-examples-v3minimal + - configMap: + defaultMode: 420 + name: v3-data-examples-v3minimal + optional: true + name: v3-data-examples-v3minimal-config + - name: tmp + initContainers: [] + imagePullSecrets: [] diff --git a/tests/fiaas_deploy_daemon/e2e_expected/v3-single-extra-configmap-deployment.yml b/tests/fiaas_deploy_daemon/e2e_expected/v3-single-extra-configmap-deployment.yml new file mode 100644 index 00000000..fe2cf04d --- /dev/null +++ b/tests/fiaas_deploy_daemon/e2e_expected/v3-single-extra-configmap-deployment.yml @@ -0,0 +1,204 @@ + +# Copyright 2017-2020 The FIAAS Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + annotations: {} + labels: + app: v3-data-examples-single-extra-config-map + fiaas/deployed_by: "" + fiaas/deployment_id: DEPLOYMENT_ID + fiaas/version: VERSION + global/label: "true" + deployment/label: "true" + name: v3-data-examples-single-extra-config-map + namespace: default + ownerReferences: + - apiVersion: fiaas.schibsted.io/v1 + blockOwnerDeletion: true + controller: true + kind: Application + name: v3-data-examples-single-extra-config-map + finalizers: [] +spec: + replicas: 2 + revisionHistoryLimit: 5 + selector: + matchLabels: + app: v3-data-examples-single-extra-config-map + strategy: + rollingUpdate: + maxSurge: "25%" + maxUnavailable: 0 + type: RollingUpdate + template: + metadata: + annotations: + prometheus.io/path: /_/metrics + prometheus.io/port: "8080" + prometheus.io/scrape: "true" + labels: + app: v3-data-examples-single-extra-config-map + fiaas/deployed_by: "" + fiaas/deployment_id: DEPLOYMENT_ID + fiaas/status: active + fiaas/version: VERSION + global/label: "true" + pod/label: "true" + name: v3-data-examples-single-extra-config-map + namespace: default + ownerReferences: [] + finalizers: [] + spec: + automountServiceAccountToken: false + containers: + - command: [] + env: + - name: ARTIFACT_NAME + value: v3-data-examples-single-extra-config-map + - name: CONSTRETTO_TAGS + value: kubernetes-test,kubernetes,test + - name: FIAAS_ARTIFACT_NAME + value: v3-data-examples-single-extra-config-map + - name: FIAAS_ENVIRONMENT + value: test + - name: FIAAS_IMAGE + value: IMAGE + - name: FIAAS_INFRASTRUCTURE + value: diy + - name: FIAAS_LIMITS_CPU + valueFrom: + resourceFieldRef: + containerName: v3-data-examples-single-extra-config-map + resource: limits.cpu + divisor: "1" + - name: FIAAS_LIMITS_MEMORY + valueFrom: + resourceFieldRef: + containerName: v3-data-examples-single-extra-config-map + resource: limits.memory + divisor: "1" + - name: FIAAS_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + apiVersion: "v1" + - name: FIAAS_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + apiVersion: "v1" + - name: FIAAS_REQUESTS_CPU + valueFrom: + resourceFieldRef: + containerName: v3-data-examples-single-extra-config-map + resource: requests.cpu + divisor: "1" + - name: FIAAS_REQUESTS_MEMORY + valueFrom: + resourceFieldRef: + containerName: v3-data-examples-single-extra-config-map + resource: requests.memory + divisor: "1" + - name: FIAAS_VERSION + value: VERSION + - name: FINN_ENV + value: test + - name: IMAGE + value: IMAGE + - name: LOG_FORMAT + value: plain + - name: LOG_STDOUT + value: "true" + - name: VERSION + value: VERSION + envFrom: + - configMapRef: + name: test1 + optional: true + - configMapRef: + name: v3-data-examples-single-extra-config-map + optional: true + image: IMAGE + imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 3 + httpGet: + path: /_/health + port: http + scheme: HTTP + httpHeaders: [] + initialDelaySeconds: 10 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + name: v3-data-examples-single-extra-config-map + ports: + - containerPort: 8080 + name: http + protocol: TCP + readinessProbe: + failureThreshold: 3 + httpGet: + path: /_/ready + port: http + scheme: HTTP + httpHeaders: [] + initialDelaySeconds: 10 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + resources: + limits: + cpu: 400m + memory: 512Mi + requests: + cpu: 200m + memory: 256Mi + volumeMounts: + - mountPath: /var/run/secrets/fiaas/ + name: v3-data-examples-single-extra-config-map-secret + readOnly: true + - mountPath: /var/run/config/test1/ + name: test1-config + readOnly: true + - mountPath: /var/run/config/fiaas/ + name: v3-data-examples-single-extra-config-map-config + readOnly: true + - mountPath: /tmp + name: tmp + dnsPolicy: ClusterFirst + restartPolicy: Always + serviceAccountName: default + terminationGracePeriodSeconds: 30 + volumes: + - name: v3-data-examples-single-extra-config-map-secret + secret: + defaultMode: 420 + optional: true + secretName: v3-data-examples-single-extra-config-map + - configMap: + defaultMode: 420 + name: test1 + optional: true + name: test1-config + - configMap: + defaultMode: 420 + name: v3-data-examples-single-extra-config-map + optional: true + name: v3-data-examples-single-extra-config-map-config + - name: tmp + initContainers: [] + imagePullSecrets: [] diff --git a/tests/fiaas_deploy_daemon/e2e_expected/v3full-deployment.yml b/tests/fiaas_deploy_daemon/e2e_expected/v3full-deployment.yml index 3889bda3..dd5e7b29 100644 --- a/tests/fiaas_deploy_daemon/e2e_expected/v3full-deployment.yml +++ b/tests/fiaas_deploy_daemon/e2e_expected/v3full-deployment.yml @@ -139,6 +139,12 @@ spec: - name: VERSION value: VERSION envFrom: + - configMapRef: + name: test1 + optional: true + - configMapRef: + name: test2 + optional: true - configMapRef: name: v3-data-examples-full optional: true @@ -184,6 +190,12 @@ spec: - mountPath: /var/run/secrets/fiaas/ name: v3-data-examples-full-secret readOnly: true + - mountPath: /var/run/config/test1/ + name: test1-config + readOnly: true + - mountPath: /var/run/config/test2/ + name: test2-config + readOnly: true - mountPath: /var/run/config/fiaas/ name: v3-data-examples-full-config readOnly: true @@ -231,6 +243,16 @@ spec: name: fiaas-secrets-init-container optional: true name: fiaas-secrets-init-container-config + - configMap: + defaultMode: 420 + name: test1 + optional: true + name: test1-config + - configMap: + defaultMode: 420 + name: test2 + optional: true + name: test2-config - configMap: defaultMode: 420 name: v3-data-examples-full diff --git a/tests/fiaas_deploy_daemon/specs/v3/data/examples/full.yml b/tests/fiaas_deploy_daemon/specs/v3/data/examples/full.yml index af18edcd..c4932c75 100644 --- a/tests/fiaas_deploy_daemon/specs/v3/data/examples/full.yml +++ b/tests/fiaas_deploy_daemon/specs/v3/data/examples/full.yml @@ -105,3 +105,6 @@ extensions: groups: - secretgroup1 - secretgroup2 +config_maps: + - test1 + - test2 diff --git a/tests/fiaas_deploy_daemon/specs/v3/data/examples/multiple_config_maps.yml b/tests/fiaas_deploy_daemon/specs/v3/data/examples/multiple_config_maps.yml new file mode 100644 index 00000000..e749b6ed --- /dev/null +++ b/tests/fiaas_deploy_daemon/specs/v3/data/examples/multiple_config_maps.yml @@ -0,0 +1,19 @@ + +# Copyright 2017-2020 The FIAAS Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +--- +version: 3 +config_maps: + - test1 + - test2 diff --git a/tests/fiaas_deploy_daemon/specs/v3/data/examples/single_extra_config_map.yml b/tests/fiaas_deploy_daemon/specs/v3/data/examples/single_extra_config_map.yml new file mode 100644 index 00000000..b86f7dea --- /dev/null +++ b/tests/fiaas_deploy_daemon/specs/v3/data/examples/single_extra_config_map.yml @@ -0,0 +1,18 @@ + +# Copyright 2017-2020 The FIAAS Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +--- +version: 3 +config_maps: + - test1 diff --git a/tests/fiaas_deploy_daemon/specs/v3/test_v3factory.py b/tests/fiaas_deploy_daemon/specs/v3/test_v3factory.py index 18bdb832..5584a2d9 100644 --- a/tests/fiaas_deploy_daemon/specs/v3/test_v3factory.py +++ b/tests/fiaas_deploy_daemon/specs/v3/test_v3factory.py @@ -87,7 +87,7 @@ "strongbox.enabled": False, "strongbox.iam_role": None, "strongbox.groups": None, - "strongbox.aws_region": "eu-west-1", + "strongbox.aws_region": "eu-west-1" }, "autoscaling_disabled": { "autoscaler.enabled": False, @@ -95,6 +95,10 @@ "autoscaler.max_replicas": 3, "autoscaler.cpu_threshold_percentage": 50, }, + "multiple_config_maps": { + "config_maps[0]": "test1", + "config_maps[1]": "test2" + }, "multiple_hosts_multiple_paths": { "ingresses[0].host": None, "ingresses[0].pathmappings[0].path": "/0noport", @@ -272,6 +276,8 @@ "strongbox.iam_role": "arn:aws:iam::12345678:role/the-role-name", "strongbox.groups[0]": "secretgroup1", "strongbox.groups[1]": "secretgroup2", + "config_maps[0]": "test1", + "config_maps[1]": "test2" }, "liveness_exec_readiness_http": { diff --git a/tests/fiaas_deploy_daemon/test_e2e.py b/tests/fiaas_deploy_daemon/test_e2e.py index 9aa5ffa5..c9918117 100644 --- a/tests/fiaas_deploy_daemon/test_e2e.py +++ b/tests/fiaas_deploy_daemon/test_e2e.py @@ -231,6 +231,27 @@ def ready(): ("v3/data/examples/tls_enabled_multiple.yml", { Ingress: "e2e_expected/tls-ingress-multiple.yml", }), + ("v3/data/examples/multiple_config_maps.yml", { + Deployment: "e2e_expected/v3-multiple-configmap-deployment.yml", + }, AdditionalLabelsOrAnnotations( + _global={"global/label": "true"}, + deployment={"deployment/label": "true"}, + pod={"pod/label": "true"} + )), + ("v3/data/examples/v3minimal.yml", { + Deployment: "e2e_expected/v3-no-extra-configmap-deployment.yml", + }, AdditionalLabelsOrAnnotations( + _global={"global/label": "true"}, + deployment={"deployment/label": "true"}, + pod={"pod/label": "true"} + )), + ("v3/data/examples/single_extra_config_map.yml", { + Deployment: "e2e_expected/v3-single-extra-configmap-deployment.yml", + }, AdditionalLabelsOrAnnotations( + _global={"global/label": "true"}, + deployment={"deployment/label": "true"}, + pod={"pod/label": "true"} + )), )) def custom_resource_definition(self, request, k8s_version): additional_labels = None