Create a docker-compose file with service names containing underscores and convert it. Same problem with volume names.
Expected behavior
Valid Helm-Chart with underscores converted to dashes in K8s resource names.
Faulty behavior
Syntax-Errors in chart templates (e.g. volume claims)
Helm-Chart cannot be applied, because of not k8s compatible names
Note
As long as this causes errors a mention in readme would help
Converting underscores to dashes in docker-compose file also results in a broken chart
### Version
3, develop branch
### Reproduce
Create a docker-compose file with service names containing underscores and convert it. Same problem with volume names.
### Expected behavior
Valid Helm-Chart with underscores converted to dashes in K8s resource names.
### Faulty behavior
- Syntax-Errors in chart templates (e.g. volume claims)
- Helm-Chart cannot be applied, because of not k8s compatible names
### Note
- As long as this causes errors a mention in readme would help
- Converting underscores to dashes in docker-compose file also results in a broken chart
I wanted to add that with the 3.0.0-rc2 version, I get the same kind of problems, where having dashes in the name of a compose service pass through in the values names, and those cannot have dashes in their names.
Katenary converts it, and then when trying to apply the helmchart I get this error :
$ katenary convert -c docker-compose.yaml -o './pnar-verif' -a '0.1.0-dev' -f
🔧 Creating configmap pnar-verif-bot
📦 Creating deployment pnar-verif-bot
$ helm upgrade --install pnar-verif ./pnar-verif/
Release "pnar-verif" does not exist. Installing it now.
Error: parse error at (pnar-verif-bot/templates/pnar-verif-bot/deployment.yaml:12): bad character U+002D '-'
Problem in the generated files
When inspecting the generated file, we can see that the problem is the naming of the variable, being the first line containing such problem it raised the aforementionned error :
# file: pnar-verif-bot/templates/pnar-verif-bot/deployment.yamlapiVersion:apps/v1kind:Deploymentmetadata:annotations:katenary.v3/compose-hash:6970dc84ab078067b4db714ab186aa4b029e61e3katenary.v3/version:3.0.0-rc2labels:{{- include "local-deploy.labels" . | nindent 4 }}katenary.v3/component:pnar-verif-botname:'{{ include "local-deploy.fullname" . }}-pnar-verif-bot'spec:replicas:{{.Values.pnar-verif-bot.replicas }} # ERROR IS HEREselector:# [...]
So Katenary needs to convert this type of characters too to prevent this case from happening.
I suggest the conversion of dashes into underscores to name the variables.
The underscores problem
Okay now for the more "fun" part, let's say I try to fix the problem just by replacing the dashes with underscores in the service name and then I try to generate. Well, it doesn't work either at the moment.
Sources
Compose file :
services:pnar_verif_bot:# CHANGED FROM pnar-verif-botimage:elraphik/pnar-verif:0.1.0-devcontainer_name:pnar-verif-botvolumes:- ./data/config.json:/er_bot/data/config.jsonlabels:katenary.v3/configmap-files:|- - ./data/config.json
The error
Some commands you've already seen, but with another twist :
$ katenary convert -c docker-compose.yaml -o './pnar-verif' -a '0.1.0-dev' -f
🔧 Creating configmap pnar_verif_bot
📦 Creating deployment pnar_verif_bot
$ helm upgrade --install pnar-verif ./pnar-verif/
Error: UPGRADE FAILED: failed to create resource:
Deployment.apps "pnar-verif-local-deploy-pnar-verif-bot" is invalid: spec.template.spec.containers[0].name:
Invalid value: "pnar_verif_bot": a lowercase RFC 1123 label must consist of lower case alphanumeric characters
or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc', regex used for
validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')
Problem in the generated files
And here's part of the generated file for more context :
# file: pnar-verif-bot/templates/pnar-verif-bot/deployment.yaml# [...]spec:replicas:{{.Values.pnar_verif_bot.replicas }}# NO ERROR HERE NOWselector:matchLabels:{{- include "local-deploy.selectorLabels" . | nindent 6 }}katenary.v3/component:pnar_verif_botstrategy:{}template:metadata:labels:{{- include "local-deploy.selectorLabels" . | nindent 8 }}katenary.v3/component:pnar_verif_botspec:containers:- image:'{{ tpl .Values.pnar_verif_bot.repository.image $ }}:{{ tpl .Values.pnar_verif_bot.repository.tag $ | default "latest" }}'imagePullPolicy:{{.Values.pnar_verif_bot.imagePullPolicy }}name:pnar_verif_bot # ERROR IS HERE{{- if .Values.pnar_verif_bot.resources }}resources:# [...]
And, two things here :
katenary did not take account of the container_name key from the compose file, which is not the real problem here
underscores were not converted to dashes in the ressource's name in the end product
Conclusion
To conclude, we can see that in both cases there is a problem with the generated chart when we are in presence of dashes or underscores in the services'names.
I'd suggest to completely segragate the two names, having one with underscores for values, and the other with dashes for the name of the container and other helm keys.
Hi
# The dashes problem
I wanted to add that with the 3.0.0-rc2 version, I get the same kind of problems, where having dashes in the name of a compose service pass through in the values names, and those cannot have dashes in their names.
## Sources
Docker compose file :
```yaml
services:
pnar-verif-bot:
image: elraphik/pnar-verif:0.1.0-dev
container_name: pnar-verif-bot
volumes:
- ./data/config.json:/er_bot/data/config.json
labels:
katenary.v3/configmap-files: |-
- ./data/config.json
```
## The error
Katenary converts it, and then when trying to apply the helmchart I get this error :
```sh
$ katenary convert -c docker-compose.yaml -o './pnar-verif' -a '0.1.0-dev' -f
🔧 Creating configmap pnar-verif-bot
📦 Creating deployment pnar-verif-bot
$ helm upgrade --install pnar-verif ./pnar-verif/
Release "pnar-verif" does not exist. Installing it now.
Error: parse error at (pnar-verif-bot/templates/pnar-verif-bot/deployment.yaml:12): bad character U+002D '-'
```
## Problem in the generated files
When inspecting the generated file, we can see that the problem is the naming of the variable, being the first line containing such problem it raised the aforementionned error :
```yaml
# file: pnar-verif-bot/templates/pnar-verif-bot/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
katenary.v3/compose-hash: 6970dc84ab078067b4db714ab186aa4b029e61e3
katenary.v3/version: 3.0.0-rc2
labels:
{{- include "local-deploy.labels" . | nindent 4 }}
katenary.v3/component: pnar-verif-bot
name: '{{ include "local-deploy.fullname" . }}-pnar-verif-bot'
spec:
replicas: {{ .Values.pnar-verif-bot.replicas }} # ERROR IS HERE
selector:
# [...]
```
So Katenary needs to convert this type of characters too to prevent this case from happening.
I suggest the conversion of dashes into underscores to name the variables.
# The underscores problem
Okay now for the more "fun" part, let's say I try to fix the problem just by replacing the dashes with underscores in the service name and then I try to generate. Well, it doesn't work either at the moment.
## Sources
Compose file :
```yaml
services:
pnar_verif_bot: # CHANGED FROM pnar-verif-bot
image: elraphik/pnar-verif:0.1.0-dev
container_name: pnar-verif-bot
volumes:
- ./data/config.json:/er_bot/data/config.json
labels:
katenary.v3/configmap-files: |-
- ./data/config.json
```
## The error
Some commands you've already seen, but with another twist :
```
$ katenary convert -c docker-compose.yaml -o './pnar-verif' -a '0.1.0-dev' -f
🔧 Creating configmap pnar_verif_bot
📦 Creating deployment pnar_verif_bot
$ helm upgrade --install pnar-verif ./pnar-verif/
Error: UPGRADE FAILED: failed to create resource:
Deployment.apps "pnar-verif-local-deploy-pnar-verif-bot" is invalid: spec.template.spec.containers[0].name:
Invalid value: "pnar_verif_bot": a lowercase RFC 1123 label must consist of lower case alphanumeric characters
or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc', regex used for
validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')
```
## Problem in the generated files
And here's part of the generated file for more context :
```yaml
# file: pnar-verif-bot/templates/pnar-verif-bot/deployment.yaml
# [...]
spec:
replicas: {{ .Values.pnar_verif_bot.replicas }} # NO ERROR HERE NOW
selector:
matchLabels:
{{- include "local-deploy.selectorLabels" . | nindent 6 }}
katenary.v3/component: pnar_verif_bot
strategy: {}
template:
metadata:
labels:
{{- include "local-deploy.selectorLabels" . | nindent 8 }}
katenary.v3/component: pnar_verif_bot
spec:
containers:
- image: '{{ tpl .Values.pnar_verif_bot.repository.image $ }}:{{ tpl .Values.pnar_verif_bot.repository.tag $ | default "latest" }}'
imagePullPolicy: {{ .Values.pnar_verif_bot.imagePullPolicy }}
name: pnar_verif_bot # ERROR IS HERE
{{- if .Values.pnar_verif_bot.resources }}
resources:
# [...]
```
And, two things here :
- katenary did not take account of the `container_name` key from the compose file, which is not the real problem here
- underscores were not converted to dashes in the ressource's name in the end product
# Conclusion
To conclude, we can see that in both cases there is a problem with the generated chart when we are in presence of dashes or underscores in the services'names.
I'd suggest to completely segragate the two names, having one with underscores for values, and the other with dashes for the name of the container and other helm keys.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Version
3, develop branch
Reproduce
Create a docker-compose file with service names containing underscores and convert it. Same problem with volume names.
Expected behavior
Valid Helm-Chart with underscores converted to dashes in K8s resource names.
Faulty behavior
Note
Hi, yes right 👍🏻
I fixed this in https://github.com/metal3d/katenary/commit/d72f371c59857f1ccaa1c1c9e2a246642043d83f
Hi
The dashes problem
I wanted to add that with the 3.0.0-rc2 version, I get the same kind of problems, where having dashes in the name of a compose service pass through in the values names, and those cannot have dashes in their names.
Sources
Docker compose file :
The error
Katenary converts it, and then when trying to apply the helmchart I get this error :
Problem in the generated files
When inspecting the generated file, we can see that the problem is the naming of the variable, being the first line containing such problem it raised the aforementionned error :
So Katenary needs to convert this type of characters too to prevent this case from happening.
I suggest the conversion of dashes into underscores to name the variables.
The underscores problem
Okay now for the more "fun" part, let's say I try to fix the problem just by replacing the dashes with underscores in the service name and then I try to generate. Well, it doesn't work either at the moment.
Sources
Compose file :
The error
Some commands you've already seen, but with another twist :
Problem in the generated files
And here's part of the generated file for more context :
And, two things here :
container_namekey from the compose file, which is not the real problem hereConclusion
To conclude, we can see that in both cases there is a problem with the generated chart when we are in presence of dashes or underscores in the services'names.
I'd suggest to completely segragate the two names, having one with underscores for values, and the other with dashes for the name of the container and other helm keys.
Yep, right, the main problem is that each resource has got its own rule. I missed this one (volume name).
I will fix it tomorrow