728x90
반응형
# 해당 pod가 어느 node에 있는지 확인하기
kubectl get pod -o wide
ec2-user:~/environment/yaml $ kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
deploy-jenkins-7dcdf75b94-7zrjx 0/1 Pending 0 54m <none> <none> <none> <none>
deploy-jenkins-7dcdf75b94-gngq8 0/1 Pending 0 62m <none> <none> <none> <none>
deploy-jenkins-7dcdf75b94-hbr5l 0/1 Pending 0 58m <none> <none> <none> <none>
deploy-jenkins-7dcdf75b94-r2tq4 0/1 Pending 0 62m <none> <none> <none> <none>
deploy-jenkins-7dcdf75b94-t2j8f 0/1 Pending 0 61m <none> <none> <none> <none>
ec2-user:~/environment/yaml $
- 하나의 pod가 어느 노드에 있는지 확인하기
kubectl get pod deploy-jenkins-7dcdf75b94-7zrjx -o wide
kubectl get pod [#podname] -o wide
ec2-user:~/environment/yaml $ kubectl get pod deploy-jenkins-7dcdf75b94-7zrjx -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
deploy-jenkins-7dcdf75b94-7zrjx 0/1 Pending 0 59m <none> <none> <none> <none>
ec2-user:~/environment/yaml $
# edit 명령어를 사용하여 스케일 아웃 수행하기
#rs 조회
kubectl get rs
#rs 수정
kubectl edit rs rs-nginx
kubectl edit rs [#replicaset name]
- replicas 수를 변경하면 스케일 아웃과 스케일 인을 설정 할 수 있다.
spec:
replicas: 3
selector:
matchLabels:
app: rs-nginx
template:
metadata:
creationTimestamp: null
labels:
app: rs-nginx
# 모든 namespace에 있는 pod 조회하기
kubectl get pod --all-namespaces
# 특정 이름으로 정의된 namespace pod를 조회하기
kubectl get pods --namespace prometheus
kubectl get pods --namespace [#정의된namespace]
ec2-user:~/environment/grafana_prometheus $ kubectl get pods --namespace prometheus
NAME READY STATUS RESTARTS AGE
grafana-5d76d7b7b9-vq5w6 0/1 Pending 0 14m
prometheus-alertmanager-5d577c9bf4-bzfxr 0/2 Pending 0 26m
prometheus-kube-state-metrics-569d7854c4-2gcdh 0/1 Pending 0 15m
prometheus-node-exporter-4pdcn 0/1 Pending 0 15m
prometheus-node-exporter-jl8k6 0/1 Pending 0 26m
prometheus-node-exporter-tsvvp 0/1 Pending 0 13m
prometheus-pushgateway-6c5fd69fd6-wbl56 0/1 Pending 0 26m
prometheus-server-6c6f6669b6-m97cq 0/2 Pending 0 26m
ec2-user:~/environment/grafana_prometheus $
- 간혹 kebectl get pod로 조회가 되지 않는 경우가 있다. 아래처럼 말이다.
이럴때는 위에서 설명한 것과 같이 namespace를 따로 정의해서 조회를 해주면 된다.
ec2-user:~/environment/grafana_prometheus $ kubectl get pods
No resources found in default namespace.
# 기본 네임스페이스외 모든 네임스페이스 삭제하기
kubectl delete namespace --all
- 기본 디폴트 namespace만 제외하고 모든 namespace가 삭제된다.
ec2-user:~/environment $ kubectl delete namespace --all
namespace "kube-node-lease" deleted
namespace "prometheus" deleted
Error from server (Forbidden): namespaces "default" is forbidden: this namespace may not be deleted
Error from server (Forbidden): namespaces "kube-public" is forbidden: this namespace may not be deleted
Error from server (Forbidden): namespaces "kube-system" is forbidden: this namespace may not be deleted
ec2-user:~/environment $
# 특정 네임스페이스와 svc를 조회하기
ec2-user:~/environment/efk $ kubectl get pod,svc -n prometheus
NAME READY STATUS RESTARTS AGE
pod/grafana-76585bffbf-7q6pl 0/1 Init:0/1 0 45m
pod/prometheus-alertmanager-787f86875f-sbjsk 0/2 Pending 0 7h29m
pod/prometheus-kube-state-metrics-58c5cd6ddb-kcrb7 1/1 Running 0 45m
pod/prometheus-node-exporter-gtmnb 1/1 Running 0 42m
pod/prometheus-pushgateway-6bd6fcd9b8-68vzj 1/1 Running 0 45m
pod/prometheus-server-75897d656d-zk5gp 0/2 ContainerCreating 0 45m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/grafana LoadBalancer 10.100.235.83 a8233b01bf6b94e07bfe4847fe4f6349-198417945.ap-northeast-2.elb.amazonaws.com 80:30704/TCP 8h
service/prometheus-alertmanager ClusterIP 10.100.150.140 <none> 80/TCP 8h
service/prometheus-kube-state-metrics ClusterIP 10.100.189.191 <none> 8080/TCP 8h
service/prometheus-node-exporter ClusterIP None <none> 9100/TCP 8h
service/prometheus-pushgateway ClusterIP 10.100.234.8 <none> 9091/TCP 8h
service/prometheus-server ClusterIP 10.100.90.151 <none>
# 로그 확인
kubectl logs [NAME]
kubectl logs jenkins-7ffb988b7-jwnjw
# ALB 자격증명 확인
kubectl describe ingress nginx-ingress
kubectl describe deploy <aws-load-balancer-controller> -n kube-system | grep -i "Service Account"
kubectl get deployment -n kube-system aws-load-balancer-controller
kubectl describe deploy aws-load-balancer-controller -n kube-system | grep -i "Service Account"
kubectl describe sa aws-load-balancer-controller -n kube-system
kubectl describe ingress nginx-ingress
728x90
반응형
'⭐ Kubernetes & EKS > 명령어 모음' 카테고리의 다른 글
pod cpu 및 메모리 사용량 확인 (0) | 2022.08.11 |
---|---|
eks 클러스터 확인 (0) | 2022.07.25 |
쿠버네티스 주요 명령어 설명 (0) | 2021.10.07 |