Docker for Mac with Kubernetes (and some tips on using Ingress)
Installation
Docker for Mac and Ingress
Some other notes on Ingress
Docker Stacks and CRDs
Conclusion
Docker released a beta version of Docker that includes Kubernetes support. I was excited to try it out on my Mac. Here are my notes and observations from experimenting with Docker for Mac with Kubernetes.
Installation
The Docker folks usually do a great job with a simple user experience, and installation was no exception. I downloaded the edge installer for Docker, which uninstalled my stable version of Docker. In the preferences pane, I enabled Kubernetes, and shortly thereafter, I had a working Kubernetes cluster.
Installing Docker for Mac with Kubernetes
I was also able to use the preexisting
kubectl
$HOME/.kube/config
config
Docker for Mac and Ingress
I decided to try installing Edge Stack, our Kubernetes-Native 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.
Docker for Mac is based on Kubernetes 1.8.2, so I installed Ambassador with RBAC:
---apiVersion: v1kind: Servicemetadata:labels:service: ambassador-adminname: ambassador-adminspec:type: NodePortports:- name: ambassador-adminport: 8877targetPort: 8877selector:service: ambassador---apiVersion: rbac.authorization.k8s.io/v1beta1kind: ClusterRolemetadata:name: ambassadorrules:- apiGroups: [""]resources:- servicesverbs: ["get", "list", "watch"]- apiGroups: [""]resources:- configmapsverbs: ["create", "update", "patch", "get", "list", "watch"]- apiGroups: [""]resources:- secretsverbs: ["get", "list", "watch"]---apiVersion: v1kind: ServiceAccountmetadata:name: ambassador---apiVersion: rbac.authorization.k8s.io/v1beta1kind: ClusterRoleBindingmetadata:name: ambassadorroleRef:apiGroup: rbac.authorization.k8s.iokind: ClusterRolename: ambassadorsubjects:- kind: ServiceAccountname: ambassadornamespace: default---apiVersion: extensions/v1beta1kind: Deploymentmetadata:name: ambassadorspec:replicas: 1template:metadata:labels:service: ambassadorspec:serviceAccountName: ambassadorcontainers:- name: ambassadorimage: datawire/ambassador:0.21.0imagePullPolicy: Alwaysresources:limits:cpu: 1memory: 400Mirequests:cpu: 200mmemory: 100Mienv:- name: AMBASSADOR_NAMESPACEvalueFrom:fieldRef:fieldPath: metadata.namespacelivenessProbe:httpGet:path: /ambassador/v0/check_aliveport: 8877initialDelaySeconds: 3periodSeconds: 3readinessProbe:httpGet:path: /ambassador/v0/check_readyport: 8877initialDelaySeconds: 3periodSeconds: 3- name: statsd-sinkimage: datawire/prom-statsd-exporter:0.6.0restartPolicy: Always
I then deployed an Ambassador
LoadBalancer
---apiVersion: v1kind: Servicemetadata:labels:service: ambassadorname: ambassadorspec:type: LoadBalancerports:- name: ambassadorport: 80targetPort: 80selector:service: ambassador
I wanted to try to connect to Ambassador, but this is what I saw:
$ kubectl get svc NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE ambassador 10.106.236.196 <pending> 80:30612/TCP 45m ambassador-admin 10.102.220.182 <nodes> 8877:31079/TCP 4h kubernetes 10.96.0.1 <none> 443/TCP 4h
Note that the
ambassador
$ curl localhost:80
I added a mapping for Ambassador to route
/httpbin/
httpbin.org
apiVersion: v1kind: Servicemetadata:name: httpbinannotations:getambassador.io/config: |---apiVersion: ambassador/v0kind: Mappingname: httpbin_mappingprefix: /httpbin/service: httpbin.org:80host_rewrite: httpbin.orgspec:ports:- port: 80
And it worked perfectly:
$ curl localhost:80/httpbin/ip { "origin": "65.217.185.138" }
Some other notes on Ingress
In some conversations on the Slack channel, I learned a few other quirks:
- To get a list of open ports, you can compile this binary. I haven’t tried this.
- The service controller does not yet handle collisions between competing services. So the last service will win.
Docker Stacks and CRDs
Docker includes a native integration between Docker Swarm and Kubernetes with a
stack
stack
Conclusion
Docker for Mac with Kubernetes has a lot of promise. While there are the rough edges you’d expect with any beta software, the Docker team has done an amazing job of building a useful alternative to Minikube. In addition, I’m excited to see how they’ve thought through how to make the experience idiomatic for Kubernetes users. I’m looking forward to updates!