Kubectl error: error loading config file "[secure]": open [secure]: file name too long

Hi,

I am trying to build project with docker and kubernetes for aws.
I had defined the environment variables as I supposed to, some base64 strings and other data, all runs fine, but when I get in the kubernetes part in the end, I get an annoying error that I can’t find the reason, the error is:

e[0K$ kubectl config set-cluster marcelo-cluster-udagram --server=${KUBE_SERVER_URL} --certificate-authority=${HOME}/.kube/udagram-ca.pem
**error: error loading config file "[secure]": open [secure]: file name too long**
travis_time:end:01feada4:start=1588625715207341620,finish=1588625715329227373,duration=121885753,event=after_script
e[0Ktravis_fold:end:after_script.1
e[0Ktravis_fold:start:after_script.2
e[0Ktravis_time:start:09622008
e[0K$ kubectl config set-credentials kubernetes-admin --client-certificate=${HOME}/.kube/udagram-client-ca.pem --client-key=${HOME}/.kube/udagram-key.pem
**error: error loading config file "[secure]": open [secure]: file name too long**
travis_time:end:09622008:start=1588625715334679813,finish=1588625715403393607,duration=68713794,event=after_script
e[0Ktravis_fold:end:after_script.2
e[0Ktravis_fold:start:after_script.3
e[0Ktravis_time:start:01808dc9
e[0K$ kubectl config set-context kubernetes-admin@marcelo-cluster-udagram --cluster=marcelo-cluster-udagram --namespace=default --user=kubernetes-admin
error: error loading config file "[secure]": open [secure]: file name too long
travis_time:end:01808dc9:start=1588625715409750716,finish=1588625715469655144,duration=59904428,event=after_script
e[0Ktravis_fold:end:after_script.3
e[0Ktravis_fold:start:after_script.4
e[0Ktravis_time:start:03f926a9
e[0K$ kubectl config use-context kubernetes-admin@marcelo-cluster-udagram
error: error loading config file "[secure]": open [secure]: file name too long
travis_time:end:03f926a9:start=1588625715477681560,finish=1588625715541474128,duration=63792568,event=after_script
e[0Ktravis_fold:end:after_script.4

full log here: https://api.travis-ci.com/v3/job/327770088/log.txt

I shortened the paths and iles already and all I can, but I can’t find the error, why I can’t load the config file, tried to add GitHub permissions fro longpaths as well and didn’t change anything, tried some documentation and couldn’t find tips either, cans someone help me?

Thanks.

Not much I can say without knowing what that “[secure]” stands for. You can request debug mode and reproduce the problem in it – there will be no filtering there and you will see the value.

Googling for this error suggests that the $KUBECONFIG envvar, and in particular, placing a base64-encoded value into it, is somehow problematic.

Okay, I will try with debug, but otherwise, do you have any recommendation? How do I store private keys and certificates in a good way in Travis? The environment variables is the only way I see, I will answer about the results of the debug and see if we can move forward.

You do store them as encrypted variables, or in encrypted files.

But here, the value looks like a config file name. There’s no real reason why a config file name should be a secret (because that file is probably present in the repository anyway).

So either

  • if you really store it in a secret variable
    • then you should store it in a regular variable instead so that it’s not filtered; or
  • that name simply coincided with some unrelated secret value like a login name
    • then this is a case of a https://tvtropes.org/pmwiki/pmwiki.php/Main/RevealingCoverup: that secret value is being revealed by the fact that this substring is being replaced. As such, you should change the corresponsding secret so that it’s not revealed this way. Or admit that yes, your login name is the same as your repository name, and stop storing it as a secret.

The way I did was just copy and paste the values that were generated for certificates for aws access, I had follow this instructions:

After that, there is a config file generated, then I copied some contents from this config to encrypted variables as you suggested, then I still get the same error, the funny thing is the error says the file name is too long, that gives me no clue how to proceed, that’s why I will wait until the debug finishes, then I will have more info.

Okay, it seems some error in the machine, I just checked the debug mode and saw that when I tried to run the kubectl command, after a few parameters I get the same error, I tried with and without my environment variables and I also checked the content of them in the system, looks good, so probably it is an internal problem, please take a look at my report to see if you have any clue.
I added in this paste in, just modified the key data for security.

https://pastebin.com/bNb2SPUc

Best regards,
Marcelo

I don’t know about you, but it’s pretty obvious to me that

YXBpVmVyc2lvbjogdjEKY2x1c3RlcnM6Ci0gY2x1c3RlcjoKICAgIGNlcnRpZmljYXRlLWF1dGhvcml0eS1kYXRhOiBMUzB0TFMxQ1JVZEpUaUJEUlZKVVNVWkpRMEZVUlMwdExTMHRDazFKU1VONVJFTkRRV0pEWjBGM1NVSkJaMGxDUVVSQlRrSm5hM0ZvYTJsSE9YY3dRa0ZSYzBaQlJFRldUVkpOZDBWUldVUldVVkZFUlhkd2NtUlhTbXdLWTIwMWJHUkhWbnBOUWpSWVJGUkpkMDFFVVhsTlJFVjRUV3ByZVUweGIxaEV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3Q25KTU9XMXFWR1prUjFKNE5Hc3JXVlp3YlUxS05tdHJRMmRaUVdFMllURkNlQ3RqU0RSUVdteHdWV2hFUkhwR2VXWkNZVGhQZUhabk4zaFpRMHhrT0RNS2FIVjFNa05NYURjNVRpOURObVpsYkVabEx6SnNURmd6Wld4QmVrdFlkbk55SzFscGFsZDVWVXd4ZUVkNFRYZEZTVTUxTWtkdWFuWlFTa1pOUkVKbFZRcFNUWGhTZDBRMGRGYzVLM2hOVUZkeUx6TTBlV2xKU0V0Q1UxUndaV3QwZDFWaGIwVjNSMVpKWWtSQmVEUllaMjlwV1hkM1JTdEpjbUZWYUZVNVUxbGxDa052Y0ZGbFVVdENaMUZEWlROeFowUkNUV05yU1hJd1J5OWFRVzV5S3pGM2Rpc3pURTVCTDFoM1pHdzNObVUyVEZobk5ESmxaRnAwYUZJNVdVSnFXbVFLVWpoeWRrbEZlWE5TT1UxbGVXWnBaREZwZFc5WldHZE9VVms1WjNSc1RGUm5RV2xxTXpCMVZWZGtZMFIzZG1nek5HTkhjMHR3ZG5Ka1JYTjJTMFZrZFFvMGIyZG1SR1JCVW5NeGFsTkJOWEJIVT
FkRGEyVk1lbWMwTUZBdkt6azVZMDVNV25sekwxRm5aMEZ3ZEVJMVVsZDJWWGRoUlZFOVBRb3RMUzB0TFVWT1JDQlNVMEVnVUZKSlZrRlVSU0JMUlZrdExTMHRMUW89Cg==: 

is a bit too long for a filename, and definitely too long for a valid filename.

Since it’s one of the secret values, it should be pretty obvious for you where it comes from.

I would guess that it’s the value of the KUBECONFIG envvar, and it’s a mystery to me why you thought this would a be a valid value for it.
The guide that you’ve linked to has absolutely no mention of assigning such monstrous values to variables.

Likewise, as I mentioned, there’s absolutely no reason for KUBECONFIG to be a secret variable.

1 Like

Hi,

Thanks again for the answer!

Well, I followed your suggestion and removed this var and try to set the values as I need, I had that just to have it all in the environment and get what I need when needed. So you’re right, some commands had run now, the weird part is that I was pointing the commands to use other variables, but for some reason it tries to get the configuration from kubeconfig, it must be something in the kubectl, I got another error and I will check if it is related. So for now I will close this.

Thank you so much!

This post was flagged by the community and is temporarily hidden.

Imprint