Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

mvn fabric8:resource converts types of kubernetes YAML annotations in fragment #1714

Closed
nimish opened this issue Sep 27, 2019 · 4 comments · Fixed by #1716 or #1725
Closed

mvn fabric8:resource converts types of kubernetes YAML annotations in fragment #1714

nimish opened this issue Sep 27, 2019 · 4 comments · Fixed by #1716 or #1725
Assignees

Comments

@nimish
Copy link

nimish commented Sep 27, 2019

Description

Info

  • f-m-p version : 4.2.0
  • Maven version (mvn -v) : 3.6.2
metadata:
  annotations:
    # Enable client certificate authentication
    nginx.ingress.kubernetes.io/auth-tls-verify-client: 'on'

After doing whatever it does to an ingress resource fragment (taken from the nginx ingress controller examples), the f-m-p will emit:

metadata:
  annotations:
    nginx.ingress.kubernetes.io/auth-tls-verify-client: on

Note the lack of quotes. This results in the warning:

[message=.metadata.annotations.nginx.ingress.kubernetes.io/auth-tls-verify-client: boolean found, string expected, violation type=type]

The difference matters quite a bit as the wrong type will stop the ingress controller from actually enforcing client certificate auth...

@erikgb
Copy link
Contributor

erikgb commented Oct 1, 2019

I am experiencing a similar problem, but probably with the same cause. I think the issue here is the rather odd boolean datatype in YAML: https://yaml.org/type/bool.html. The fix in f-m-p could be to NOT remove quotes when the qouted value is in the YAML boolean regex range.

A potential workaround could have been to transform the resource fragment into JSON - as f-m-p supports both YAML and JSON. But that does not work because f-m-p seems to use YAML as the "canonical dataformat" for generated resources. And the generated YAML resources (from a JSON resource fragments) still has the wrong unquoted value....

@rohanKanojia : Any chance of getting this fixed for the upcoming f-m-p release?

I am trying to deploy Kong using fabric8-maven-plugin. The Kong image supports configuration of the database type through the environment variable KONG_DATABASE, and the supported values are (postgres, cassandra, off).

In my deployment resource fragment I tried with (starting from kong-dist-kubernetes):
env:
- name: KONG_DATABASE
value: 'off'

The generated resources from fabric8-maven-plugin (in target/classes/META-INF/fabric8/) transforms this into:
env:
- name: KONG_DATABASE
value: off

Notice how the quotes are removed from the value....
The resource goal also emits warnings like this:
[WARNING] F8: Invalid Resource : (...)/target/classes/META-INF/fabric8/kubernetes/kong-dbless-deployment.yml
[message=.spec.template.spec.containers[0].env[0].value: boolean found, string expected, violation type=type]
[WARNING] F8: Invalid Resource : (...)/target/classes/META-INF/fabric8/openshift/kong-dbless-deploymentconfig.yml
[message=.spec.template.spec.containers[0].env[0].value: boolean found, string expected, violation type=type]

When I then run the apply goal to apply the generated resources to my Openshift Cluster, this results in the following YAML (from my Openshift deployment config):
env:
- name: KONG_DATABASE
value: 'false'

Which results in my pod ending up in a Crash Loop Back-off with the following error message: Error: database has an invalid value: 'false' (postgres, cassandra, off)

@erikgb
Copy link
Contributor

erikgb commented Oct 1, 2019

I have just tested this with the 4.3-SNAPSHOT version, built from the master branch. And same behavior....

rohanKanojia added a commit to rohanKanojia/fabric8-maven-plugin that referenced this issue Oct 1, 2019
… YAML annotations in fragment

Modified Jackson ObjectMapper to disable minimizing quotes in case of yamls
rohanKanojia added a commit to rohanKanojia/fabric8-maven-plugin that referenced this issue Oct 1, 2019
… YAML annotations in fragment

Modified Jackson ObjectMapper to disable minimizing quotes in case of yamls
rohanKanojia added a commit to rohanKanojia/fabric8-maven-plugin that referenced this issue Oct 3, 2019
… YAML annotations in fragment

Modified Jackson ObjectMapper to disable minimizing quotes in case of yamls
rohanKanojia added a commit that referenced this issue Oct 3, 2019
…otations in fragment

Modified Jackson ObjectMapper to disable minimizing quotes in case of yamls
@nimish
Copy link
Author

nimish commented Oct 4, 2019

A way to avoid this -- and this might be user error on my part -- is to specify the type tag: !!str.

Still, it's irritating and is more a yaml thing than anything f-m-p related

@erikgb
Copy link
Contributor

erikgb commented Oct 5, 2019

@nimish : Single quotes should be enough to make it into a YAML string. I suspect that there is a bug in jackson-dataformats-text (or in one of the dependencies)....

erikgb added a commit to erikgb/fabric8-maven-plugin that referenced this issue Oct 5, 2019
…bernetes YAML annotations in fragment"

This reverts commit c64d894
erikgb added a commit to erikgb/fabric8-maven-plugin that referenced this issue Oct 5, 2019
…bernetes YAML annotations in fragment"

This reverts commit c64d894
erikgb added a commit to erikgb/fabric8-maven-plugin that referenced this issue Oct 5, 2019
erikgb added a commit to erikgb/fabric8-maven-plugin that referenced this issue Oct 5, 2019
erikgb added a commit to erikgb/fabric8-maven-plugin that referenced this issue Oct 5, 2019
erikgb added a commit to erikgb/fabric8-maven-plugin that referenced this issue Oct 7, 2019
rohanKanojia pushed a commit that referenced this issue Oct 7, 2019
…YAML annotations in fragment"

This reverts commit c64d894
rohanKanojia pushed a commit that referenced this issue Oct 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.