Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal for multiple configmaps #112 #113

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/v3_spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,20 @@ Kubernetes apiserver. If in doubt, leave this disabled.
admin_access: False
```

## config_map

| **Type** | **Required** |
|----------|--------------|
| list | no |

Add extra configMaps to your application. By default a configMap named the same as your application will be
skogie marked this conversation as resolved.
Show resolved Hide resolved
added.

```yaml
config_maps:
- yourconfigmap
```


## extensions

Expand Down
19 changes: 18 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 @@ -135,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:
Expand Down Expand Up @@ -244,6 +249,18 @@ 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 = [EnvFromSource(configMapRef=ConfigMapEnvSource(name=app_spec.name, optional=True))]
skogie marked this conversation as resolved.
Show resolved Hide resolved
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)))
skogie marked this conversation as resolved.
Show resolved Hide resolved
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@

# Copyright 2017-2019 The FIAAS Authors
skogie marked this conversation as resolved.
Show resolved Hide resolved
#
# 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: []
Loading