Kubeflow on K3s
I want to try out Kubeflow on my desktop. The obvious choice is to use microk8s (or minikube, but I prefer not to use VM). But somehow I keep getting problem to successfully configure Kubeflow on it. At this point, I don't want to get too deep with the infrastructure itself (Kubernetes). Let's save it for another time. I just want to focus on Kubeflow.
Finally I am able to make it working properly. I use k3s instead of microk8s. I'll explain the steps shortly. As a note, I use Ubuntu 20.04.
Install k3s on a single node
curl -sfL https://get.k3s.io | sh -s - server
confirm if k3s is running:
sudo k3s kubectl get nodes
Install Kubeflow operator
Reference: https://www.kubeflow.org/docs/operator/install-operator/
Go to Kubeflow operator: https://operatorhub.io/operator/kubeflow
Click `Install`, a pop-up menu will be displayed with installation instruction:
According to the instruction, the first step is to download a script that will install Operator Lifecycle Manager (OLM). But the script won't work because it assumes that we are using Kubernetes (directly calling `kubectl` command). On the other hands, we use `k3s kubectl` since we have k3s. Therefore, we need to download the script first, and then replace any `kubectl` command with `sudo k3s kubectl`. Another alternative is to make `kubectl` as an alias of `sudo k3s kubectl`, but I haven't tried it yet.
So, first download the script:
curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.17.0/install.sh
Next, modify the script by replacing `kubectl` with `sudo k3s kubectl`:
bash install.sh v0.17.0
Install the kubeflow operator:
kubectl create -f https://operatorhub.io/install/kubeflow.yaml
next:
sudo k3s kubectl get csv -n operators
Installing Kubeflow
Reference: https://www.kubeflow.org/docs/operator/install-kubeflow/
Firstly, install yq. Note that here we are going to use yq version 3, because in the guideline above we are going to use `yq w <>` command, which is not present in yq version 4.
sudo wget https://github.com/mikefarah/yq/releases/download/3.4.0/yq_linux_amd64 -O /usr/bin/yq &&\\n sudo chmod +x /usr/bin/yq
Now, we can just follow steps mentioned in the link above:
# download a default KfDef configuration from remote repo
export KFDEF_URL=https://raw.githubusercontent.com/kubeflow/manifests/v1.1-branch/kfdef/kfctl_ibm.yaml
export KFDEF=$(echo "${KFDEF_URL}" | rev | cut -d/ -f1 | rev)
curl -L ${KFDEF_URL} > ${KFDEF}
# add metadata.name field
# Note: yq can be installed from https://github.com/mikefarah/yq
export KUBEFLOW_DEPLOYMENT_NAME=kubeflow
yq w ${KFDEF} 'metadata.name' ${KUBEFLOW_DEPLOYMENT_NAME} > ${KFDEF}.tmp && mv ${KFDEF}.tmp ${KFDEF}# create the namespace for Kubeflow deployment
KUBEFLOW_NAMESPACE=kubeflow
kubectl create ns ${KUBEFLOW_NAMESPACE}
# create the KfDef custom resource
kubectl create -f ${KFDEF} -n ${KUBEFLOW_NAMESPACE}Access Kubeflow UI
sudo k3s kubectl port-forward -n istio-system svc/istio-ingressgateway 8080:80






Comments
Post a Comment