・logs
kubectl logs
– pods
kubectl logs -n ${namespace} ${pod_name}
<output>
$ kubectl logs -n ingress-nginx ingress-nginx-controller-7657f6db5f-nbct8
-------------------------------------------------------------------------------
NGINX Ingress controller
Release: v1.12.0
Build: ba73b2c24d355f1cdcf4b31ef7c5574059f12118
Repository: https://github.com/kubernetes/ingress-nginx
nginx version: nginx/1.25.5
-------------------------------------------------------------------------------
– container (realtime)
kubectl logs -f ${pod_name} -c ${container_name}
<output>
$ kubectl logs -f echo-spring-bt95h -c echo
2025/01/11 12:02:55 start server
2025/01/11 12:02:55 image changed
・get
kubectl get
– nodes
kubectl get nodes -o wide
<output>
$ kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
minikube Ready control-plane 7h35m v1.31.0 192.168.49.2 <none>
– pod(yaml)
kubectl get pod my-first-pod -o yaml
<output>
% kubectl get pod my-first-pod -o yaml
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: "2025-01-14T02:38:49Z"
labels:
run: my-first-pod
name: my-first-pod
namespace: default
resourceVersion: "6929"
uid: e6751d3b-4cbf-4ef5-aae2-24ac28aec5a4
spec:
〜略〜
hostIP: 192.168.17.222
hostIPs:
- ip: 192.168.17.222
phase: Running
podIP: 192.168.14.65
podIPs:
- ip: 192.168.14.65
qosClass: BestEffort
startTime: "2025-01-14T02:38:49Z"
・exec
kubectl exec -it debug -- sh
<output>
$ kubectl exec -it debug -- sh
sh-4.2#
・replace
kubectl replace -f replicaset-demo.yml
<output>
% kubectl replace -f replicaset-demo.yml
・deployment
– rollout
kubectl rollout history deployment/my-first-deployment
<output>
% kubectl rollout history deployment/my-first-deployment
deployment.apps/my-first-deployment
REVISION CHANGE-CAUSE
1 <none>
2 kubectl set image deployment/my-first-deployment kubenginx=stacksimplify/kubenginx:2.0.0 --record=true
– edit
kubectl edit deployment/my-first-deployment --record=true
<output>
% kubectl edit deployment/my-first-deployment --record=true
Flag --record has been deprecated, --record will be removed in the future
deployment.apps/my-first-deployment edited