- Notifications
You must be signed in to change notification settings - Fork10
Development Toolkit for Kubernetes on Docker for Mac.
License
pengsrc/docker-for-mac-kubernetes-devkit
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Docker for Mac (on Edge channel) includes a local Kubernetes cluster which is very delightful for test and development. Refer to the official document (https://docs.docker.com/docker-for-mac/#kubernetes) to know how to get it up and running.
If you are using Kubernetes on Docker for Mac, some scripts in this repository might be helpful.
Because the Docker for Mac containers are actually running in a VM powered byHyperKit, you can't directly have interactions with the containers. More details here,Docker for Mac - Networking - Known limitations, use cases, and workarounds.
To solve this problem, run an OpenVPN server container inside the VM withhost network mode, then you can reach the containers with its internal IP. You can run the OpenVPN server with docker-compose or on Kubernetes.
Off course you can follow the docker-compose approach without Kubernetes.
Generally, it works like this:
Mac <-> Tunnelblick <-> socat/service <-> OpenVPN Server <-> ContainersInstall
Tunnelblick(an open source GUI OpenVPN client for Mac).Change into the
docker-for-mac-openvpndirectory.
Install
helm(the package manager for Kubernetes).Create local values file at
local/values.yamland specify local dirs.
dirPaths: # The project dir. data: /tmp/docker-for-mac-kubernetes-devkit/docker-for-mac-openvpn # Local dir to hold generated files. local: /tmp/docker-for-mac-kubernetes-devkit/docker-for-mac-openvpn/local # Local dir to hold generated server configs. configs: /tmp/docker-for-mac-kubernetes-devkit/docker-for-mac-openvpn/local/configs- Run the OpenVPN server.
$ helm install -n docker-for-mac-openvpn --namespace docker-for-mac -f local/values.yaml.Run the OpenVPN server, it'll generate certificates and configurations at the first time, maybe a little slow.
$# Run$ docker-compose up -d$# Follow logs$ docker-compose logs -f
Now, you will get the client config file at./local/docker-for-mac.ovpn. Add the subnets that you want to reach at bottom of the client config like below, and connect to the local OpenVPN server.
route 192.168.65.0 255.255.255.0route 10.96.0.0 255.240.0.0Run a container and access to it directory with it's IP address.
$# Start Nginx$ docker run --rm -it nginx$# Find out the IP address$ docker inspect`docker ps| grep nginx| awk'{print $1}'`| grep'"IPAddress"'"IPAddress":"172.16.0.11",$# Visit$ curl http://172.16.0.11<!DOCTYPE html><html><head><title>Welcome to nginx!</title>...
In most times, a Kubernetes ingress controller is needed to manage all traffic, but there's no cloud available for a Mac.
If you define yourservice type asLoadBalancer in Kubernetes, Docker for Mac will open a port on host machine. So we can deploy theNginx Ingress Controller to serve and dispatch requests.
First of all, stop anything that listing on port 80 or 443.
$ kubectl apply -f ingress-nginx/namespacesnamespace"ingress-nginx" created$ kubectl apply -f ingress-nginx/configmapsconfigmap"nginx-configuration" createdconfigmap"tcp-services" createdconfigmap"udp-services" created$ kubectl apply -f ingress-nginx/deploymentsdeployment"default-http-backend" createddeployment"nginx-ingress-controller" created$ kubectl apply -f ingress-nginx/servicesservice"default-http-backend" createdservice"nginx-ssl" createdservice"nginx" created
Now nginx ingress controller is listing on port 80 and 443, visithttp://127.0.0.1 will see the default HTTP backend.
$ curl http://127.0.0.1default backend - 404
Check the ingress controller.
$ kubectl get all -n ingress-nginxNAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGEdeploy/default-http-backend 1 1 1 1 21mdeploy/nginx-ingress-controller 1 1 1 1 21mNAME DESIRED CURRENT READY AGErs/default-http-backend-55c6c69b88 1 1 1 21mrs/nginx-ingress-controller-579f8bf799 1 1 1 21mNAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGEdeploy/default-http-backend 1 1 1 1 21mdeploy/nginx-ingress-controller 1 1 1 1 21mNAME DESIRED CURRENT READY AGErs/default-http-backend-55c6c69b88 1 1 1 21mrs/nginx-ingress-controller-579f8bf799 1 1 1 21mNAME READY STATUS RESTARTS AGEpo/default-http-backend-55c6c69b88-9rcr7 1/1 Running 0 21mpo/nginx-ingress-controller-579f8bf799-4pfjk 1/1 Running 0 21mNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEsvc/default-http-backend ClusterIP 10.110.153.121<none> 80/TCP 21msvc/nginx LoadBalancer 10.100.205.59 localhost 80:31764/TCP 21msvc/nginx-ssl LoadBalancer 10.108.87.129 localhost 443:30592/TCP 21m
The Apache License (Version 2.0, January 2004).
About
Development Toolkit for Kubernetes on Docker for Mac.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.