목록DevOps & Infra/K8S(Kubernetes) (35)
오늘도 한 뼘 더

# Label Node, Pod, Deployment 등의 모든 리소스에 할당한다. 리소스를 분류하고 Selector를 사용하여 선택한다. 키-값 쌍으로 적용된다. # Label 할당 한 노드에 test=ok라는 label을 할당한다 kubectl --context=test label node {node name} test=ok # Label 조회 노드에 할당되어 있는 Label 조회하기 kubectl --context=test get nodes --show-lables # Label 삭제 label 이름에 '-'을 붙여주면 된다. kubectl --context=staging label nodes {node name} test-

# 배경 새벽 사이에 pod이 restart 되어 있는 것을 확인했다. 어느 시점에 restart 되어 있는지 확인하기 위해서 이전 로그를 확인하고자 했다. # 방법 kubectl logs 에는 '--previous' 옵션이 있다. pod의 이름이 변경되지 않았다면 --previous 옵션을 사용하여 바로 직전의 로그 내용을 확인할 수 있다. kubectl logs --previous {pod name}

# 배경 EKS 서비스에 만들어둔 클러스터를 aws cli를 사용하여 삭제하는 과정에서 다음과 같은 경고가 발생하면서 삭제가 진행되지 않는 현상이 발생하였다. pods are unevictable from node xxxxxxx # 문제 pod의 수가 replica의 수만큼 유지되야하는데 node를 삭제하면서 pod의 수가 최소 갯수를 만족하지 못하면서 node삭제가 block되고 그 결과 cluster 삭제가 불가해졌다. # 해결 방법 pod의 replica를 무시하고 진행할 수 있도록 옵션을 줘서 진행한다. kubectl drain {NodeName} --ignore-daemonsets --delete-emptydir-data

Ingress(인그레스) Ingress 하나로 URL 엔드포인트 하나만 생성하여 외부로 Pod을 외부로 노출하는 것이 가능 외부 요청에 대한 처리 규칙을 한 곳에서 처리 가능 [ Ingress.yaml 예시 ] apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: test-ingress annotations: alb.ingress.kubernetes.io/scheme: internal alb.ingress.kubernetes.io/listen-ports: '[{"HTTP":80,"HTTPS": 443}]' #alb.ingress.kubernetes.io/target-type: ip spec: ingressClassName: alb rules: -..

Service (서비스) Pod을 연결하고 외부에 노출하는 역할 docker를 실행시킬 때 port를 설정하는 -p 옵션과 같은 역할 여러 개의 Pod에 접근할 때, 요청을 분산하는 로드 밸런서 기능을 수행 [ Service.yaml 예시 ] apiVersion: v1 kind: Service metadata: name: svc-test-service labels: app: test-service spec: selector: app: app-test-service type: NodePort ports: - protocol: TCP port: 80 targetPort: 8000

# 배경 쿠버네티스 Pod을 올리는 과정에서 새로 올라간 Pod이 Pending이 나면서 올라가지 않았다. 자세한 내용을 확인해 본 결과 다음과 같은 에러 메시지를 확인하였다. kubectl describe pod {pod} Type Reason Age From Message ---- ------ ---- ---- ------- Warning FailedScheduling 3s (x2 over 5m26s) default-scheduler 0/1 nodes are available: 1 Too many pods. preemption: 0/1 nodes are available: 1 No preemption victims found for incoming pod. # 문제 해당 문제는 인스턴스에 만들 수 있..

# 배경 helm 차트를 사용하여 패키지를 추가하는 과정에서 다음과 같은 경고 메시지가 떴다. WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /home/.kube/config 보안상의 문제가 있는 건지 궁금해서 찾아보게 되었다. # 문제 해당 메시지가 떴던 이유는 config에 설정된 권한 때문이었다. 현재 권한이 제삼자도 읽기 권한을 가지고 있어 위와 같은 경고 메시지가 뜬 것이었다. # 해결 방법 위 문제는 무시해도 큰 문제는 없다고 했는데, 이런 경고 메시지를 받지 않기 위해서는 해당 파일의 권한을 다음과 같이 변경하면 된다. chmod 600 /home/.kube/config

# 배경 kubectl 명령어를 사용하려고 kubectl을 설치하다가 다음과 같은 에러가 발생했다. $ kubectl version error: exec plugin: invalid apiVersion "client.authentication.k8s.io/v1alpha1" 이전에 해당 문제를 경험한 적이 있었는데 eks와 kubectl의 버전이 많이 차이가 나면 이와 같은 에러가 발생할 수 있다고 한다. 그래서 버전을 내리면 된다는 것을 알게 되었다. [k8s] error: exec plugin: invalid apiVersion "client.authentication.k8s.io/v1alpha1" # 문제 내용 eks로 만든 cluster를 kubectl을 통해서 접근하려고 하니 다음과 같은 에러가 ..

# 배경 AWS EKS Cluster를 생성한 사용자 외의 다른 사용자가 cluster 및 리소스들을 접근할 수 있도록 권한을 부여하고 싶다. # 문제 aws configure 다른 사용자를 설정하고 kubectl 명령어를 입력하면 다음과 같은 에러가 발생한다. $ kubectl get pods > error: You must be logged in to the server (Unauthorized) 설정한 사용자에게 eks에 대한 권한이 없기에 발생하는 문제이다. # 해결방법 EKS Cluster 구성에 있는 configmap의 aws-auth에 해당 사용자를 매핑시켜주어야 한다. $ kubectl edit configmap -n kube-system aws-auth 위 명령어를 통해서 configma..

# 문제 내용 eks로 만든 cluster를 kubectl을 통해서 접근하려고 하니 다음과 같은 에러가 발생 > kubectl get pods error: exec plugin: invalid apiVersion "client.authentication.k8s.io/v1alpha1" # 원인 kubectl 12.4.x 이상의 버전에서 eks와 연동해서 사용할 경우 발생하는 오류라고 한다. https://github.com/aws/aws-cli/issues/6920 aws eks update-kubeconfig invalid apiVersion · Issue #6920 · aws/aws-cli Describe the bug Update kubectl from v1.23.6 to 1.24.0 and run ..