Skip to content

Instantly share code, notes, and snippets.

@peteristhegreat
Last active December 13, 2018 19:40
Show Gist options
  • Save peteristhegreat/b2d6320587d06c321f4051bcd2c894a3 to your computer and use it in GitHub Desktop.
Save peteristhegreat/b2d6320587d06c321f4051bcd2c894a3 to your computer and use it in GitHub Desktop.
Kubernettes, Docker for Mac, Quick Start

https://github.com/docker/for-mac

https://download.docker.com/mac/stable/Docker.dmg

https://www.youtube.com/watch?v=jWupQjdjLN0

After downloading, and dragging the .app into Applications, make sure docker is pointing at docker in your Docker.app.

$> ls -l $(which docker)
lrwxr-xr-x 1 username 54 Oct 22 13:59 /usr/local/bin/docker -> /Applications/Docker.app/Contents/Resources/bin/docker

Launch the app.

Click two checkboxes

Docker System Tray > Preferences > Kubernettes > Enable Kubernettes (checkbox)

Click and tell it to install.

Docker System Tray > Preferences > Kubernettes > Show system containers (checkbox)

Now you should have something similar when running the following from the command prompt

$> docker container ls
CONTAINER ID        IMAGE                                      COMMAND                  CREATED             STATUS              PORTS               NAMES
7496891abd85        docker/kube-compose-controller             "/compose-controller…"   3 minutes ago       Up 3 minutes                            k8s_compose_compose-74649b4db6-rjwwr_docker_c3fb616e-feec-11e8-8921-025000000001_0
489d6b5b7c50        docker/kube-compose-api-server             "/api-server --kubec…"   3 minutes ago       Up 3 minutes                            k8s_compose_compose-api-574fc7899-brfgz_docker_c3f07300-feec-11e8-8921-025000000001_0
449f00e7733d        k8s.gcr.io/pause-amd64:3.1                 "/pause"                 3 minutes ago       Up 3 minutes                            k8s_POD_compose-74649b4db6-rjwwr_docker_c3fb616e-feec-11e8-8921-025000000001_0
d7df7895828e        k8s.gcr.io/pause-amd64:3.1                 "/pause"                 3 minutes ago       Up 3 minutes                            k8s_POD_compose-api-574fc7899-brfgz_docker_c3f07300-feec-11e8-8921-025000000001_0
53fe69546c7e        k8s.gcr.io/k8s-dns-sidecar-amd64           "/sidecar --v=2 --lo…"   4 minutes ago       Up 4 minutes                            k8s_sidecar_kube-dns-86f4d74b45-b9fj5_kube-system_9e3a9f75-feec-11e8-8921-025000000001_0
cbaaf411dcad        k8s.gcr.io/k8s-dns-dnsmasq-nanny-amd64     "/dnsmasq-nanny -v=2…"   4 minutes ago       Up 4 minutes                            k8s_dnsmasq_kube-dns-86f4d74b45-b9fj5_kube-system_9e3a9f75-feec-11e8-8921-025000000001_0
d340472962f6        k8s.gcr.io/kube-proxy-amd64                "/usr/local/bin/kube…"   4 minutes ago       Up 4 minutes                            k8s_kube-proxy_kube-proxy-l8kft_kube-system_9e84ee3c-feec-11e8-8921-025000000001_0
6258622a6c06        k8s.gcr.io/k8s-dns-kube-dns-amd64          "/kube-dns --domain=…"   4 minutes ago       Up 4 minutes                            k8s_kubedns_kube-dns-86f4d74b45-b9fj5_kube-system_9e3a9f75-feec-11e8-8921-025000000001_0
1d8ec026db77        k8s.gcr.io/pause-amd64:3.1                 "/pause"                 4 minutes ago       Up 4 minutes                            k8s_POD_kube-proxy-l8kft_kube-system_9e84ee3c-feec-11e8-8921-025000000001_0
0973cc343bee        k8s.gcr.io/pause-amd64:3.1                 "/pause"                 4 minutes ago       Up 4 minutes                            k8s_POD_kube-dns-86f4d74b45-b9fj5_kube-system_9e3a9f75-feec-11e8-8921-025000000001_0
c475d6d099f6        k8s.gcr.io/etcd-amd64                      "etcd --peer-client-…"   5 minutes ago       Up 5 minutes                            k8s_etcd_etcd-docker-for-desktop_kube-system_22cd22b5aea7fd5cc9f4a1e01f39aa80_0
45bce07be2bd        k8s.gcr.io/kube-apiserver-amd64            "kube-apiserver --ad…"   5 minutes ago       Up 5 minutes                            k8s_kube-apiserver_kube-apiserver-docker-for-desktop_kube-system_fe7a5e8c7c3718872477c476a1e9ec1c_0
7072959c7db8        k8s.gcr.io/kube-controller-manager-amd64   "kube-controller-man…"   5 minutes ago       Up 5 minutes                            k8s_kube-controller-manager_kube-controller-manager-docker-for-desktop_kube-system_aa372ab1759880385e4a16c1466d6866_0
0a375de254fd        k8s.gcr.io/kube-scheduler-amd64            "kube-scheduler --le…"   5 minutes ago       Up 5 minutes                            k8s_kube-scheduler_kube-scheduler-docker-for-desktop_kube-system_8c33750d637b5de93e891805153e7560_0
598c29b4310f        k8s.gcr.io/pause-amd64:3.1                 "/pause"                 5 minutes ago       Up 5 minutes                            k8s_POD_etcd-docker-for-desktop_kube-system_22cd22b5aea7fd5cc9f4a1e01f39aa80_0
07ae08a5f34d        k8s.gcr.io/pause-amd64:3.1                 "/pause"                 5 minutes ago       Up 5 minutes                            k8s_POD_kube-apiserver-docker-for-desktop_kube-system_fe7a5e8c7c3718872477c476a1e9ec1c_0
1b7686ae0cc0        k8s.gcr.io/pause-amd64:3.1                 "/pause"                 5 minutes ago       Up 5 minutes                            k8s_POD_kube-controller-manager-docker-for-desktop_kube-system_aa372ab1759880385e4a16c1466d6866_0
31953ddde78a        k8s.gcr.io/pause-amd64:3.1                 "/pause"                 5 minutes ago       Up 5 minutes                            k8s_POD_kube-scheduler-docker-for-desktop_kube-system_8c33750d637b5de93e891805153e7560_0

