Minikube
ナビゲーションに移動
検索に移動
| Kubernetes | MicroK8s | Docker |
目次
minikube
- https://github.com/kubernetes/minikube
- ローカル開発や学習、テスト用のシンプルなKubernetesシュミレータ
- シングルノードクラスタで、インストールには、ローカルマシンにハイパーバイザーがインストールされていること
- VT-x/AMD-v 仮想化がBIOSで有効化されていること。
- Minikubeを使用してローカル環境でKubernetesを動かす
インストール
Ubuntu + 仮想環境
入手
- $ curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
- $ sudo +x minkube
インストール
- $ sudo install minikube /usr/local/bin
利用
ローカルクラスタの作成
- ローカル仮想マシンを作成
- Kubernetesを設定
- kubectlを設定
- > minikube start
- VirtualBox
- Ubuntu+KVM
クラスタの確認
- $ kubectl config get-contexts
- CURRENT NAME CLUSTER AUTHINFO NAMESPACE
- * minikube minikube minikube
停止
- > minikube stop
クラスタを削除
- > minikube delete
ダッシュボード
- $ minikube dashboard
コマンド
コマンド | 内容 |
---|---|
ssh | minikube の環境にログインします(デバッグ用) |
Kubernetes Deploymentを作る
- 単純なHTTPサーバーであるechoserverという既存のイメージを使用して、Kubernetes Deploymentを作る
- --portを使用して8080番ポートで公開
- $ kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.10
- deployment.apps/hello-minikube created
Deploymentに接続するために、Serviceとして公開
- $ kubectl expose deployment hello-minikube --type=NodePort --port=8080
- service/hello-minikube exposed
Podが起動しているか確認
- $ kubectl get pod
- NAME READY STATUS RESTARTS AGE
- hello-minikube-64b64df8c9-jzm5v 1/1 Running 0 11m
公開サービスのURLを確認
- $ minikube service hello-minikube --url
- http://192.168.39.214:31429
クラスタのステータス
- Serverとクライアントのバージョン
- $ kubectl version
- Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.8", GitCommit:"9f2892aab98fe339f3bd70e3c470144299398ace", GitTreeState:"clean", BuildDate:"2020-08-13T16:12:48Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}
- Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.3", GitCommit:"2e7996e3e2712684bc73f0dec0200d64eec7fe40", GitTreeState:"clean", BuildDate:"2020-05-20T12:43:34Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}
- クラスタを構成しているコンポーネントを確認
- $ kubectl get componentstatus
- NAME STATUS MESSAGE ERROR
- controller-manager Healthy ok
- scheduler Healthy ok
- etcd-0 Healthy {"health":"true"}
ワーカーノードの表示
- クラスタ上の全のノードを表示
- $ kubectl get nodes
- NAME STATUS ROLES AGE VERSION
- minikube Ready master 3h13m v1.18.3
ノードの詳細情報
- kubectl describe nodes [ノード名]
基本情報が最初に表示される
- Name: minikube
- Roles: master
- Labels: beta.kubernetes.io/arch=amd64
- beta.kubernetes.io/os=linux
- kubernetes.io/arch=amd64
- kubernetes.io/hostname=minikube
- kubernetes.io/os=linux
- node-role.kubernetes.io/master=
- Annotations: kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock
- node.alpha.kubernetes.io/ttl: 0
- volumes.kubernetes.io/controller-managed-attach-detach: true
- CreationTimestamp: Mon, 05 Aug 2019 23:17:24 +0900
- Taints: <none>
- Unschedulable: false
ノード上で動いているオペレーションの情報が表示される
- それぞれのノードが十分なディスクとメモリを持っているか
- Kubernatesマスターに対して正常であるか
- Conditions:
- Type Status LastHeartbeatTime LastTransitionTime Reason Message
- ---- ------ ----------------- ------------------ ------ -------
- MemoryPressure False Tue, 13 Aug 2019 01:01:05 +0900 Mon, 05 Aug 2019 23:17:15 +0900 KubeletHasSufficientMemory kubelet has sufficient memory available
- DiskPressure False Tue, 13 Aug 2019 01:01:05 +0900 Mon, 05 Aug 2019 23:17:15 +0900 KubeletHasNoDiskPressure kubelet has no disk pressure
- PIDPressure False Tue, 13 Aug 2019 01:01:05 +0900 Mon, 05 Aug 2019 23:17:15 +0900 KubeletHasSufficientPID kubelet has sufficient PID available
- Ready True Tue, 13 Aug 2019 01:01:05 +0900 Mon, 05 Aug 2019 23:17:15 +0900 KubeletReady kubelet is posting ready status
- Addresses:
- InternalIP: 10.0.2.15
- Hostname: minikube
マシンのキャパシティ情報の表示
- Capacity:
- cpu: 2
- ephemeral-storage: 17784772Ki
- hugepages-2Mi: 0
- memory: 2038624Ki
- pods: 110
- Allocatable:
- cpu: 2
- ephemeral-storage: 16390445849
- hugepages-2Mi: 0
- memory: 1936224Ki
- pods: 110
ノード上のソフトウェアバージョンの表示
- System Info:
- Machine ID: 7ec5a55cfdc14693866eccf4e9a1228f
- System UUID: 2C88347D-32CC-4F26-9AEE-1FED259A233C
- Boot ID: 1da81daa-4519-4f04-afe0-64efecedd7e7
- Kernel Version: 4.15.0
- OS Image: Buildroot 2018.05.3
- Operating System: linux
- Architecture: amd64
- Container Runtime Version: docker://18.9.6
- Kubelet Version: v1.15.0
- Kube-Proxy Version: v1.15.0
ノード上で動いているPod情報の表示
- Non-terminated Pods: (9 in total)
- Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits AGE
- --------- ---- ------------ ---------- --------------- ------------- ---
- kube-system coredns-5c98db65d4-j24hp 100m (5%) 0 (0%) 70Mi (3%) 170Mi (8%) 7d1h
- kube-system coredns-5c98db65d4-phtm8 100m (5%) 0 (0%) 70Mi (3%) 170Mi (8%) 7d1h
- kube-system etcd-minikube 0 (0%) 0 (0%) 0 (0%) 0 (0%) 7d1h
- kube-system kube-addon-manager-minikube 5m (0%) 0 (0%) 50Mi (2%) 0 (0%) 7d1h
- kube-system kube-apiserver-minikube 250m (12%) 0 (0%) 0 (0%) 0 (0%) 7d1h
- kube-system kube-controller-manager-minikube 200m (10%) 0 (0%) 0 (0%) 0 (0%) 7d1h
- kube-system kube-proxy-wrgp5 0 (0%) 0 (0%) 0 (0%) 0 (0%) 7d1h
- kube-system kube-scheduler-minikube 100m (5%) 0 (0%) 0 (0%) 0 (0%) 7d1h
- kube-system storage-provisioner 0 (0%) 0 (0%) 0 (0%) 0 (0%) 7d1h
- Allocated resources:
- (Total limits may be over 100 percent, i.e., overcommitted.)
- Resource Requests Limits
- -------- -------- ------
- cpu 755m (37%) 0 (0%)
- memory 190Mi (10%) 340Mi (17%)
- ephemeral-storage 0 (0%) 0 (0%)
- Events:
- Type Reason Age From Message
- ---- ------ ---- ---- -------
- Normal NodeHasSufficientMemory 7d1h (x8 over 7d1h) kubelet, minikube Node minikube status is now: NodeHasSufficientMemory
- Normal NodeHasNoDiskPressure 7d1h (x8 over 7d1h) kubelet, minikube Node minikube status is now: NodeHasNoDiskPressure
- Normal NodeHasSufficientPID 7d1h (x7 over 7d1h) kubelet, minikube Node minikube status is now: NodeHasSufficientPID
- Normal Starting 7d1h kube-proxy, minikube Starting kube-proxy.
- Normal Starting 12m kubelet, minikube Starting kubelet.
- Normal NodeHasSufficientMemory 12m (x8 over 12m) kubelet, minikube Node minikube status is now: NodeHasSufficientMemory
- Normal NodeHasNoDiskPressure 12m (x8 over 12m) kubelet, minikube Node minikube status is now: NodeHasNoDiskPressure
- Normal NodeHasSufficientPID 12m (x7 over 12m) kubelet, minikube Node minikube status is now: NodeHasSufficientPID
- Normal NodeAllocatableEnforced 12m kubelet, minikube Updated Node Allocatable limit across pods
- Normal Starting 11m kube-proxy, minikube Starting kube-proxy
クラスタのコンポーネント
- Kubernetesクラスタを構成する多くのコンポーネントが、Kubernetes自体を使ってデプロイされる
- kube-system Namesspace内で動作
Kubernetes proxy
- クラスタ内のロードバランスされたServiceにネットワークトラフィックをルーティング
- クラスタ内の各ノードで動いている必要がある
- DaemonSetというAPIオブジェクトが多くのクラスタではノードでプロキシを動作させるために利用される
Namespace
- クラスタ内のオブジェクトを構造化
- kubectlはデフォルトではdefaultというNamespaceとやり取り
- --namespace で指定できる
Context
- デフォルトのNamespaceを恒久的に変更したい場合
- $HOME/.kube/config に保存される
Kubernetes APIオブジェクトの参照
- Kubernetes上にあるものは、すべてRESTFulリソースであらわされる
- Kubernetes API
- Kubernetes API Reference
© 2006 矢木浩人