Skip to content

Commit

Permalink
Add proxy config docs (canonical#389)
Browse files Browse the repository at this point in the history
* Add proxy config docs

* add examples for proxy config of charms
  • Loading branch information
evilnick authored May 1, 2024
1 parent 2f8f528 commit f2711d3
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/src/charm/howto/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Overview <self>
charm
etcd
proxy
contribute
```
Expand Down
33 changes: 33 additions & 0 deletions docs/src/charm/howto/proxy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Configuring proxy settings for K8s

Canonical Kubernetes packages a number of utilities (eg curl, helm) which need
to fetch resources they expect to find on the internet. In a constrained
network environment, such access is usually controlled through proxies.

## Adding proxy configuration for the k8s charms

For the charm deployments of Canonical Kubernetes, Juju manages proxy
configuration through the [Juju model].

For example, assume we have a proxy running at `http://squid.internal:3128` and
we are using the networks `10.0.0.0/8`,`192.168.0.0/16` and `172.16.0.0/12`. In
this case we would configure the model in which the charms are to run with
Juju:

```
juju model-config \
juju-http-proxy=http://squid.internal:3128 \
juju-https-proxy=http://squid.internal:3128 \
juju-no-proxy=10.0.8.0/24,192.168.0.0/16,127.0.0.1,10.152.183.0/24
```

```{note} The **10.152.183.0/24** CIDR needs to be covered in the juju-no-proxy
list as it is the Kubernetes service CIDR. Without this any pods will not be
able to reach the cluster's kubernetes-api. You should also exclude the range
used by pods (which defaults to **10.1.0.0/16**) and any required
local networks.
```

<!-- LINKS -->

[Juju model]: https://juju.is/docs/juju/model
2 changes: 2 additions & 0 deletions docs/src/charm/reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Overview <self>
releases
charms
proxy
architecture
community
```
Expand Down
2 changes: 2 additions & 0 deletions docs/src/charm/reference/proxy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
```{include} /snap/reference/proxy.md
```
3 changes: 3 additions & 0 deletions docs/src/snap/howto/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ install/index
networking/index
storage
external-datastore
cos-lite
proxy
contribute
support
```

---
Expand Down
47 changes: 47 additions & 0 deletions docs/src/snap/howto/proxy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Configure proxy settings for K8s

Canonical Kubernetes packages a number of utilities (eg curl, helm) which need
to fetch resources they expect to find on the internet. In a constrained
network environment, such access is usually controlled through proxies.

On Ubuntu and other Linux operating systems, proxies are configured through
system-wide environment variables defined in the `/etc/environment` file.

## Adding proxy configuration for the k8s snap

Edit the `/etc/environment` file and add the relevant URLs

```{note} It is important to add whatever address ranges are used by the
cluster itself to the `NO_PROXY` and `no_proxy` variables.
```

For example, assume we have a proxy running at `http://squid.internal:3128` and
we are using the networks `10.0.0.0/8`,`192.168.0.0/16` and `172.16.0.0/12`. We
would edit the environment (`/etc/environment`) file to include these lines:

```
HTTPS_PROXY=http://squid.internal:3128
HTTP_PROXY=http://squid.internal:3128
NO_PROXY=10.0.0.0/8,192.168.0.0/16,127.0.0.1,172.16.0.0/12
https_proxy=http://squid.internal:3128
http_proxy=http://squid.internal:3128
no_proxy=10.0.0.0/8,192.168.0.0/16,127.0.0.1,172.16.0.0/12
```

Note that you may need to restart for these settings to take effect.

```{note} The **10.152.183.0/24** CIDR needs to be covered in the juju-no-proxy
list as it is the Kubernetes service CIDR. Without this any pods will not be
able to reach the cluster's kubernetes-api. You should also exclude the range
used by pods (which defaults to **10.1.0.0/16**) and any required
local networks.
```

## Adding proxy configuration for the k8s charms

Proxy confiuration is handled by Juju when deploying the `k8s` charms. Please
see the [documentation for adding proxy configuration via Juju].

<!-- LINKS -->

[documentation for adding proxy configuration via Juju]: /charm/howto/proxy
1 change: 1 addition & 0 deletions docs/src/snap/reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ commands
troubleshooting
community
architecture
proxy
roadmap
```

Expand Down
41 changes: 41 additions & 0 deletions docs/src/snap/reference/proxy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Proxy environment variables

Canonical Kubernetes uses the standard system-wide environment variables to
control access through proxies.

On Ubuntu and other Linux operating systems, proxies are configured through
system-wide environment variables defined in the `/etc/environment` file.

- **HTTPS_PROXY**
- **HTTP_PROXY**
- **NO_PROXY**
- **https_proxy**
- **http_proxy**
- **no_proxy**

## No-proxy CIDRS

When configuring proxies, it is important to note that there are always some
CIDRs which need to be excluded and added to the `no-proxy` lists. For
Canonical Kubernetes these are:

- The range used by Kubernetes services (defaults to **10.152.183.0/24**)
- The range used by the Kubernetes pods (defaults to **10.1.0.0/16**)

And it is also important to exclude the local network to maintain access to any
local traffic.

## Configuring

For the `k8s` snap, proxy configuration is controlled by editing the
`etc/environment` file mentioned above. There is an example in the
[How to guide for configuring proxies for the k8s snap][].

For charms deployed by Juju, proxies are managed by configuring the model. See
the [How to guide for configuring proxies for k8s charms][] for an example of
how to set these.

<!-- LINKS -->

[How to guide for configuring proxies for the k8s snap]: /snap/howto/proxy
[How to guide for configuring proxies for k8s charms]: /charm/howto/proxy

0 comments on commit f2711d3

Please sign in to comment.