$ kubectl get services
NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP   6m

$ kubectl get pods
No resources found.

Download a set of yaml files from Kubernettes example pages.

$ git clone https://github.com/kubernetes/examples.git k8s-examples && cd k8s-examples/mysql-wordpress-pd

$ kubectl create -f local-volumes.yaml . # note that some examples will just make the volumes on demand without a separate call to a "Persistent Volumes" creation yaml

$ kubectl get pv

$ kubectl create secret generic mysql-pass --from-literal=password=DockerCon

$ kubectl get secrets

$ cat mysql-deployment.yaml

$ kubectl create -f mysql-deployment.yaml

$ kubectl create -f wordpress-deployment.yaml

$ kubectl get pods

$ kubectl get services

$ kubectl port-forward wordpress-mysql-XXXXXXX-xxxx 3306:3306

To interact with the api, you will probably need to use port fowarding

$ kubectl cluster-info

$ kubectl proxy --port=8000 &

Open the url in the browser mentioned in cluster-info and ignore the certificate errors, and fail when missing the bearer token, or use the proxy port instead.

You can see the bearer token by running:

$ kubectl get secrets
$ kubectl describe secrets/default-token-xxxxxx

Then pass into the calls the bearer token as part of the http "Authorization" header, in the format of "Bearer xxxxxxxx....xxxxxx"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment