-
Notifications
You must be signed in to change notification settings - Fork 772
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
Add env_file + ConfigMaps feature to Kompose #799
Conversation
TODO:
|
d070dde
to
15b2de9
Compare
Ready for review @ashetty1 @containscafeine @kadel @surajnarwade @surajssd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docker Compose file -
version: '3'
services:
redis:
image: 'bitnami/redis:latest'
environment:
- ALLOW_EMPTY_PASSWORD=no
# Env file will override environment / warn!
env_file:
- ./bar.env
labels:
kompose.service.type: nodeport
ports:
- '6379:6379'
Generated ConfigMap -
- apiVersion: v1
data:
BAR: FOO
FOO: BAR
kind: ConfigMap
metadata:
creationTimestamp: null
name: -/bar-env
kind: List
metadata: {}
Upon doing kompose up -
$ kompose up -f script/test/fixtures/configmap/docker-compose.yaml
INFO We are going to create Kubernetes Deployments, Services and PersistentVolumeClaims for your Dockerized application. If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead.
INFO Deploying application in "default" namespace
INFO Successfully created Service: redis
FATA Error while deploying application: Deployment.apps "redis" is invalid: [spec.template.spec.containers[0].env[0].valueFrom.configMapKeyRef.name: Invalid value: "-/bar-env": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*'), spec.template.spec.containers[0].env[1].valueFrom.configMapKeyRef.name: Invalid value: "-/bar-env": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')]
pkg/kobject/kobject.go
Outdated
ContainerName string | ||
Image string `compose:"image"` | ||
Environment []EnvVar `compose:"environment"` | ||
EnvFile []string `compose:""` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can add compose:"env_file"
as it is valid key
version 2 docker -compose file,
doesn't create configmaps,
|
Your example shows Version 3 @surajnarwade Yeah, at the moment it doesn't support Version 2. I will have to add that. Baby steps! 👍 Can you do a review on the basis Version 3? |
@cdrage , my bad about version 👍 for baby step |
@containscafeine @kadel @surajnarwade @surajssd ready for review 👍 edit: next sprint I will add v2 support, i have updated the conversion.md matrix accordingly. |
Reason why this is not in v2 is because of this: docker/libcompose#488 |
@cdrage still getting the error in #799 (review) :( |
7fc8fc8
to
b0f2b00
Compare
@containscafeine should work now, i've created a new function in order to format the new env name's correctly, feel free to do another review!
|
ignoring vendoring updates, this PR needs review edit: vendoring updates blocked on #835 due to running into errors with logrus + gojsonschema @kadel @containscafeine @surajnarwade @surajssd please review |
9b8e8d1
to
27de17c
Compare
1bc04b5
to
51bece6
Compare
APIVersion: "v1", | ||
}, | ||
ObjectMeta: api.ObjectMeta{ | ||
Name: envName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be named like other objects kompose creates? appName - maifest type.yaml
Here also we can use same format, just add appName
before envName
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so appName-configmap-env
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cdrage this sounds good!
works for me 👍 |
When using env_file with Docker Compose, a ConfigMap will be generated For example: ```sh ▶ ./kompose convert -f script/test/fixtures/configmaps/docker-compose.yml INFO Kubernetes file "redis-service.yaml" created INFO Kubernetes file "redis-deployment.yaml" created INFO Kubernetes file "foo-env-configmap.yaml" created INFO Kubernetes file "bar-env-configmap.yaml" created ``` File: ```yaml version: '3' services: redis: image: 'bitnami/redis:latest' environment: - ALLOW_EMPTY_PASSWORD=no # Env file will override environment / warn! env_file: - "foo.env" - bar.env labels: kompose.service.type: nodeport ports: - '6379:6379' ``` To: ```yaml apiVersion: v1 data: ALLOW_EMPTY_PASSWORD: "yes" kind: ConfigMap metadata: creationTimestamp: null name: foo-env ``` ```yaml ... - env: - name: ALLOW_EMPTY_PASSWORD valueFrom: configMapKeyRef: key: ALLOW_EMPTY_PASSWORD name: foo-env ```
When using env_file with Docker Compose, a ConfigMap will be generated.
For example:
File:
To: