理系学生日記

おまえはいつまで学生気分なのか

忍者TOOLS

Docker for MacでKubernetesが動かせます

そういや、Docker for Mac で Kubernetes が統合されていて、手軽に動かすことができたりします。 たぶん、Docker for Windows でもいけるとおもう。

6/12 現在、stable ではなくて、edge が必要です。

  1. Docker Store から、 Docker CE for Mac (Edge) をダウンロード & インストールする
  2. Preference を開くと Kubernetes のタブができているので、Enable Kubernetes とかにチェックを入れて Apply を押下 f:id:kiririmode:20180614053419p:plain
  3. 心を無にして数分待ちます f:id:kiririmode:20180614053452p:plain
  4. おわり

ぼくの Mac 非力なので、さすがにちょっともっさりする。動かしたくない場合は、Enable Kubernetes を off にしましょう。

kubectl はパスが通っており、

$ kubectl config get-contexts
CURRENT   NAME                 CLUSTER                      AUTHINFO             NAMESPACE
*         docker-for-desktop   docker-for-desktop-cluster   docker-for-desktop

$ kubectl describe nodes | head -29
Name:               docker-for-desktop
Roles:              master
Labels:             beta.kubernetes.io/arch=amd64
                    beta.kubernetes.io/os=linux
                    kubernetes.io/hostname=docker-for-desktop
                    node-role.kubernetes.io/master=
Annotations:        node.alpha.kubernetes.io/ttl=0
                    volumes.kubernetes.io/controller-managed-attach-detach=true
CreationTimestamp:  Sat, 09 Jun 2018 16:18:34 +0900
Taints:             <none>
Unschedulable:      false
Conditions:
  Type             Status  LastHeartbeatTime                 LastTransitionTime                Reason                       Message
  ----             ------  -----------------                 ------------------                ------                       -------
  OutOfDisk        False   Thu, 14 Jun 2018 05:40:51 +0900   Sat, 09 Jun 2018 16:18:30 +0900   KubeletHasSufficientDisk     kubelet has sufficient disk space available
  MemoryPressure   False   Thu, 14 Jun 2018 05:40:51 +0900   Sat, 09 Jun 2018 16:18:30 +0900   KubeletHasSufficientMemory   kubelet has sufficient memory available
  DiskPressure     False   Thu, 14 Jun 2018 05:40:51 +0900   Sat, 09 Jun 2018 16:18:30 +0900   KubeletHasNoDiskPressure     kubelet has no disk pressure
  PIDPressure      False   Thu, 14 Jun 2018 05:40:51 +0900   Sat, 09 Jun 2018 16:18:30 +0900   KubeletHasSufficientPID      kubelet has sufficient PID available
  Ready            True    Thu, 14 Jun 2018 05:40:51 +0900   Sat, 09 Jun 2018 16:18:30 +0900   KubeletReady                 kubelet is posting ready status
Addresses:
  InternalIP:  192.168.65.3
  Hostname:    docker-for-desktop
Capacity:
 cpu:                2
 ephemeral-storage:  61252420Ki
 hugepages-1Gi:      0
 hugepages-2Mi:      0
 memory:             2046932Ki
 pods:               110

諸々のコンテナが浮いています。

