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

Set KUBECONFIG, DOCKER_HOST in root garden.yaml #459

Closed
adnaan opened this issue Jan 12, 2019 · 5 comments
Closed

Set KUBECONFIG, DOCKER_HOST in root garden.yaml #459

adnaan opened this issue Jan 12, 2019 · 5 comments
Assignees
Labels
support Support request

Comments

@adnaan
Copy link

adnaan commented Jan 12, 2019

Bug

Current Behavior

$ garden get status

Unable to connect to Kubernetes cluster. Please make sure it is running, reachable and that you have the right context configured.
$ export KUBECONFIG=/Users/myuser/.kube/config
$ garden init
Initializing local environment ⚙

  local-kubernetes          → Preparing environment...
    ✔ kubernetes-dashboard      → Preparing chart... → Done (took 3.2 sec)
    ✔ ingress-controller        → Preparing chart... → Done (took 3.8 sec)
    ✔ kubernetes-dashboard      → Preparing chart... → Version f4da12648f already deployed


Failed building default-backend. Here is the output:
————————————————————————————————————————————————————————————————————————————————
Command failed: docker images  -q
error during connect: Get http://11.142.1.15:5143/v1.39/images/json?filters=%7B%22reference%22%3A%7B%22undefined%22%3Atrue%7D%7D: dial tcp 10.132.1.15:4243: connect: network is unre
achable
————————————————————————————————————————————————————————————————————————————————

local-kubernetes: 1 errors occurred when configuring environment

$ unset DOCKER_HOST
$ garden init
Initializing local environment ⚙

✔ local-kubernetes          → Configured
    ✔ ingress-controller        → Preparing chart... → Done (took 4.5 sec)
    ✔ kubernetes-dashboard      → Preparing chart... → Done (took 3.9 sec)
    ✔ default-backend           → Building default-backend:f4da12648f... → Done (took 10.9 sec)
    ✔ kubernetes-dashboard      → Preparing chart... → Version f4da12648f already deployed
    ✔ default-backend           → Deploying version f4da12648f... → Done (took 7.2 sec)
    ✔ ingress-controller        → Deploying version f4da12648f... → Done (took 90.6 sec)

Done! ✔️

Expected behavior

The above problem was due to configured DOCKER_HOST. Running unset DOCKER_HOST
fixes the problem. Expected garden init to log this as a solution in the error log.

Reproducible example

export KUBECONFIG=/path/to/unreachable/k8s/context
export DOCKER_HOST=/path/to/unreachable/k8s/host
$ garden init

Suggested solution(s)

Set KUBECONFIG, DOCKER_HOST in garden.yaml:environments:local:providers:local-kubernetes

Example:

project:
  name: simple-project
  environments:
    - name: local
      providers:
        - name: local-kubernetes
          env: 
            - docker_host: localhost
            - kubeconfig: /path/to/docker-desktop.config

Although this is quite trivial, setting these environment vars in root garden.yml leads to a better dev experience for the uninitiated devs.

Alternatively the error logs could be more descriptive about a suggested solution like:

Please run `$ unset DOCKER_HOST` if you are developing against docker for desktop`

garden version
0.8.1
kubectl version

Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.1", GitCommit:"eec55b9ba98609a46fee712359c7b5b365bdd920", GitTreeState:"clean", BuildDate:"2018-12-13T19:44:10Z", GoVersion:"go1.11.2", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-21T09:05:37Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}

docker version

Client: Docker Engine - Community
 Version:           18.09.0
 API version:       1.39
 Go version:        go1.10.4
 Git commit:        4d60db4
 Built:             Wed Nov  7 00:47:43 2018
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.0
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.4
  Git commit:       4d60db4
  Built:            Wed Nov  7 00:55:00 2018
  OS/Arch:          linux/amd64
  Experimental:     false
@drubin
Copy link
Contributor

drubin commented Jan 14, 2019

@adnaan Thanks for this issue. You are 100% right our errors currently need a bit of work to make them more friendly.

Do you think the use case would be covered by #180 ? (Purely better errors)

Just trying to figure out if the approach to fix it would better be covered by friendly useful error messages vs explicitly user config checked into the garden.yaml files

The main reason for not allowing you to configure these details in the garden.yaml file yet. They need to differ from developer to developer. For example my kube-config would be in a different path to yours and my docker-host might also be slightly different (minikube vs docker-for-mac and even then minikube isn't always set to have a static ip)

@adnaan
Copy link
Author

adnaan commented Jan 14, 2019

@drubin Agreed #180 should cover this.

More thoughts with a perspective of possibly better developer experience for teams in large organisations: It should be possible to ship a garden.yaml which sets its own docker_host and kubeconfig for an environment(not necessarily local). This will move handling prerequisites from a README file to a contract immediately available for the whole team. This reduces the initial friction in setting up the project with multiple team and organisation level environments. This is especially impactful for teams with different skill levels. For a local environment a preset docker_host and kubeconfig will be a problem but that can still be handled by #180.

@drubin
Copy link
Contributor

drubin commented Jan 14, 2019

@adnaan Sure its currently not incredibly well documented but for shared remote env's we have

context: my-remote-context
https://github.com/garden-io/garden/blob/master/examples/remote-k8s/garden.yml#L13

But fully sharing the exact config becomes a bit harder since your kubeconfig has private user specific info in it.

But our goal is to allow user customisation in #309

@adnaan
Copy link
Author

adnaan commented Jan 14, 2019

context: my-remote-context
https://github.com/garden-io/garden/blob/master/examples/remote-k8s/garden.yml#L13

I see. I think this is quite sufficient. Alongwith #309 it covers most of the concerns.

Thanks for your time :)

@adnaan adnaan closed this as completed Jan 14, 2019
@drubin drubin added the support Support request label Jan 14, 2019
@drubin drubin self-assigned this Jan 14, 2019
@edvald
Copy link
Collaborator

edvald commented Jan 14, 2019

Thanks for the feedback @adnaan!

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

No branches or pull requests

3 participants