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

Add possibility for pipe-tasks to pipe env-files #1484

Merged
merged 2 commits into from
Apr 29, 2020
Merged

Conversation

zen-dog
Copy link
Contributor

@zen-dog zen-dog commented Apr 27, 2020

Summary:
When creating ConfigMaps or Secrets k8s allows for taking an env-file using the --from-env-file option. Env-files contain a list of environment variables.

These syntax rules apply:

  • Each line in an env file has to be in VAR=VAL format.
  • Lines beginning with # (i.e. comments) are ignored.
  • Blank lines are ignored.
  • There is no special handling of quotation marks (i.e. they will be part of the ConfigMap value))

New pipe-task envFile field can be used instead of file to signal that the pipe-file should be treated as an env-file:

spec:
 pipe:
   - envFile: /tmp/foo.env
     kind: ConfigMap
     key: foo

Note, that either file or envFile can be used but not both.

For more information on env-files see k8s documentation

Fixes: #1394

Signed-off-by: Aleksey Dukhovniy alex.dukhovniy@googlemail.com

Summary:
When creating `ConfigMap`s or `Secret`s k8s allows for taking an env-file using the `--from-env-file` option. Env-files contain a list of environment variables.

These syntax rules apply:
 - Each line in an env file has to be in VAR=VAL format.
 - Lines beginning with # (i.e. comments) are ignored.
 - Blank lines are ignored.
 - There is no special handling of quotation marks (i.e. they will be part of the ConfigMap value))

 New pipe-task `fnvFile` field can be used instead of `file` to signal that the pipe-file should be treated as an env-file:

 ```yaml
spec:
  pipe:
    - envFile: /tmp/foo.env
      kind: ConfigMap
      key: foo
```

Note, that **either** `file` or `envFile` can be used but not both.

For more information on env-files see [k8s documentation](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#create-configmaps-from-files)

Fixes: #1394
Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
@zen-dog zen-dog requested a review from ANeumann82 April 27, 2020 19:56
@zen-dog zen-dog added the release/highlight This PR is a highlight for the next release label Apr 27, 2020
Copy link
Member

@ANeumann82 ANeumann82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small nits, other than that it looks good

pkg/engine/task/task.go Outdated Show resolved Hide resolved
pkg/engine/task/task.go Outdated Show resolved Hide resolved
Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
Copy link
Member

@nfnt nfnt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@wombat
Copy link

wombat commented May 13, 2020

@zen-dog I am running into this error: failed to build task deploy.main.install-test.install-test: task validation error: pipe file is empty: { ConfigMap dotEnv}"

My Task:

- name: install-test
    kind: Pipe
    spec:
      pod: install-test.yaml
      pipe:
        - envFile: /tmp/foo.env
          kind: ConfigMap
          key: dotEnv

I already checked that the pod is mounting the /tmp folder but it does not even launch this pod so it can´t be a missing file.

@zen-dog
Copy link
Contributor Author

zen-dog commented May 13, 2020

It seems you're simply using an outdated kudo version which doesn't have envFile support.

@wombat
Copy link

wombat commented May 13, 2020

Well I tried with the kudo terraform provider and configured the kudo version to be 0.13.0-rc1 - BUT I guess because the terraform provider uses an older kudo version the validation might fail there?

@zen-dog
Copy link
Contributor Author

zen-dog commented May 14, 2020

I'm not sure, @runyontr do you know more?

@wombat
Copy link

wombat commented May 14, 2020

I also uninstalled my brew cask and manually installed the 0.13.0-rc1 - after running kudo manually without terraform I got the same error.

@runyontr
Copy link
Member

Can you try a key with all lowercases?

@wombat
Copy link

wombat commented May 14, 2020

@runyontr unfortunately its the same result

@wombat
Copy link

wombat commented May 14, 2020

I just noticed that when I describe the instance I can see the following message:

  Warning  UnknownTaskKind  10s   instance-controller  Error during execution: default/test fatal error:  failed to build task deploy.main.install-test.install-test: task validation error: pipe file is empty: { ConfigMap dotenv}

I am confused about the UnknownTaskKind - this supports the theory of @zen-dog - here is my version output:

kubectl kudo version                                                                                                                                                                                                                                                                                            
KUDO Version: version.Info{GitVersion:"0.13.0-rc1", GitCommit:"89fe2dc3", BuildDate:"2020-05-08T16:06:23Z", GoVersion:"go1.14.2", Compiler:"gc", Platform:"darwin/amd64"}

@runyontr
Copy link
Member

It looks like that error is returned regardless of the reason the error happened. So even though the issue was some configuration with the task, the logic here:

https://github.com/kudobuilder/kudo/blob/master/pkg/engine/workflow/engine.go#L155-L165

only returns the value here:

https://github.com/kudobuilder/kudo/blob/master/pkg/engine/workflow/engine.go#L22

@zen-dog
Copy link
Contributor Author

zen-dog commented May 14, 2020

The UnknownTaskKind is confusing, but the error message is pretty descriptive. And the v0.13.0-rc1 version has the env-file support as shown in this test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release/highlight This PR is a highlight for the next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the ability to pipe env/properties files content to a configmap
5 participants