From 32b0dcb6d3cb955e392ac6c3cae4fbef0cb85d2f Mon Sep 17 00:00:00 2001 From: Simen Skoglund Date: Fri, 28 Aug 2020 14:40:27 +0200 Subject: [PATCH 01/18] proposal for multiple configmaps #112 --- .../kubernetes/deployment/deployer.py | 12 +++++++++++- fiaas_deploy_daemon/specs/models.py | 3 ++- fiaas_deploy_daemon/specs/v3/defaults.yml | 1 + fiaas_deploy_daemon/specs/v3/factory.py | 1 + tests/fiaas_deploy_daemon/conftest.py | 3 ++- .../kubernetes/test_ingress_deploy.py | 3 ++- .../specs/v3/data/examples/full.yml | 3 +++ .../v3/data/examples/multiple_config_maps.yml | 19 +++++++++++++++++++ .../specs/v3/test_v3factory.py | 8 +++++++- 9 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 tests/fiaas_deploy_daemon/specs/v3/data/examples/multiple_config_maps.yml diff --git a/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py b/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py index 76602686..d8b78549 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, @@ -244,6 +245,15 @@ def _build_fiaas_env(config): return env +def _add_config_maps(app_spec): + config_maps = [EnvFromSource(configMapRef=ConfigMapEnvSource(name=app_spec.name, optional=True))] + if app_spec.config_maps: + for config_map in app_spec.config_maps: + config_maps.append(EnvFromSource(configMapRef=ConfigMapEnvSource(name=config_map, optional=True))) + return config_maps + else: + 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..978d3206 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: [] \ No newline at end of file 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 aacf9f01..2622e121 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 d68bde33..7a807311 100644 --- a/tests/fiaas_deploy_daemon/deployer/kubernetes/test_ingress_deploy.py +++ b/tests/fiaas_deploy_daemon/deployer/kubernetes/test_ingress_deploy.py @@ -67,7 +67,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/specs/v3/data/examples/full.yml b/tests/fiaas_deploy_daemon/specs/v3/data/examples/full.yml index af18edcd..598626c5 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" \ No newline at end of file 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..9b77e457 --- /dev/null +++ b/tests/fiaas_deploy_daemon/specs/v3/data/examples/multiple_config_maps.yml @@ -0,0 +1,19 @@ + +# Copyright 2017-2019 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" \ No newline at end of file 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": { From c933e1caab7aefbc09dce9342bbe2852caef5d79 Mon Sep 17 00:00:00 2001 From: Simen Skoglund Date: Fri, 28 Aug 2020 14:54:46 +0200 Subject: [PATCH 02/18] fix newlines --- fiaas_deploy_daemon/specs/v3/defaults.yml | 2 +- tests/fiaas_deploy_daemon/specs/v3/data/examples/full.yml | 2 +- .../specs/v3/data/examples/multiple_config_maps.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fiaas_deploy_daemon/specs/v3/defaults.yml b/fiaas_deploy_daemon/specs/v3/defaults.yml index 978d3206..bfc705e6 100644 --- a/fiaas_deploy_daemon/specs/v3/defaults.yml +++ b/fiaas_deploy_daemon/specs/v3/defaults.yml @@ -100,4 +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: [] \ No newline at end of file +config_maps: [] 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 598626c5..71ecab0c 100644 --- a/tests/fiaas_deploy_daemon/specs/v3/data/examples/full.yml +++ b/tests/fiaas_deploy_daemon/specs/v3/data/examples/full.yml @@ -107,4 +107,4 @@ extensions: - secretgroup2 config_maps: - "test1" - - "test2" \ No newline at end of file + - "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 index 9b77e457..10fdee97 100644 --- 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 @@ -16,4 +16,4 @@ version: 3 config_maps: - "test1" - - "test2" \ No newline at end of file + - "test2" From 6b410fb88e5aec6b0e45b563f9301fd39aead7db Mon Sep 17 00:00:00 2001 From: Simen Skoglund Date: Fri, 28 Aug 2020 17:15:01 +0200 Subject: [PATCH 03/18] Add docs and add integration tests --- docs/v3_spec.md | 14 ++ .../kubernetes/deployment/deployer.py | 3 +- .../kubernetes/deployment/test_configmaps.py | 0 .../v3-multiple-configmap-deployment.yml | 199 ++++++++++++++++++ .../v3-no-extra-configmap-deployment.yml | 193 +++++++++++++++++ .../v3-single-extra-configmap-deployment.yml | 196 +++++++++++++++++ .../e2e_expected/v3full-deployment.yml | 6 + .../specs/v3/data/examples/full.yml | 4 +- .../v3/data/examples/multiple_config_maps.yml | 4 +- .../data/examples/single_extra_config_map.yml | 18 ++ tests/fiaas_deploy_daemon/test_e2e.py | 9 + 11 files changed, 640 insertions(+), 6 deletions(-) create mode 100644 tests/fiaas_deploy_daemon/deployer/kubernetes/deployment/test_configmaps.py create mode 100644 tests/fiaas_deploy_daemon/e2e_expected/v3-multiple-configmap-deployment.yml create mode 100644 tests/fiaas_deploy_daemon/e2e_expected/v3-no-extra-configmap-deployment.yml create mode 100644 tests/fiaas_deploy_daemon/e2e_expected/v3-single-extra-configmap-deployment.yml create mode 100644 tests/fiaas_deploy_daemon/specs/v3/data/examples/single_extra_config_map.yml diff --git a/docs/v3_spec.md b/docs/v3_spec.md index eaa7c7d3..2a993bb9 100644 --- a/docs/v3_spec.md +++ b/docs/v3_spec.md @@ -680,6 +680,20 @@ Kubernetes apiserver. If in doubt, leave this disabled. admin_access: False ``` +## config_map + +| **Type** | **Required** | +|----------|--------------| +| list | no | + +Add extra configMaps from fiaas to your application, by default a configMap named the same as your application will be +added to your app by default. + +```yaml +config_maps: + - yourconfigmap +``` + ## extensions diff --git a/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py b/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py index d8b78549..a74fe81c 100644 --- a/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py +++ b/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py @@ -251,8 +251,7 @@ def _add_config_maps(app_spec): for config_map in app_spec.config_maps: config_maps.append(EnvFromSource(configMapRef=ConfigMapEnvSource(name=config_map, optional=True))) return config_maps - else: - return config_maps + return config_maps def _build_global_env(global_env): """ diff --git a/tests/fiaas_deploy_daemon/deployer/kubernetes/deployment/test_configmaps.py b/tests/fiaas_deploy_daemon/deployer/kubernetes/deployment/test_configmaps.py new file mode 100644 index 00000000..e69de29b 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..82fbe1f4 --- /dev/null +++ b/tests/fiaas_deploy_daemon/e2e_expected/v3-multiple-configmap-deployment.yml @@ -0,0 +1,199 @@ + +# Copyright 2017-2019 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: v3-data-examples-multiple-config-maps + optional: true + - configMapRef: + name: test1 + optional: true + - configMapRef: + name: test2 + 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/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: 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..88423786 --- /dev/null +++ b/tests/fiaas_deploy_daemon/e2e_expected/v3-no-extra-configmap-deployment.yml @@ -0,0 +1,193 @@ + +# Copyright 2017-2019 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..d13db2d8 --- /dev/null +++ b/tests/fiaas_deploy_daemon/e2e_expected/v3-single-extra-configmap-deployment.yml @@ -0,0 +1,196 @@ + +# Copyright 2017-2019 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: v3-data-examples-single-extra-config-map + optional: true + - configMapRef: + name: test1 + 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/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: 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 c9557f6c..0801d62a 100644 --- a/tests/fiaas_deploy_daemon/e2e_expected/v3full-deployment.yml +++ b/tests/fiaas_deploy_daemon/e2e_expected/v3full-deployment.yml @@ -141,6 +141,12 @@ spec: - configMapRef: name: v3-data-examples-full optional: true + - configMapRef: + name: test1 + optional: true + - configMapRef: + name: test2 + optional: true image: IMAGE imagePullPolicy: IfNotPresent livenessProbe: 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 71ecab0c..c4932c75 100644 --- a/tests/fiaas_deploy_daemon/specs/v3/data/examples/full.yml +++ b/tests/fiaas_deploy_daemon/specs/v3/data/examples/full.yml @@ -106,5 +106,5 @@ extensions: - secretgroup1 - secretgroup2 config_maps: - - "test1" - - "test2" + - 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 index 10fdee97..236380f8 100644 --- 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 @@ -15,5 +15,5 @@ --- version: 3 config_maps: - - "test1" - - "test2" + - 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..fdcb9191 --- /dev/null +++ b/tests/fiaas_deploy_daemon/specs/v3/data/examples/single_extra_config_map.yml @@ -0,0 +1,18 @@ + +# Copyright 2017-2019 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/test_e2e.py b/tests/fiaas_deploy_daemon/test_e2e.py index f30c5150..74ae9ebe 100644 --- a/tests/fiaas_deploy_daemon/test_e2e.py +++ b/tests/fiaas_deploy_daemon/test_e2e.py @@ -230,6 +230,15 @@ 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", + }), + ("v3/data/examples/v3minimal.yml", { + Deployment: "e2e_expected/v3-no-extra-configmap-deployment.yml", + }), + ("v3/data/examples/single_extra_config_map.yml", { + Deployment: "e2e_expected/v3-single-extra-configmap-deployment.yml", + }), )) def custom_resource_definition(self, request, k8s_version): additional_labels = None From c3ccfaaa5695b803bc97aebba2de2a395fcc9614 Mon Sep 17 00:00:00 2001 From: Simen Skoglund Date: Fri, 28 Aug 2020 17:15:23 +0200 Subject: [PATCH 04/18] Remove unused file --- .../deployer/kubernetes/deployment/test_configmaps.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 tests/fiaas_deploy_daemon/deployer/kubernetes/deployment/test_configmaps.py diff --git a/tests/fiaas_deploy_daemon/deployer/kubernetes/deployment/test_configmaps.py b/tests/fiaas_deploy_daemon/deployer/kubernetes/deployment/test_configmaps.py deleted file mode 100644 index e69de29b..00000000 From fa814666c2e7cf3901f2582bb12bf8998bbae5b6 Mon Sep 17 00:00:00 2001 From: Simen Skoglund Date: Tue, 1 Sep 2020 12:04:25 +0200 Subject: [PATCH 05/18] Update docs/v3_spec.md Co-authored-by: Greg Jones --- docs/v3_spec.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/v3_spec.md b/docs/v3_spec.md index 2a993bb9..7aac13ea 100644 --- a/docs/v3_spec.md +++ b/docs/v3_spec.md @@ -686,8 +686,8 @@ admin_access: False |----------|--------------| | list | no | -Add extra configMaps from fiaas to your application, by default a configMap named the same as your application will be -added to your app by default. +Add extra configMaps to your application. By default a configMap named the same as your application will be +added. ```yaml config_maps: From 348cf0baf7192e207e7e3e9b320bad467a1652dd Mon Sep 17 00:00:00 2001 From: Simen Skoglund Date: Thu, 3 Sep 2020 15:38:27 +0200 Subject: [PATCH 06/18] add configMap volumes for user-defined configMaps --- .../deployer/kubernetes/deployment/deployer.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py b/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py index a74fe81c..e03f45f6 100644 --- a/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py +++ b/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py @@ -136,6 +136,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.insert(0, 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: From 69b1b9a2157d68437354ca748a68f44453d8ebcd Mon Sep 17 00:00:00 2001 From: Simen Skoglund Date: Thu, 3 Sep 2020 15:39:57 +0200 Subject: [PATCH 07/18] put user-defined configMaps first and comment function --- .../deployer/kubernetes/deployment/deployer.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py b/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py index e03f45f6..6fbed869 100644 --- a/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py +++ b/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py @@ -250,13 +250,17 @@ def _build_fiaas_env(config): 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 = [EnvFromSource(configMapRef=ConfigMapEnvSource(name=app_spec.name, optional=True))] if app_spec.config_maps: for config_map in app_spec.config_maps: - config_maps.append(EnvFromSource(configMapRef=ConfigMapEnvSource(name=config_map, optional=True))) - return config_maps + config_maps.insert(0, EnvFromSource(configMapRef=ConfigMapEnvSource(name=config_map, 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_ From 205c01f388b2f8030e1160a1d96701ae1d03e924 Mon Sep 17 00:00:00 2001 From: Simen Skoglund Date: Thu, 3 Sep 2020 15:46:24 +0200 Subject: [PATCH 08/18] add new configMaps when making volume mounts --- .../deployer/kubernetes/deployment/deployer.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py b/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py index 6fbed869..e3694310 100644 --- a/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py +++ b/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py @@ -151,6 +151,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.insert(0, VolumeMount(name="{}-config".format(config_map), + readOnly=True, mountPath="/var/run/config/fiaas/")) 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")) From 8fc2c9863d6639c0a6056f3eaeb3fe176d7dcf69 Mon Sep 17 00:00:00 2001 From: Simen Skoglund Date: Mon, 7 Sep 2020 13:38:24 +0200 Subject: [PATCH 09/18] more efficient appending of configmaps --- .../deployer/kubernetes/deployment/deployer.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py b/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py index e3694310..e9c75b90 100644 --- a/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py +++ b/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py @@ -138,7 +138,7 @@ def _make_volumes(self, app_spec): volumes = [] if app_spec.config_maps: for config_map in app_spec.config_maps: - volumes.insert(0, Volume(name="{}-config".format(config_map), + 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))) @@ -153,8 +153,8 @@ def _make_volume_mounts(self, app_spec): volume_mounts = [] if app_spec.config_maps: for config_map in app_spec.config_maps: - volume_mounts.insert(0, VolumeMount(name="{}-config".format(config_map), - readOnly=True, mountPath="/var/run/config/fiaas/")) + 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")) @@ -258,10 +258,11 @@ 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 = [EnvFromSource(configMapRef=ConfigMapEnvSource(name=app_spec.name, optional=True))] + config_maps = [] if app_spec.config_maps: for config_map in app_spec.config_maps: - config_maps.insert(0, EnvFromSource(configMapRef=ConfigMapEnvSource(name=config_map, optional=True))) + 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 From 55c390e66f4d373d98a828075ac7ab29f691b879 Mon Sep 17 00:00:00 2001 From: Simen Skoglund Date: Mon, 16 Nov 2020 14:40:00 +0100 Subject: [PATCH 10/18] Update documentation and fix tests --- docs/v3_spec.md | 7 +++--- .../v3-multiple-configmap-deployment.yml | 22 ++++++++++++++++--- .../v3-single-extra-configmap-deployment.yml | 12 ++++++++-- .../e2e_expected/v3full-deployment.yml | 22 ++++++++++++++++--- 4 files changed, 52 insertions(+), 11 deletions(-) diff --git a/docs/v3_spec.md b/docs/v3_spec.md index 7aac13ea..3582b74b 100644 --- a/docs/v3_spec.md +++ b/docs/v3_spec.md @@ -680,20 +680,21 @@ Kubernetes apiserver. If in doubt, leave this disabled. admin_access: False ``` -## config_map +## config_maps | **Type** | **Required** | |----------|--------------| | list | no | -Add extra configMaps to your application. By default a configMap named the same as your application will be -added. +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/tests/fiaas_deploy_daemon/e2e_expected/v3-multiple-configmap-deployment.yml b/tests/fiaas_deploy_daemon/e2e_expected/v3-multiple-configmap-deployment.yml index 82fbe1f4..4b59033e 100644 --- a/tests/fiaas_deploy_daemon/e2e_expected/v3-multiple-configmap-deployment.yml +++ b/tests/fiaas_deploy_daemon/e2e_expected/v3-multiple-configmap-deployment.yml @@ -125,15 +125,15 @@ spec: - name: VERSION value: VERSION envFrom: - - configMapRef: - name: v3-data-examples-multiple-config-maps - optional: true - 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: @@ -174,6 +174,12 @@ spec: - 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 @@ -189,6 +195,16 @@ spec: 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 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 index d13db2d8..4c68ff2c 100644 --- 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 @@ -126,10 +126,10 @@ spec: value: VERSION envFrom: - configMapRef: - name: v3-data-examples-single-extra-config-map + name: test1 optional: true - configMapRef: - name: test1 + name: v3-data-examples-single-extra-config-map optional: true image: IMAGE imagePullPolicy: IfNotPresent @@ -171,6 +171,9 @@ spec: - 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 @@ -186,6 +189,11 @@ spec: 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 diff --git a/tests/fiaas_deploy_daemon/e2e_expected/v3full-deployment.yml b/tests/fiaas_deploy_daemon/e2e_expected/v3full-deployment.yml index 0801d62a..2ba932fb 100644 --- a/tests/fiaas_deploy_daemon/e2e_expected/v3full-deployment.yml +++ b/tests/fiaas_deploy_daemon/e2e_expected/v3full-deployment.yml @@ -138,15 +138,15 @@ spec: - name: VERSION value: VERSION envFrom: - - configMapRef: - name: v3-data-examples-full - optional: true - configMapRef: name: test1 optional: true - configMapRef: name: test2 optional: true + - configMapRef: + name: v3-data-examples-full + optional: true image: IMAGE imagePullPolicy: IfNotPresent livenessProbe: @@ -189,6 +189,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 @@ -235,6 +241,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 From 29ef2f68dfffbe1bc76ee407e9c815108c7b3528 Mon Sep 17 00:00:00 2001 From: Simen Skoglund Date: Tue, 17 Nov 2020 12:30:25 +0100 Subject: [PATCH 11/18] fix codestyle --- .../deployer/kubernetes/deployment/deployer.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py b/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py index e9c75b90..363f4a4e 100644 --- a/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py +++ b/fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py @@ -104,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 @@ -139,7 +141,7 @@ def _make_volumes(self, app_spec): 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))) + 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: @@ -154,7 +156,7 @@ def _make_volume_mounts(self, app_spec): 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))) + 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")) From cf61a1cdd1579db9b91ffb9c6deacf9de11b2c3d Mon Sep 17 00:00:00 2001 From: Simen Skoglund Date: Tue, 17 Nov 2020 14:29:10 +0100 Subject: [PATCH 12/18] fix some integration tests --- tests/fiaas_deploy_daemon/test_e2e.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/fiaas_deploy_daemon/test_e2e.py b/tests/fiaas_deploy_daemon/test_e2e.py index 74ae9ebe..dfb9c789 100644 --- a/tests/fiaas_deploy_daemon/test_e2e.py +++ b/tests/fiaas_deploy_daemon/test_e2e.py @@ -232,13 +232,25 @@ def ready(): }), ("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 From 7ec5ed46155705089fb09505b16eb4a76cfa8902 Mon Sep 17 00:00:00 2001 From: Simen Skoglund Date: Wed, 25 Nov 2020 14:22:01 +0100 Subject: [PATCH 13/18] remove - --- tests/fiaas_deploy_daemon/e2e_expected/v3full-deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fiaas_deploy_daemon/e2e_expected/v3full-deployment.yml b/tests/fiaas_deploy_daemon/e2e_expected/v3full-deployment.yml index 2ba932fb..861981a0 100644 --- a/tests/fiaas_deploy_daemon/e2e_expected/v3full-deployment.yml +++ b/tests/fiaas_deploy_daemon/e2e_expected/v3full-deployment.yml @@ -250,7 +250,7 @@ spec: defaultMode: 420 name: test2 optional: true - - name: test2-config + name: test2-config - configMap: defaultMode: 420 name: v3-data-examples-full From dd94a02a02bc794b42daa25084f197af37c80abe Mon Sep 17 00:00:00 2001 From: Simen Skoglund Date: Thu, 26 Nov 2020 19:14:12 +0100 Subject: [PATCH 14/18] update copyright Co-authored-by: Greg Jones --- .../e2e_expected/v3-single-extra-configmap-deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 4c68ff2c..fe2cf04d 100644 --- 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 @@ -1,5 +1,5 @@ -# Copyright 2017-2019 The FIAAS Authors +# 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. From 5aec7420b077bd464e8780ba5e17660887150166 Mon Sep 17 00:00:00 2001 From: Simen Skoglund Date: Thu, 26 Nov 2020 19:14:28 +0100 Subject: [PATCH 15/18] update copyright Co-authored-by: Greg Jones --- .../specs/v3/data/examples/single_extra_config_map.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index fdcb9191..b86f7dea 100644 --- 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 @@ -1,5 +1,5 @@ -# Copyright 2017-2019 The FIAAS Authors +# 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. From e591c6c95d46e6d294abd7fbebf36ec918e4fefd Mon Sep 17 00:00:00 2001 From: Simen Skoglund Date: Thu, 26 Nov 2020 19:14:39 +0100 Subject: [PATCH 16/18] update copyright Co-authored-by: Greg Jones --- .../specs/v3/data/examples/multiple_config_maps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 236380f8..e749b6ed 100644 --- 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 @@ -1,5 +1,5 @@ -# Copyright 2017-2019 The FIAAS Authors +# 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. From 171d068acec57d30888f8c6975a10309d5cdeee3 Mon Sep 17 00:00:00 2001 From: Simen Skoglund Date: Thu, 26 Nov 2020 19:14:53 +0100 Subject: [PATCH 17/18] update copyright Co-authored-by: Greg Jones --- .../e2e_expected/v3-no-extra-configmap-deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 88423786..3606bd0b 100644 --- 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 @@ -1,5 +1,5 @@ -# Copyright 2017-2019 The FIAAS Authors +# 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. From 8d2ddf8e433ae0f7859cc9489858d3f8bef3a429 Mon Sep 17 00:00:00 2001 From: Simen Skoglund Date: Thu, 26 Nov 2020 19:15:02 +0100 Subject: [PATCH 18/18] update copyright Co-authored-by: Greg Jones --- .../e2e_expected/v3-multiple-configmap-deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 4b59033e..f6e3a6ff 100644 --- a/tests/fiaas_deploy_daemon/e2e_expected/v3-multiple-configmap-deployment.yml +++ b/tests/fiaas_deploy_daemon/e2e_expected/v3-multiple-configmap-deployment.yml @@ -1,5 +1,5 @@ -# Copyright 2017-2019 The FIAAS Authors +# 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.