목록kubernetes (18)
오늘도 한 뼘 더

# Helm 설치하기 Helm 다운로드 및 설치 $ curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 $ chmod 700 get_helm.sh $ ./get_helm.sh Helm 버전 확인하기 $ helm version

# 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}

# 배경 쿠버네티스 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. # 문제 해당 문제는 인스턴스에 만들 수 있..

# 배경 서비스를 Elastic Beanstalk에서 EKS로 변경을 하면서 모니터링을 위해 Prometheus와 Grafana를 설치한다 # docker-compose.yaml 작성 version: '3.7' services: # 설치하려는 컨테이너 목록 prometheus: network_mode: bridge image: prom/prometheus:latest container_name: prometheus user: root command: - '--web.enable-lifecycle' - '--config.file=/etc/prometheus/prometheus.yaml' volumes: - /monitor/prometheus/config:/etc/prometheus/ - /monitor/p..

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

# 배경 쿠버네티스의 CPU, Memory 등의 사용량 Metric을 보고 싶다. # 문제 metric을 보기 위해 다음 명령어를 입력하면 에러가 발생한다. > kubectl top nodes error: Metrics API not available # 원인 Metric-server가 없어서 발생하는 문제이다. metric-server 없이는 metric을 볼 수 없다. # 해결 방법 ## Metric-Server 설치 https://github.com/kubernetes-sigs/metrics-server GitHub - kubernetes-sigs/metrics-server: Scalable and efficient source of container resource metrics for Kuber..

Deployment (디플로이먼트) 레플리카셋과 포드의 배포를 관리 포드와 레플리카셋을 관리하기 때문에 deployment를 삭제하지 않고 pod을 삭제하면 pod은 삭제되지 않고 계속 생성된다. "--record" 명령어를 통해 revision이 가능하다. deployment-nginx.yaml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment spec: replicas: 3 selector: matchLabels: app: nginx-my template: metadata: name: nginx-pod labels: ngnix-my spec: containers: - name: nginx image: nginx:latest p..

Replica Set(레플리카셋) 일정 개수의 포드를 유지하는 컨트롤러 역할 노드 장애 등의 이유로 포드를 사용할 수 없다면 다른 노드에서 포드를 생성할 수 있도록 한다. yaml 파일에 여러 개의 리소를 만들도록 지정할 수 있으나 이는 포드 개수를 유지하는 방법은 아니다. 레플리카 셋 사용 전 apiVersion: v1 kind: Pod metadata: name: nginx-pod-a spec: containers: - name: nginx-container image: nginx:latest ports: - containerPort: 80 protocol: TCP --- apiVersion: v1 kind: Pod metadata: name: nginx-pod-b spec: containers: -..

Pod(포드) 1개 이상의 컨테이너로 구성된 컨테이너의 집합 1개 또는 그 이상의 컨테이너가 하나의 포드에 존재할 수 있다. pod 목록 확인하기 kubectl get pods pod 상세 내용 확인 kubectl describe pods pod yaml 예시 apiVersion: v1 kind: Pod metadata: name: nginx-pod spec: containers: - name: nginx-container image: nginx:latest ports: - containerPort: 80 protocol: TCP apiVersion : YAML 파일에서 정의한 오브젝트의 API 버전 정보 kind : 오브젝트 종류 metadata : 라벨, 주석, 이름 등과 같은 리소스의 부가 정보 s..