Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a single-node Kubernetes cluster inside a VM on your laptop for users looking to try out Kubernetes or develop with it day-to-day.

Running Kubernetes Locally via Minikube



  • Windows10 Pro(10.0.17134 N/A ビルド 17134)
  • VirtualBox 5.2.30
  • minikube version: 1.1.0
  • kubectl version 1.14.2



以下の通り、windows用exeをダウンロードして、exeファイル名を minikube.exe に変更します。exeファイルを置いたPathは、システム環境変数に登録しておきます。

PS> Invoke-WebRequest -Uri -OutFile C:\tools\minikube\minikube.exe


> minikube version
minikube version: v1.1.0

Install Minikube


kubernetes用のcliである kubectl をインストールします。こちらはscoop経由でインストール。

> scoop install kubectl
> kubectl version --client
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.2", GitCommit:"66049e3b21efe110454d67df4fa62b08ea79a19b", GitTreeState:"clean", BuildDate:"2019-05-16T16:23:09Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"windows/amd64"}

Install kubectl on Windows

kubernetes clusterの作成

以下のコマンドで、利用できるVirtual Machine上にkubernetesクラスタを作成してくれます。

> minikube start
* minikube v1.1.0 on windows (amd64)
* Downloading Minikube ISO ...
 131.28 MB / 131.28 MB [============================================] 100.00% 0s
* Creating virtualbox VM (CPUs=2, Memory=2048MB, Disk=20000MB) ...
* Found network options:
* Configuring environment for Kubernetes v1.14.2 on Docker 18.09.6
  - env NO_PROXY=
* Downloading kubeadm v1.14.2
* Downloading kubelet v1.14.2
* Pulling images ...
* Launching Kubernetes ...
* Verifying: apiserver proxy etcd scheduler controller dns
* Done! kubectl is now configured to use "minikube"
> minikube status
host: Running
kubelet: Running
apiserver: Running
kubectl: Correctly Configured: pointing to minikube-vm at

minikube start 処理では、Kubernetesクラスタを作成するのと同時に、kubectlに作成クラスタ向けのコンフィグ設定をしてくれます。

> kubectl config view
apiVersion: v1
- cluster:
    certificate-authority: C:\Users\yukari\.minikube\ca.crt
  name: minikube
- context:
    cluster: minikube
    user: minikube
  name: minikube
current-context: minikube
kind: Config
preferences: {}
- name: minikube
    client-certificate: C:\Users\yukari\.minikube\client.crt
    client-key: C:\Users\yukari\.minikube\client.key


> kubectl cluster-info minikube
Kubernetes master is running at
KubeDNS is running at

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

kubernetes dashboardの表示


> minikube dashboard
* Enabling dashboard ...
* Verifying dashboard health ...
* Launching proxy ...
* Verifying proxy health ...
* Opening in your default browser...

Opening の後に出力されているURLにアクセスすると、ダッシュボードが表示されています。

Hello Minikube


Hello Minikube

Hello Worldを返す簡単なNode.jsのコンテナを、kubernetes上で起動するという内容です。Dockerfileの構成は、以下より確認できます。

Hello Minikube - Before you begin


前述したNode.jsのコンテナを1つ持つ Pod 1つにより構成された、 Deployment を作成します。

Pod とは、

A Pod is the basic building block of Kubernetes–the smallest and simplest unit in the Kubernetes object model that you create or deploy. A Pod represents processes running on your Cluster.

A Pod encapsulates an application’s container (or, in some cases, multiple containers), storage resources, a unique network IP, and options that govern how the container(s) should run. A Pod represents a unit of deployment: a single instance of an application in Kubernetes, which might consist of either a single container or a small number of containers that are tightly coupled and that share resources.

AWS ECSの、 タスク にあたるような概念なのでしょうか。

Pod Overview

Deployment とは、上の説明では a single instance of an application in Kubernetes と紹介されていましたが、公式に記載されているUse Caseを読むのがイメージをつかみやすいでしょうか。

  • Create a Deployment to rollout a ReplicaSet. The ReplicaSet creates Pods in the background. Check the status of the rollout to see if it succeeds or not.
  • Declare the new state of the Pods by updating the PodTemplateSpec of the Deployment. A new ReplicaSet is created and the Deployment manages moving the Pods from the old ReplicaSet to the new one at a controlled rate. Each new ReplicaSet updates the revision of the Deployment.
  • Rollback to an earlier Deployment revision if the current state of the Deployment is not stable. Each rollback updates the revision of the Deployment.
  • Scale up the Deployment to facilitate more load.
  • Pause the Deployment to apply multiple fixes to its PodTemplateSpec and then resume it to start a new rollout.
  • Use the status of the Deployment as an indicator that a rollout has stuck.
  • Clean up older ReplicaSets that you don’t need anymore.

AWS ECSの、 サービス にあたるような概念なのでしょうか。



> kubectl create deployment hello-node
deployment.apps/hello-node created

起動するコンテナイメージをGCPのGCRから持ってきて、 hello-node という名前のdeploymentを作成しています。

kubectl - create deployment


> kubectl get deployments
hello-node   1/1     1            1           12m


> kubectl get pods
NAME                          READY   STATUS    RESTARTS   AGE
hello-node-78cd77d68f-8sc2q   1/1     Running   0          2m39s


> kubectl get events
LAST SEEN   TYPE     REASON                    OBJECT                             MESSAGE
3m          Normal   Scheduled                 pod/hello-node-78cd77d68f-8sc2q    Successfully assigned default/hello-node-78cd77d68f-8sc2q to minikube
3m          Normal   Pulling                   pod/hello-node-78cd77d68f-8sc2q    Pulling image ""
2m24s       Normal   Pulled                    pod/hello-node-78cd77d68f-8sc2q    Successfully pulled image ""
2m24s       Normal   Created                   pod/hello-node-78cd77d68f-8sc2q    Created container hello-node
2m24s       Normal   Started                   pod/hello-node-78cd77d68f-8sc2q    Started container hello-node
3m          Normal   SuccessfulCreate          replicaset/hello-node-78cd77d68f   Created pod: hello-node-78cd77d68f-8sc2q
3m          Normal   ScalingReplicaSet         deployment/hello-node              Scaled up replica set hello-node-78cd77d68f to 1


> minikube ssh

docker psコマンドで、コンテナの起動状況を確認。

$ docker ps
CONTAINER ID        IMAGE                                           COMMAND                  CREATED             STATUS              PORTS               NAMES
aa1e4ab36043   "/bin/sh -c 'node se…"   6 minutes ago       Up 6 minutes                            k8s_hello-node_hello-node-78cd77d68f-8sc2q_default_9d559f24-85ba-11e9-83fd-080027270 1e7_0


上記のdocker psコマンド結果から分かる通り、コンテナ上のPortがExposeされていません。コンテナを外部アクセス可能とする仕組みとして Service があります。

A Kubernetes Service is an abstraction which defines a logical set of Pods and a policy by which to access them - sometimes called a micro-service. The set of Pods targeted by a Service is (usually) determined by a Label Selector



> kubectl expose deployment hello-node --type=LoadBalancer --port=8080
service/hello-node exposed

kubectl - expose


> kubectl get services
NAME         TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
hello-node   LoadBalancer   <pending>     8080:31285/TCP   31s
kubernetes   ClusterIP        <none>        443/TCP          4d9h

上記情報から、exposeされているポートにアクセスすると、Node.jsプログラムのHello Worldが帰ってきます。

> curl
Hello World!