実施すること
- kubectlを使ってpodを動かす
参考
kubectlのオプション
helloworldを試す
試す
現在のpodを表示
- 何も表示されないこと
[tsubame@control-plane01 ~]$ kubectl get pods No resources found in default namespace. [tsubame@control-plane01 ~]$
Podを起動
- エラーが無いこと
[tsubame@control-plane01 ~]$ kubectl run --image hello-world:latest --restart Never helloworld helloworld pod/helloworld created [tsubame@control-plane01 ~]$
podの状態を確認
- statusがえらーでは無いこと
[tsubame@control-plane01 ~]$ kubectl get pods NAME READY STATUS RESTARTS AGE helloworld 0/1 Completed 0 3m34s [tsubame@control-plane01 ~]$
ログ確認
- 表示されること
[tsubame@control-plane01 ~]$ kubectl logs helloworld Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (arm64v8) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/ [tsubame@control-plane01 ~]$
詳細を確認
- 表示されること
- デフォルトではImageがdocker.ioから取得していることが確認できたこと
[tsubame@control-plane01 ~]$ kubectl get pods NAME READY STATUS RESTARTS AGE helloworld 0/1 Completed 0 3m34s [tsubame@control-plane01 ~]$ kubectl describe pods helloworld Name: helloworld Namespace: default Priority: 0 Service Account: default Node: worker03/192.168.50.57 Start Time: Tue, 15 Aug 2023 20:20:33 +0900 Labels: run=helloworld Annotations: cni.projectcalico.org/containerID: a66975e225982ea92a8fe59c0ca4c236b5398dd24082cfc09183de086ac18bdf cni.projectcalico.org/podIP: cni.projectcalico.org/podIPs: Status: Succeeded IP: 192.168.133.131 IPs: IP: 192.168.133.131 Containers: helloworld: Container ID: containerd://e76445408b30c895860a2242b5bd51dfc1e31ad603293aba72b3b5e7ce81bd53 Image: hello-world:latest Image ID: docker.io/library/hello-world@sha256:dcba6daec718f547568c562956fa47e1b03673dd010fe6ee58ca806767031d1c Port: <none> Host Port: <none> State: Terminated Reason: Completed Exit Code: 0 Started: Tue, 15 Aug 2023 20:20:38 +0900 Finished: Tue, 15 Aug 2023 20:20:38 +0900 Ready: False Restart Count: 0 Environment: <none> Mounts: /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-bjvww (ro) Conditions: Type Status Initialized True Ready False ContainersReady False PodScheduled True Volumes: kube-api-access-bjvww: Type: Projected (a volume that contains injected data from multiple sources) TokenExpirationSeconds: 3607 ConfigMapName: kube-root-ca.crt ConfigMapOptional: <nil> DownwardAPI: true QoS Class: BestEffort Node-Selectors: <none> Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s node.kubernetes.io/unreachable:NoExecute op=Exists for 300s Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 3m54s default-scheduler Successfully assigned default/helloworld to worker03 Normal Pulling 15h kubelet Pulling image "hello-world:latest" Normal Pulled 15h kubelet Successfully pulled image "hello-world:latest" in 3.997028791s (3.9970352s including waiting) Normal Created 15h kubelet Created container helloworld Normal Started 15h kubelet Started container helloworld [tsubame@control-plane01 ~]$
コピペ用
helloworld
kubectl run --image hello-world:latest --restart Never helloworld kubectl get pods kubectl logs helloworld kubectl describe pods helloworld