As per the official documentation, Kubernetes is only available in Docker for Mac 17.12 CE Edge. Go to the official download page and click on the Edge channel and not the Stable version. Download the.dmg file and go ahead with the standard installation steps. Docker for Mac and Ingress. I decided to try installing Ambassador, our open source API Gateway built on the Envoy Proxy. Ambassador strives to be as idiomatic to Kubernetes as possible (e.g., it’s configured via annotations), so it’s a good real-world test for a Kubernetes implementation.
Last week I deployed Fn Project on Kubernetes as a quick smoke test. Fn is the new serverless platform that was open sourced at Java One 2017. Running it on Kubernetes is easier than ever because Docker directly supports Kubernetes now, as announced at the last DockerCon. In the end it just worked without any issues.
To reproduce the steps, first of all make sure the latest version of Docker with Kubernetes support is installed properly and Kubernetes is enabled (in my case this is 17.12.0-ce-mac45 from the edge channel) .
List the images of running Docker containers. This should show you the containers required for K8s if you enabled it in the Docker console under preferences:
Next, check if there are existing contexts. For example I have minikube and and GKE configured as well. Make sure the * (astericks) is set to docker-for-desktop:
If it is not set correctly, you can point kubectl to the correct Kubernetes cluster with the following command:
Also you can see the running nodes:
Check out the cluster, it just consists of a single node:
Setup
To get better visibility into K8s I recommend to install the Kubernetes Dashboard:
The dashboard is running in the kube-system namespace and you can check this with the following command:
Enable Port Forwarding for the dashboard
Enable port forwarding to port 8443 with the following command and make sure to use the correct pod name:
With a web browser connect to https://localhost:8443. When asked, allow access for the untrusted site and click on “Skip”.
Alternative to Port Forward: Proxy
Alternatively you could access it via the proxy service:
Then use the following URL with the browser
Microservice smoke test
The following steps are not necessary to run Fn project. However, I first deployed a small microservice to see if Kubernetes was running fine for me on my Mac. Feel free to skip that entirely. To copy what I did, you could follow the steps for load balancing a microservice with K8s
Helm
Make sure your Kubernetes cluster is up and running and working correctly. We will use the K8s package manager Helm to install Fn.
Install Helm
Follow the instructions to [install Helm(https://docs.helm.sh/using_helm/#installing-helm) on your system, e.g. on a Mac it can be done with with brew. Helm will talk to Tiller, a deployment on the K8s cluster.
Init Helm and provision Tiller
Install Fn
You can simply follow the instructions about installing Fn on Kubernetes. I put the steps here for completeness. First, let’s clone the fn-helm repo from github:
Install chart dependencies (from requirements.yaml):
Then install the chart. I chose the release name fm-release:
Then make sure to set the FN_API_URL as described in the output of the command above.
This should be it! You should see the following deployment from the K8s console.
Try to run a function. For more details checke the Fn Helm instruction on github.
Installing Fn on K8s with Helm should work on any Kubernetes cluster. Give it a try yourself, code some functions and run them on Fn / Kubernetes. Feel free to check out my Serverless slides.
Several months back I spent some time playing with Kubernetes but it’s been a while so I need to retrace my steps to get back up to speed.
I’ve already have my Docker for Mac single Kubernetes node running (see here)
Next, I need to run a local Docker repository where I can push my Docker images for testing. I walked through these steps here.
I have a Docker image called examplespringboot that I want to deploy to my local single node Kubernetes cluster, so first up, tag it:
And then push it:
With my local Kubernetes cluster up:
I created a deployment.yml for my Docker container using the example here:
This references the Docker image from my local Docker repo.
To create the deployment:
Now you can describe the pod and the deployment and watch them come up:
At this point the running pod is not exposed outside of the cluster. Following the steps here to expose as a service and assign an external ip:
If you describe the service you now see it has a LoadBalancer Ingress assigned on localhost:
Calling localhost:8080/example/hello on my service, now it’s up and responding:
Done!