Skip to content

Instantly share code, notes, and snippets.

@geunho
Last active April 3, 2020 01:45
Show Gist options
  • Save geunho/c5d25c9809ab5cca8650768f96271e71 to your computer and use it in GitHub Desktop.
Save geunho/c5d25c9809ab5cca8650768f96271e71 to your computer and use it in GitHub Desktop.
Kubernetes 유용한 명령어 모음 ⌨️

생성 시간 순으로 모든 이벤트 조회

kubectl get events --all-namespaces  --sort-by='.metadata.creationTimestamp'
NAMESPACE   LAST SEEN   TYPE      REASON              OBJECT                                        MESSAGE
default     59m         Warning   FailedMount         pod/kafka-connect-history-744c4cb5f9-br66z    MountVolume.SetUp failed for volume "config-file" : configmap "kafka-connect-history-default-config" not found
default     54m         Warning   FailedMount         pod/kafka-connect-history-744c4cb5f9-br66z    Unable to mount volumes for pod "kafka-connect-history-744c4cb5f9-br66z_default(38034b71-8a92-42ed-9afd-b3894f79bc56)": timeout expired waiting for volumes to attach or mount for pod "default"/"kafka-connect-history-744c4cb5f9-br66z". list of unmounted volumes=[nubes ep-volume timezone config-file default-token-zgztl]. list of unattached volumes=[nubes ep-volume timezone config-file default-token-zgztl]
default     46m         Normal    ScalingReplicaSet   deployment/kafka-connect-history              Scaled up replica set kafka-connect-history-744c4cb5f9 to 1
default     46m         Normal    Scheduled           pod/kafka-connect-history-744c4cb5f9-rs7kt    Successfully assigned default/kafka-connect-history-744c4cb5f9-rs7kt to docker-desktop
default     46m         Normal    SuccessfulCreate    replicaset/kafka-connect-history-744c4cb5f9   Created pod: kafka-connect-history-744c4cb5f9-rs7kt
default     44

불필요한 pod 일괄 삭제

# 이름에 history가 포함된 pod 중 상태가 Init:Error인 것을 골라내고 pod 이름만 가져온 후 일괄 삭제한다.
kubectl get pods | grep history | grep Init:Error | awk '{print $1}' | xargs kubectl delete pod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment