kubectl create secret via gitlab throwing error

4/16/2019

I am using gitlab CI/CD and GKE. I am trying to create a secret via gitlab. I am getting error like below

The connection to the server localhost:8080 was refused - did you specify the right host or port?

Below is the code in yaml file.

deploy to dev:
  stage: Dev-Deploy
  image: dtzar/helm-kubectl
  script:
    - kubectl create secret docker-registry  pradeep_secret --docker-server=$ARTIFACTORY_DOCKER_REPOSITORY --docker-username=$ARTIFACTORY_USER --docker-password=$ARTIFACTORY_PASS --docker-email="abc@gmail.com"

How do i go about debugging or fixing the same.

-- Hacker
gitlab
google-kubernetes-engine
kubernetes-secrets

1 Answer

4/16/2019

Look like you didn't configure correctly the configuration of the cluster. You can run kubectl config view to view the current configuration used by the CI, and ensure it's correct.

The error means that the CI is trying to connect to a cluster listening on http://localhost:8080, and this cluster does not answer. I guess this is not a correct config - which explain why it doesn't work. This is the default configuration used in case no configuration supplied.

-- Omer Levi Hevroni
Source: StackOverflow