How to deploy Charmed Kubeflow on MicroK8s behind a web proxy

1. Introduction

In this short how-to guide, you will learn how to deploy Charmed Kubeflow on MicroK8s from behind a web proxy.


2. Configure the systems for operation behind a web proxy

Since MicroK8s includes a few utilities (eg, curl, helm) it makes sense to configure the system proxy settings in /etc/environment. We’ll need to add a few addresses to the proxy exclusion list so that things work as they should.

CLUSTER_SUBNET=<YOUR MICROK8S CLUSTER SUBNET>/24
CLUSTER_HOSTS=<YOUR MICROK8S CLUSTER HOSTNAMES> #comma separated
PROXY_HOST=squid.internal #change as required
PROXY_PORT=3128 #change as required

echo "HTTPS_PROXY=http://$PROXY_HOST:$PROXY_PORT" | sudo tee -a /etc/environment
echo "HTTP_PROXY=http://$PROXY_HOST:$PROXY_PORT" | sudo tee -a /etc/environment
echo "NO_PROXY=10.1.0.0/16,10.152.183.0/24,127.0.0.1,$CLUSTER_SUBNET,$CLUSTER_HOSTS,admission-webhook.kubeflow.svc,modeloperator.kubeflow.svc,modeloperator.controller-uk8s.svc,katib-controller.kubeflow.svc,169.254.169.254" | sudo tee -a /etc/environment
echo "https_proxy=http://$PROXY_HOST:$PROXY_PORT" | sudo tee -a /etc/environment
echo "http_proxy=http://$PROXY_HOST:$PROXY_PORT" | sudo tee -a /etc/environment
echo "no_proxy=10.1.0.0/16,10.152.183.0/24,127.0.0.1,$CLUSTER_SUBNET,$CLUSTER_HOSTS,admission-webhook.kubeflow.svc,modeloperator.kubeflow.svc,modeloperator.controller-uk8s.svc,katib-controller.kubeflow.svc,169.254.169.254" | sudo tee -a /etc/environment

Reboot the machines and wait until they’re up again.

sudo reboot

3. Install MicroK8s

Kubernetes 1.21: Remember to install the supported MicroK8s version 1.21/stable for Charmed Kubeflow.

sudo snap install microk8s --channel=1.21/stable --classic

Enable MicroK8s storage and wait for it to be available.

microk8s enable storage

4. Set a local DNS server for CoreDNS

When running behind a proxy, CoreDNS may not be able to reach public DNS servers, so you may want to configure MicroK8s to use a local DNS server. You can configure the DNS server that MicroK8s uses to use the host’s DNS server configuration as follows:

microk8s enable dns:$(resolvectl status | grep "Current DNS Server" | awk '{print $NF}')"

5. Deploy and bootstrap Juju

Once you’ve deployed MicroK8s as above, the next steps are to install and bootstrap Juju.

PROXY_HOST="squid.internal" #change as required
PROXY_PORT=3128 #change as required
CLUSTER_SUBNET=<YOUR MICROK8S CLUSTER SUBNET>/24

sudo snap install juju --classic
sudo snap install juju-bundle --classic
sudo snap install juju-wait --classic

juju bootstrap microk8s uk8s
juju add-model kubeflow
juju model-config \
  {juju,apt,snap}-http{,s}-proxy=http://$PROXY_HOST:$PROXY_PORT \
  apt-no-proxy=localhost,127.0.0.1 \
  juju-no-proxy=localhost,127.0.0.1,0.0.0.0,10.0.8.0/24,$CLUSTER_SUBNET

6. Deploy Kubeflow

When all of the previous steps are completed, you can deploy Kubeflow as usual by following the quickstart guide.