$ docker ps
CONTAINER ID        IMAGE                            COMMAND                  CREATED             STATUS              PORTS               NAMES
fa235e26a3eb        docker/kube-compose-api-server   "/api-server --kubec…"   2 minutes ago       Up 2 minutes                            k8s_compose_compose-api-75d86595dc-6hthm_docker_589417f5-6bb5-11e8-9690-025000000001_1
5b70dc4b906e        docker/kube-compose-controller   "/compose-controller…"   2 minutes ago       Up 2 minutes                            k8s_compose_compose-6f784b699b-bjcqj_docker_5893f31c-6bb5-11e8-9690-025000000001_0
99cdc4a83577        6f7f2dc7fab5                     "/sidecar --v=2 --lo…"   2 minutes ago       Up 2 minutes                            k8s_sidecar_kube-dns-86f4d74b45-6qvss_kube-system_5892c0e7-6bb5-11e8-9690-025000000001_0
e26b75fc7c3e        c2ce1ffb51ed                     "/dnsmasq-nanny -v=2…"   2 minutes ago       Up 2 minutes                            k8s_dnsmasq_kube-dns-86f4d74b45-6qvss_kube-system_5892c0e7-6bb5-11e8-9690-025000000001_0
c059a047c023        80cc5ea4b547                     "/kube-dns --domain=…"   2 minutes ago       Up 2 minutes                            k8s_kubedns_kube-dns-86f4d74b45-6qvss_kube-system_5892c0e7-6bb5-11e8-9690-025000000001_0
4489eb10b93d        4261d315109d                     "/usr/local/bin/kube…"   3 minutes ago       Up 2 minutes                            k8s_kube-proxy_kube-proxy-cf8dq_kube-system_589bc329-6bb5-11e8-9690-025000000001_0
b30110e654b0        k8s.gcr.io/pause-amd64:3.1       "/pause"                 3 minutes ago       Up 2 minutes                            k8s_POD_kube-proxy-cf8dq_kube-system_589bc329-6bb5-11e8-9690-025000000001_0
846f8502f4ad        k8s.gcr.io/pause-amd64:3.1       "/pause"                 3 minutes ago       Up 3 minutes                            k8s_POD_kube-dns-86f4d74b45-6qvss_kube-system_5892c0e7-6bb5-11e8-9690-025000000001_0
c2ed95a9e38c        k8s.gcr.io/pause-amd64:3.1       "/pause"                 3 minutes ago       Up 3 minutes                            k8s_POD_compose-api-75d86595dc-6hthm_docker_589417f5-6bb5-11e8-9690-025000000001_0
b1e52c46bae3        k8s.gcr.io/pause-amd64:3.1       "/pause"                 3 minutes ago       Up 3 minutes                            k8s_POD_compose-6f784b699b-bjcqj_docker_5893f31c-6bb5-11e8-9690-025000000001_0
303dfa913d0c        353b8f1d102e                     "kube-scheduler --ad…"   3 minutes ago       Up 3 minutes                            k8s_kube-scheduler_kube-scheduler-docker-for-desktop_kube-system_ea66a171667ec4aaf1b274428a42a7cf_0
12f38c43e479        40c8d10b2d11                     "kube-controller-man…"   3 minutes ago       Up 3 minutes                            k8s_kube-controller-manager_kube-controller-manager-docker-for-desktop_kube-system_e7f3602541de405f8d08a19e40551a17_0
b5a093346273        e03746fe22c3                     "kube-apiserver --ad…"   3 minutes ago       Up 3 minutes                            k8s_kube-apiserver_kube-apiserver-docker-for-desktop_kube-system_fbdad7be3cd8f9184b611d030d354124_1
21ca56adc81f        52920ad46f5b                     "etcd --cert-file=/r…"   3 minutes ago       Up 3 minutes                            k8s_etcd_etcd-docker-for-desktop_kube-system_0ad1cafd71e473bf71de8ee290d73e4a_0
fbba1a61f869        k8s.gcr.io/pause-amd64:3.1       "/pause"                 3 minutes ago       Up 3 minutes                            k8s_POD_kube-scheduler-docker-for-desktop_kube-system_ea66a171667ec4aaf1b274428a42a7cf_0
34fd1f8ca8a2        k8s.gcr.io/pause-amd64:3.1       "/pause"                 3 minutes ago       Up 3 minutes                            k8s_POD_etcd-docker-for-desktop_kube-system_0ad1cafd71e473bf71de8ee290d73e4a_0
fa395a8d6994        k8s.gcr.io/pause-amd64:3.1       "/pause"                 3 minutes ago       Up 3 minutes                            k8s_POD_kube-controller-manager-docker-for-desktop_kube-system_e7f3602541de405f8d08a19e40551a17_0
63102892ed1d        k8s.gcr.io/pause-amd64:3.1       "/pause"                 3 minutes ago       Up 3 minutes                            k8s_POD_kube-apiserver-docker-for-desktop_kube-system_fbdad7be3cd8f9184b611d030d354124_0

まとめ

Docker Swarm はどうなってしまうのか。