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

Witout TTY docker on CI #36

Closed
albertoig opened this issue Nov 23, 2017 · 9 comments
Closed

Witout TTY docker on CI #36

albertoig opened this issue Nov 23, 2017 · 9 comments

Comments

@albertoig
Copy link

I am triying to use kubeval on docker without TTY to validate YML on CI but give me this error "The document stdin appears to be empty". How i can use it without TTY?

@garethr
Copy link
Collaborator

garethr commented Nov 23, 2017

Hi @albertoig could you post an example of the command you're running? I'll try and recreate.

@albertoig
Copy link
Author

albertoig commented Nov 23, 2017

Hi!

I am using Gitlab CI with some pipelines to deploy a project. I think is interesting to validate my YML kubernetes files with Kubeval. I execute on a pipeline this thing like this:

yaml-validator:
stage: doctor
image: garethr/kubeval
tags:
- linux
- docker
script:
- kubeval -v 1.8.1 ./deploy/*

If a execute on terminal it work because the docker commmand use TTY, but gitlab CI does not. Why the kubeval have to be TTY?

captura de pantalla 2017-11-23 a las 17 17 59

@johscheuer
Copy link

@albertoig I solved this issue by running kubeval with script e.g.script -q -e -c "kubeval -v 1.8.1 ./deploy/*"

@xanonid
Copy link
Contributor

xanonid commented Feb 23, 2018

@albertoig @johscheuer You can also redirect stdin from /dev/null: kubeval *.yaml < /dev/null

@Tombar
Copy link

Tombar commented Mar 6, 2018

FTR the same thing happens when using kubeval in the context of an ansible template validation

    - name: setup-k8s | template image pull secret
      template:
        src: k8s/image-pull-secret.yml.j2
        dest: "{{ deploy_dir }}/010-image-pull-secret.yml"
        validate: '/usr/bin/kubeval %s'
      tags: k8s-tasks
TASK [setup-k8s | template image pull secret] ****************************************************************************************************************
Tuesday 06 March 2018  03:13:00 +0000 (0:00:01.031)       0:00:10.130 *********
fatal: [localhost]: FAILED! => {"changed": false, "checksum": "28a4d034ca2f8202789bb7e0ac11439c06fa0ff1", "exit_status": 1, "msg": "failed to validate", "stderr": "", "stderr_lines": [], "stdout": "***PRINTED BY CALLBACK***", "stdout_lines": "***PRINTED BY CALLBACK***"}

stdout: The document stdin appears to be empty

the script -q -e -c workaround seems to work only for some cases where the < /dev/null doesn't work in any scenario

@Neirda24
Copy link

Neirda24 commented Mar 15, 2018

Having the same trouble here.... :/ can't find a way around so far...

I am using kubeval like this:

unalias kubeval 2> /dev/null > /dev/null || true
kubeval() {
	docker run \
		--rm \
		-v "${CURRENT_DIR}/.fixtures:/temp_kubeval/.fixtures" \
		-w "/temp_kubeval" \
		garethr/kubeval $*
}
export -f kubeval

then:

kubeval "./.fixtures/${PROJECT_NAME}/*" --strict

@Neirda24
Copy link

@garethr : Hi, we greatly appreciate your work on this. It helps us a lot when debugging helm on local with no access to a kubernetes cluster. We'd like to use it in our CI as well (gitlab-ci) (see the above post). Do you have any news on this bug ?

@iomv
Copy link

iomv commented Apr 18, 2018

Hi, I am having the same issue here, we are using TeamCity CI to spin up a linux box and I pass a list of paths to kubeval:
kubeval -v $K8S_VERSION -f $FILES_LIST_DEV
it works locally on my machine but on the build agent I get:
The document 01_deploy.yml appears to be empty

None of the workarounds above works for my case unfortunately.

Might come useful to specify that I copy the app from source and I install the binary while on #40 seems to imply that it might work when building from docker?

@keegancsmith
Copy link
Contributor

keegancsmith commented May 21, 2018

This is an issue with how kubeval decides to use STDIN vs reading files from arguments. You can very easily reproduce with the docker image provided

docker run --rm=true --entrypoint=/bin/sh -v `pwd`/fixtures:/fixtures garethr/kubeval:0.7.1 -c 'find /fixtures | xargs /kubeval'

I don't know why kubeval checks stdin's mode to decide to use stdin. Every other tool I know of just uses stdin if no args are provided or have - mean stdin.

https://github.com/garethr/kubeval/blob/master/cmd/root.go#L42-L43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants