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

docs: Instructions on make verify-kube-connect step when using k3d #4687

Merged
merged 4 commits into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 30 additions & 0 deletions docs/developer-guide/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,36 @@ make: *** [Makefile:386: verify-kube-connect] Error 1

you should edit your `~/.kube/config` and modify the `server` option to point to your correct K8s API (as described above).

### Using k3d

k3d is a lightweight wrapper to run [k3s](https://github.com/rancher/k3s), a minimal Kubernetes distribution, in docker. Because it's running in a docker container, you're dealing with docker's internal networking rules when using k3d. A typical Kubernetes cluster running on your local machine is part of the same network that you're on so you can access it using **kubectl**. However, a Kubernetes cluster running within a docker container (in this case, the one launched by make) cannot access 0.0.0.0 from inside the container itself, when 0.0.0.0 is a network resource outside the container itself (and/or the container's network). This is the cost of a fully self-contained, disposable Kubernetes cluster. The following steps should help with a successful `make verify-kube-connect` execution.
Copy link
Contributor

@amitkrout amitkrout Oct 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the first point of [1] it has been mentioned that a minimal Kubernetes cluster k3s is enough for dev environment and from [2] i can see k3s is only supported on linux distribution. So on mac and windows we need a third party tool like k3d, VirtualBox etc which can provide a containerize/virtual linux env to install k3s.

Instead of specifying a tool to install k3s, IMO just create a hyper link k3d in the first point of [1] as one of containerize env provider and ofcourse for connectivity you need to provide ip address configuration information in k3d containerize env.

[1] https://github.com/argoproj/argo-cd/blob/master/docs/developer-guide/contributing.md#before-you-start
[2] https://rancher.com/docs/k3s/latest/en/installation/installation-requirements/#operating-systems


1. Find your host IP by executing `ifconfig` on Mac/Linux and `ipconfig` on Windows. For most users, the following command works to find the IP address.

For Mac:
```
IP=`ifconfig en0 | grep inet | grep -v inet6 | awk '{print $2}'`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will error out on linux and windows because the same interface device won't be available

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on linux you can run ip addr. I don't know about windows.

Copy link
Contributor

@tetchel tetchel Oct 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also keep in mind this IP will be dynamically assigned by the router so if your router restarts for any reason your IP will change and you will have to recreate the cluster. You can assign your PC a static IP to prevent that from happening

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review Amit. I added command for Linux.

echo $IP
```

For Linux:
```
IP=`ifconfig eth0 | grep inet | grep -v inet6 | awk '{print $2}'`
echo $IP
```

Keep in mind that this IP is dynamically assigned by the router so if your router restarts for any reason, your IP might change.

2. Edit your ~/.kube/config and replace 0.0.0.0 with the above IP address.

3. Execute a `kubectl version` to make sure you can still connect to the Kubernetes API server via this new IP. Run `make verify-kube-connect` and check if it works.

4. Finally, so that you don't have to keep updating your kube-config whenever you spin up a new k3d cluster, add `--api-port $IP:6550` to your **k3d cluster create** command, where $IP is the value from step 1. An example command is provided here.

```
k3d cluster create my-cluster --wait --k3s-server-arg '--disable=traefik' --api-port $IP:6550 -p 443:443@loadbalancer
```

## The development cycle

When you have developed and possibly manually tested the code you want to contribute, you should ensure that everything will build correctly. Commit your changes to the local copy of your Git branch and perform the following steps:
Expand Down
2 changes: 1 addition & 1 deletion docs/developer-guide/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ To be on the safe side, make sure that you have created an Enhancement Proposal
See [Failing CI Checks](ci.md#troubleshooting-ci-checks).

### What checked-in code is generated, and how is it generated?
The following files under this repository are generated, and must be kept up-to-date. Also see [Why does the codegen step fail?](ci#why-does-the-codegen-step-fail).
The following files under this repository are generated, and must be kept up-to-date. Also see [Why does the codegen step fail?](ci.md#why-does-the-codegen-step-fail).

See the Makefile for targets that can also run these scripts, and the `codegen` target which runs them all.

Expand Down