0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[K8s] minikube podの立ち上げ

Posted at

概要

本投稿はminikubeを使用し、K8sの基本動作を抑えることを目的とした個人メモです。

前提条件

  • MacOSにminikube, kubectlがインストール済みであること。
  • K8sクラスタが起動していること
$ minikube start

クラスタ構成の確認

以下コマンドではK8sマスタIPアドレスと、内部DNSエンドポイントが表示される。
kubectlコマンドがマスターと通信できない場合はエラーとなるため、minikube stop実行後、再度クラスタを立ち上げること

$ kubectl cluster-info
Kubernetes master is running at https://192.168.99.100:8443
KubeDNS is running at https://192.168.99.100:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
kubernetes-dashboard is running at https://192.168.99.100:8443/api/v1/namespaces/kube-system/services/kubernetes-dashboard/proxy

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

nodeの確認方法は以下の通り。
マルチノード構成の場合はマスタの他にワーカーノードも表示される。

$ kubectl get node
NAME       STATUS    ROLES     AGE       VERSION
minikube   Ready     <none>    9m        v1.4.5

ポッドの実行

今回はhello-worldイメージを使用し、ポッドの立ち上げを行う。

$ kubectl run hello-world --image=hello-world -it --restart=Never

また、既に同じポッドが立ち上がっている場合は以下のようなエラーとなる。

$ kubectl run hello-world --image=hello-world -it --restart=Never
Error from server (AlreadyExists): pods "hello-world" already exists

ポッドの状態は以下コマンドで確認することが可能。

$ kubectl get pod
NAME          READY     STATUS      RESTARTS   AGE
hello-world   0/1       Completed   0          3m

ポッドを削除する場合はdeleteを行う。

$ kubectl delete pod hello-world
pod "hello-world" deleted

削除後はポッドが起動していないことを確認できる。

$ kubectl get pod
No resources found.

ログを確認する場合は以下の通り。

$ kubectl logs hello-world
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?