Skip to content

Setting-up Kubernetes

If you already have access to a Kubernetes cluster, then skip to Configuring Ingress - you are almost ready-to-go. If not, then please read on.

Deploying Locally

If you are new to Kubernetes or want to test deployments locally, then we recommend that you start by installing Minikube. Minikube will enable you with everything you need to use Bodywork, it is well documented and supported by a large community.

Managed Kubernetes Services

When you are ready to deploy to the cloud, then the easiest path is via a managed Kubernetes service from one of the following cloud infrastructure providers:

Required Kubernetes Version

Bodywork relies on the official Kubernetes Python client, whose latest version (12.0.1) has full compatibility with Kubernetes 1.16. We recommend that you also use Kubernetes 1.16, but in-practice Bodywork will work with other versions - more information can be found here. Bodywork is tested against Kubernetes 1.16 running on Amazon Elastic Kubernetes Service.

Installing the kubectl Tool

Kubectl is the command-line tool that lets you control your Kubernetes cluster - see here for an overview. Bodywork does not use kubectl (it talks directly to the Kubernetes API instead), and so it is not a requirement. Regardless, kubectl is an essential tool to have access to, so we strongly recommend that you install it - see here for instructions.

Configuring Ingress

If you want to expose Bodywork-deployed services to requests from outside your cluster, then you need to install the NGINX Ingress Controller within your cluster. This will act like an API Gateway for your cluster, that will route external HTTP requests to internal services.

The NGINX Ingress controller is an official Kubernetes project and can be installed with a single command - for local a Minikube cluster you would use,

$ minikube addons enable ingress

Or for EKS on AWS you would use,

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.44.0/deploy/static/provider/aws/deploy.yaml

The precise details for every potential Kubernetes deployment option are listed here.

Managed Kubernetes services will also provision an external load balancer to manage the flow of traffic to the ingress controller (and hence the cluster). Note, this will have an associated cost that is additional to that of the Kubernetes cluster.

Connecting to the Cluster

Get the public-facing IP address for your ingress controller with the following command,

kubectl -n ingress-nginx get service ingress-nginx-controller

And make a note of the EXTERNAL-IP field, that will have to be used for all requests to Bodywork-deployed services originating from outside the cluster. Services within the cluster can communicate with one another using the cluster's internal network.

Learning Kubernetes

Familiarity with basic Kubernetes concepts and some exposure to the kubectl command-line tool will make life easier, but are not essential. If you would like to learn a bit more about Kubernetes, then we recommend the first two introductory sections of Marko Lukša's excellent book Kubernetes in Action, or the introductory article we wrote on Deploying Python ML Models with Flask, Docker and Kubernetes.

Getting Help

If you need help with Kubernetes, then please don't hesitate to contact us and we'll do our best to get you up-and-running.