1
k get pod -o=wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx-project-59d59f75c4-wnnbd 1/1 Running 0 16m 192.168.1.187 ip-192-168-1-11.ap-northeast-2.compute.internal <none> <none>
2
k get pods
NAME READY STATUS RESTARTS AGE
nginx-project-59d59f75c4-wnnbd 1/1 Running 0 25m
k describe pod nginx-project-59d59f75c4-wnnbd
Name: nginx-project-59d59f75c4-wnnbd
Namespace: default
Priority: 0
Service Account: default
Node: ip-192-168-1-11.ap-northeast-2.compute.internal/192.168.1.11
Start Time: Tue, 26 Dec 2023 12:27:12 +0900
Labels: app=nginx-project
pod-template-hash=59d59f75c4
Annotations: <none>
Status: Running
IP: 192.168.1.187
IPs:
IP: 192.168.1.187
3
kubectl get pods -o jsonpath='{.items[*].spec.containers[*].image}'
nginx
챰고 사이트
https://kubernetes.io/ko/docs/tasks/configure-pod-container/assign-pods-nodes/
kubectl get pods -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.startTime}{"\n"}
{end}'
참고 서적
15단계로 배우는 도커와 쿠버네티스 - 97페이지
1
kubectl create deployment nginx-project --image=nginx --dry-run=client -o yaml --port=80 > nginx-deploy.yaml
kubectl apply -f nginx-deploy.yaml
more nginx-deploy.yaml
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: nginx-project
name: nginx-project
spec:
replicas: 1
selector:
matchLabels:
app: nginx-project
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: nginx-project
spec:
containers:
- image: nginx
name: nginx
ports:
- containerPort: 80
resources: {}
status: {}
k get pods
NAME READY STATUS RESTARTS AGE
nginx-project-59d59f75c4-wnnbd 1/1 Running 0 28h
2
kubectl get pods -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.startTime}{"\n"}
{end}'
nginx-project-59d59f75c4-wnnbd 2023-12-26T03:27:12Z
kubectl get pods -o=jsonpath='{.items[0].metadata.name}'
kubectl get pods -o=jsonpath="{.items[*]['metadata.name', 'status.capacity']}"
kubectl get pods <pod-name> -o custom-columns=NAME:.metadata.name,RSRC:.metadata.resourceVersion
kubectl get pods <pod-name> -o custom-columns-file=template.txt
https://kubernetes.io/docs/reference/kubectl/#output-options
kubectl rollout history deployment deployment-nginx
참고
https://brunch.co.kr/@topasvga/1674
1
cat <<EOT > my-job.yaml
apiVersion: batch/v1
kind: Job
metadata:
name: my-job
spec:
template:
spec:
containers:
- name: my-job
image: busybox
command: ["echo", "Hello World!"]
restartPolicy: Never
backoffLimit: 4
EOT
kubectl apply -f my-job.yaml
2
또는
# kubectl create 로도 가능
kubectl create job my-job --image=busybox -- echo "Hello World!"
3
kubectl get jobs
NAME COMPLETIONS DURATION AGE
my-job 1/1 5s 17s
4
kubectl delete job my-job
PV 목록을 가져오고 크기별로 정렬해보자
kubectl get pv --sort-by=.spec.capacity.storage
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
efs-pv 5Gi RWO Retain Available 33h
task-pv-volume 10Gi RWO Retain Available manual 32h
kubectl get pv --help
network-policy-default-deny-ingress.yaml
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny-ingress
spec:
podSelector: {}
policyTypes:
- Ingress
참고 사이트
https://kubernetes.io/docs/concepts/services-networking/network-policies/
kubectl get configmap,secrets --all-namespaces
kubectl get configmap,secrets -A
kubectl get pods -o=jsonpath="{.items[*]['metadata.name', 'metadata.namespace']}"
https://brunch.co.kr/@topasvga/1656
감사합니다.