# 사용 중단된 API 사용 확인
kubectl get -l k8s-app!=kube-dns deployments --all-namespaces -o json | jq '.items[].spec.template.spec.containers[].image' | sort | uniq
# 사용 중단된 API 사용 확인
kubectl get $(kubectl api-resources --verbs=list -o name | paste -sd, -) \
--all-namespaces -o json | jq '.items[] | select(.apiVersion | contains("beta"))' | jq -r '.kind,.apiVersion,.metadata.name' | sort | uniq
# 노드 상태 확인
kubectl get nodes
# 파드 상태 확인
kubectl get pods --all-namespaces
# 컴포넌트 상태 확인
kubectl get componentstatuses
# 이벤트 확인
kubectl get events --all-namespaces
# AWS CLI를 사용한 상태 확인
aws eks describe-update \
--name my-cluster \
--update-id <update-id>
# eksctl을 사용한 상태 확인
eksctl get clusters
eksctl get nodegroup --cluster my-cluster
# 노드 상태 확인
kubectl get nodes
# 파드 상태 확인
kubectl get pods --all-namespaces
# 이벤트 확인
kubectl get events --all-namespaces --sort-by='.lastTimestamp'
# 기존 노드에 taint 적용
kubectl taint nodes -l alpha.eksctl.io/nodegroup-name=my-nodegroup-old \
node-group=old:NoSchedule
# 새 파드가 새 노드에 스케줄링되는지 확인
kubectl get pods -o wide
# 기존 노드 드레이닝
for node in $(kubectl get nodes -l alpha.eksctl.io/nodegroup-name=my-nodegroup-old -o name); do
kubectl drain --ignore-daemonsets --delete-emptydir-data $node
done
# 노드 목록 가져오기
NODES=$(kubectl get nodes -l alpha.eksctl.io/nodegroup-name=my-nodegroup -o name)
# 각 노드에 대해 드레이닝 및 종료 수행
for node in $NODES; do
echo "Draining node $node..."
kubectl drain --ignore-daemonsets --delete-emptydir-data $node
# 노드 ID 가져오기
INSTANCE_ID=$(aws ec2 describe-instances \
--filters "Name=private-dns-name,Values=$(echo $node | cut -d'/' -f2)" \
--query "Reservations[0].Instances[0].InstanceId" \
--output text)
# 노드 종료
aws ec2 terminate-instances --instance-ids $INSTANCE_ID
# 새 노드가 준비될 때까지 대기
echo "Waiting for new node to be ready..."
sleep 60
# 노드 상태 확인
kubectl get nodes
done
# 노드 목록 가져오기
NODES=$(kubectl get nodes -l alpha.eksctl.io/nodegroup-name=my-nodegroup -o name)
# 각 노드에 대해 인플레이스 업그레이드 수행
for node in $NODES; do
echo "Cordoning node $node..."
kubectl cordon $node
echo "Draining node $node..."
kubectl drain --ignore-daemonsets --delete-emptydir-data $node
# 노드에 SSH 접속하여 업그레이드 수행
# 이 부분은 노드 접근 방법에 따라 다를 수 있음
INSTANCE_ID=$(aws ec2 describe-instances \
--filters "Name=private-dns-name,Values=$(echo $node | cut -d'/' -f2)" \
--query "Reservations[0].Instances[0].InstanceId" \
--output text)
# SSM을 사용하여 명령 실행
aws ssm send-command \
--instance-ids $INSTANCE_ID \
--document-name "AWS-RunShellScript" \
--parameters commands=["sudo yum update -y kubelet kubectl"]
# 노드 uncordon
echo "Uncordoning node $node..."
kubectl uncordon $node
done
kubectl get nodes -o custom-columns=NAME:.metadata.name,VERSION:.status.nodeInfo.kubeletVersion
kubectl get nodes
kubectl describe nodes
kubectl get pods --all-namespaces -o wide
kubectl get pods --all-namespaces -o wide | grep -v Running
kubectl get events -n kube-system --sort-by='.lastTimestamp'
# 클러스터 버전 확인
kubectl version --short
# 노드 버전 확인
kubectl get nodes -o custom-columns=NAME:.metadata.name,VERSION:.status.nodeInfo.kubeletVersion
# 노드 상태 확인
kubectl get nodes
# 파드 상태 확인
kubectl get pods --all-namespaces
# 네임스페이스 상태 확인
kubectl get namespaces
# 서비스 상태 확인
kubectl get services --all-namespaces
# 배포 상태 확인
kubectl get deployments --all-namespaces
# 스테이트풀셋 상태 확인
kubectl get statefulsets --all-namespaces
# 데몬셋 상태 확인
kubectl get daemonsets --all-namespaces
# 서비스 엔드포인트 확인
kubectl get endpoints --all-namespaces
kubectl run nginx --image=nginx
kubectl get pod nginx
kubectl delete pod nginx
kubectl create deployment nginx --image=nginx --replicas=2
kubectl expose deployment nginx --port=80 --type=ClusterIP
kubectl get service nginx
kubectl delete service nginx
kubectl delete deployment nginx