Kubectl suddently asking for username (EOF error)

My last deployment pipeline stage suddently started asking for username when running kubectl apply command. This is the log generated when running the stage:

$ kubectl config set-cluster $ITINI_STAG_KUBE_CLUSTER --server="$ITINI_STAG_KUBE_URL" --insecure-skip-tls-verify=true
Cluster "itini-int-cluster" set.
$ kubectl config set-credentials gitlab --token="$ITINI_STAG_KUBE_TOKEN"
User "gitlab" set.
$ kubectl config set-context default --cluster=$ITINI_STAG_KUBE_CLUSTER --user=gitlab
Context "default" created.
$ kubectl config use-context default
Switched to context "default".
$ kubectl apply -f deployment.yml
Please enter Username: error: EOF

There was no recent changes made to any configuration files.
Anyone facing anything similar?

Assuming the token is valid, has the version of kubectl CLI and/or your Kubernetes server version changed since the last successful build? If there is a large difference (> 2 minor versions) between the two, try upgrading the kubectl CLI version and retry.

I’m not sure about the previous version (or even if it has been changed), but this is what I get when running “kubectl version” in the pipeline:

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.4", GitCommit:"d360454c9bcd1634cf4cc52d1867af5491dc9c5f", GitTreeState:"clean", BuildDate:"2020-11-11T13:17:17Z", GoVersion:"go1.15.2", Compiler:"gc", Platform:"linux/amd64"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?
Cleaning up file based variables
ERROR: Job failed: exit code 1

Note that, after adding the version command, the pipeline does not execute the remaining commands, it crashes just after the command.

I’ve managed to reproduced the same commands using my local kubectl binary using the same variables/tokens present in the pipeline, and the deployment finishes with success.

This is my output when running “kubectl version” locally:

Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.0", GitCommit:"af46c47ce925f4c4ad5cc8d1fca46c7b77d13b38", GitTreeState:"clean", BuildDate:"2020-12-08T17:59:43Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"17+", GitVersion:"v1.17.13-gke.2001", GitCommit:"00c919adfe4adf308bcd7c02838f2a1b60482f02", GitTreeState:"clean", BuildDate:"2020-11-06T18:24:02Z", GoVersion:"go1.13.15b4", Compiler:"gc", Platform:"linux/amd64"}

This is the log generated by gitlab’s pipeline when running “kubectl version” command:

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.4", GitCommit:"d360454c9bcd1634cf4cc52d1867af5491dc9c5f", GitTreeState:"clean", BuildDate:"2020-11-11T13:17:17Z", GoVersion:"go1.15.2", Compiler:"gc", Platform:"linux/amd64"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?

Note that, after adding the version command, the pipeline crashes in the same line, and the other commands are not executed.

This is what I get when I run the command locally (locally it’s working as expected):

Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.0", GitCommit:"af46c47ce925f4c4ad5cc8d1fca46c7b77d13b38", GitTreeState:"clean", BuildDate:"2020-12-08T17:59:43Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"17+", GitVersion:"v1.17.13-gke.2001", GitCommit:"00c919adfe4adf308bcd7c02838f2a1b60482f02", GitTreeState:"clean", BuildDate:"2020-11-06T18:24:02Z", GoVersion:"go1.13.15b4", Compiler:"gc", Platform:"linux/amd64"}

The problem was that my ITINI_STAG_KUBE_TOKEN variable was marked as protected, and it was being replaced by an empty string instead of the actual token. I fixed the issue by unmarking the variable as protected. Is this something expected? I don’t remember changing this option recently.