728x90

Kubernetes 20

kubernetes pod 기동 시 오류(networkPlugin cni failed to teardown pod)

kubernetes 설치 후 pod를 기동하면 아래 오류가 발생하는 경우가 있다. network for pod "coredns-74ff55c5b-prb74": networkPlugin cni failed to set up pod "coredns-74ff55c5b-prb74_kube-system" network: error getting ClusterInformation: Get "https://[10.96.0.1]:443/apis/crd.projectcalico.org/v1/clusterinformations/default": x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" ..

Kubernetes 2023.08.16

kubernetes 인증서 갱신하는 방법

어느 날 갑자기 kubectl 명령어를 사용했는데 아래 오류가 발생했다. error: You must be logged in to the server (Unauthorized) 만약 작업한 게 없다면 인증서 유효기간 1년이 지났을 가능성이 크다. 먼저 인증서 유효기간을 확인한다. kubeadm certs check-expiration 추가적으로 해당 경로 (/etc/kubernetes/pki) 인증서를 확인해 보면 아마 유효기간 1년이 지났을 것이다. 이런 경우 마스터 노드에서 인증서를 갱신해 주면 된다. kubeadm certs renew all 명령어 실행 후 해당 경로(/etc/kubernetes)에 바뀐 conf파일 확인 admin.conf 파일을 ~/.kube/config로 복사한뒤 kubect..

pod <-> local 파일 업/다운로드

1. local -> pod 파일 업로드 kubectl cp {file_name} {pod_name}:{path} ex) kubectl cp fileupload.txt test-deployment-112121-sdfwe:/app/fileupload.txt 2. pod -> local 파일 다운로드 kubectl cp {pod_name}:{file-path} {local-path} ex) kubectl cp test-deployment-121212-dsfdfd:/app/fileupload.txt /home/user/fileupload.txt "tar: Removing leading `/' from member names" 문구가 뜨지만 해당 메시지는 에러가 아니고 알림 메시지다. 압축할 파일의 경로에서 t..

Kubernetes/pod 2023.07.27

Amazon EKS, 네트워킹 추가 기능 upgrade

1. coredns upgrade #백업 kubectl get deployment coredns -n kube-system -o yaml > aws-k8s-coredns-old.yaml => 해당 백업파일을 apply 시키면 원복이 가능하다. #업그레이드 방법 kubectl set image deployment.apps/coredns -n kube-system coredns=602401143452.dkr.ecr.{region}.amazonaws.com/eks/coredns:{version} => 같은 방법이지만 edit deployment에서 image 부분만 바꿔도 업그레이드 가능하다. #버전 확인 kubectl describe deployment coredns -n kube-system | grep ..

Command probe 적용하기

이전 포스팅에서 Probe를 체크하는 방법이 3가지가 있었는데 그중 Command로 Probe를 체크하는 방법에 대해서 포스팅을 진행해 봤다. Command probe 성공 : Command 실행 후 결괏값이 0이면 정상 실패 : Command 실행 후 결과값이 0이 아니면 실패 readinessProbe or livenessProbe 적용 readinessProbe: exec: command: - /test/probe/probe.sh test shell 파일 생성 후 테스트 - 권한이 없는 경우 chmod 777을 통해 권한 추가 필요 #!/bin/bash exit 0 소켓 or 스레드 개수를 확인 후 true / false 체크 #!/bin/bash #소켓 결과 RESULT=$(ls /proc/1/f..

Kubernetes 2023.05.31

Pod Lifecycle(readiness,liveness Probe)

kubelet이 각 컨테이너의 상태를 특정 조건으로 주기적으로 체크한 뒤 문제가 있는 pod를 자동으로 재시작하거나 문제가 있는 pod를 서비스에서 제외해서 네트워크 유입을 막을 수 있다. 해당 기능을 probe 구성이라고 한다. probe를 사용하는 방법은 간단하게 2가지가 있다. 1. readinessProbe - 프로브 수행 후 실패하는 경우 pod가 재시작되지 않고 해당 pod를 서비스에서 제외시켜 네트워크 유입을 막는다. 2. livenessProbe - 프로브 수행 후 실패하는 경우 pod가 재기동된다. Probe를 체크하는 방법 1. HTTP probe 성공: get 요청을 보내서 return이 200~300 사이면 정상 실패: 그 외의 값이 return 되는 경우는 비정상 readiness..

Kubernetes 2023.05.30

EBS CSI Driver 설치 방법

1. IAM 역할 생성1. 해당 EKS의 정보확인 aws eks describe-cluster \ --name {cluster_name} \ --query "cluster.identity.oidc.issuer" \ --output text output 값 = > https://oidc.eks.{region}.amazonaws.com/id/{key} 2. json 파일 생성 { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Federated": "arn:aws:iam::{ID}:oidc-provider/oidc.eks.{region}.amazonaws.com/id/{key}" }, "Action": "sts:Assu..

AWS EKS Kubernetes 버전 1.22 to 1.23 upgrade

EKS Kubernetes 버전 업그레이드(1.22 to 1.23)를 진행하기 전 필요한 드라이버가 있는지 수정되는 정책이 있는지 등 확인이 필요하다. 1.22 -> 1.23 으로 업그레이드 시 설치 및 업그레이드 가능한 사항 1. Amazon EBS CSI 드라이버 설치(EBS 볼륨을 사용한다면 필수 설치) : EBS 볼륨을 사용하는 경우 필수 설치 2. CNI Driver 최신 버전 업그레이드 : v1.12.6-eksbuild.1 3. kube-proxy 최신 버전 업그레이드 : v1.23.16-eksbuild.2 4. CoreDNS 최신 버전 업그레이드 : v1.8.7-eksbuild.4 2~4번 네트워크 관련 모듈들 업그레이드는 필수가 아니지만 최신버전을 항상 올려주는게 좋은 것 같다. 아래 표는..

podAntiAffinity 정책

파드간 affinity 사용(podAntiAffinity) - affinity는 Pod를 특정 Node에 배포되도록 하는 정책이다 1. Hard affinity - 규칙이 만족되는 경우만 파드가 기동된다. #requiredDuringSchedulingIgnoredDuringExecution: 규칙이 만족되지 않으면 스케줄러가 파드를 스케줄링할 수 없다. 이 기능은 nodeSelector와 유사하지만, 좀 더 표현적인 문법을 제공한다. ex) 만약 node가 4개 인데 pod replicas가 5개면 pod 4개는 running이지만 pod 1개는 affinity 정책에 걸려 pending 상태로 남아있다. affinity: podAntiAffinity: requiredDuringSchedulingIgno..

Kubernetes 2023.05.24

Pod Resource 관리(cpu, mem limits)

resources 요청 및 제한 적용 - requests: 처음 pod를 실행할 때 필요한 최소 자원 - limits : cpu, mem 등의 제한 사용량 아래 코드를 보면 pod가 실행될때의 최소 사용량은 request이고 최대 사용량은 limits다. resources: requests: memory: "10Mi" cpu: "10m" limits: memory: "50Mi" cpu: "50m" 그럼 limits을 설정하고 그 이상 자원을 사용하면 어떻게 되는지 확인해 보자. 1. CPU limit을 사용하는 경우 - limits 조건 : request : 10m // limit : 50m resources: requests: cpu: "10m" limits: cpu: "50m" 아무리 부하를 줘도 C..

Kubernetes 2023.05.22
728x90