Skip to content

Commit

Permalink
proposal for multiple configmaps fiaas#112
Browse files Browse the repository at this point in the history
  • Loading branch information
Simen Skoglund committed Aug 28, 2020
1 parent 2b186fb commit 32b0dcb
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 5 deletions.
12 changes: 11 additions & 1 deletion fiaas_deploy_daemon/deployer/kubernetes/deployment/deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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_
Expand Down
3 changes: 2 additions & 1 deletion fiaas_deploy_daemon/specs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class AppSpec(namedtuple("AppSpec", [
"strongbox",
"singleton",
"ingress_tls",
"secrets"
"secrets",
"config_maps"
])):
__slots__ = ()

Expand Down
1 change: 1 addition & 0 deletions fiaas_deploy_daemon/specs/v3/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: []
1 change: 1 addition & 0 deletions fiaas_deploy_daemon/specs/v3/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion tests/fiaas_deploy_daemon/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[]
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions tests/fiaas_deploy_daemon/specs/v3/data/examples/full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,6 @@ extensions:
groups:
- secretgroup1
- secretgroup2
config_maps:
- "test1"
- "test2"
Original file line number Diff line number Diff line change
@@ -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"
8 changes: 7 additions & 1 deletion tests/fiaas_deploy_daemon/specs/v3/test_v3factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,18 @@
"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,
"autoscaler.min_replicas": 3,
"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",
Expand Down Expand Up @@ -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": {
Expand Down

0 comments on commit 32b0dcb

Please sign in to comment.