k8s
-
Affinity : Pod를 원하는 Node에 띄우기Kubernetes 2023. 7. 22. 16:04
Affinity란 선호도란 뜻으로, Pod를 선호하는 Node에서 띄울 수 있게 하는 옵션이다. Affinity 종류 개요 nodeAffinity Pod를 배치할 때, 어떤 Node에 스케쥴링 할지 설정 한다. podAffinity Pod를 배치할 때, 실행 중인 Pod들 중에 선호하는 Pod를 찾아 해당 Pod와 동일한 Node로 배치하도록 설정한다. podAntiAffinity 실행 중인 Pod등 중에, 선호하지 않는 Pod가 실행중인 Node를 피해서 배치하도록 설정한다. nodeAffinity 옵션 **required**DuringScheduling**Ignored**DuringExecution 반드시 충족해야 하는 조건 (Hard) Label이 매칭 되는 Node에만 Pod 배포 가능 **pre..
-
Pod 에 root 권한 주는 법Kubernetes 2023. 7. 1. 17:04
Pod 에서 작업을 하다 보면 `Operation not permitted` 에러가 자주 발생 하는데 root 권한이 없어서 발생하는 것이다. securityContext: privileged: true pod를 올릴 때 securityContext 설정을 해주면 root 권한을 부여 받을 수 있다. 전체 pod yaml 예시 --- apiVersion: v1 kind: Pod metadata: name: csi-rbd-demo-pod spec: containers: - name: web-server image: nginx securityContext: privileged: true volumeMounts: - name: mypvc mountPath: /var/lib/www/html volumes: - ..
-
kubectl cp 명령어Kubernetes 2023. 7. 1. 17:02
kubectl cp 명령어는 local 과 Pod 간의 파일 복사를 수행한다. Pod 에서 Pod 로 복사는 불가능 하다. 명령어 형식 # kubectl cp : # kubectl cp : 예시 # kubectl cp localfile.txt :/data 혹은 # kubectl cp :/data/remotefile.txt /home/user 옵션 `kubectl cp` 명령어는 다음과 같은 옵션을 지원한다. `-c, --container`: 복사할 컨테이너 이름 지정 `--no-preserve`: 파일 소유권, 퍼미션 정보 등을 유지하지 않고 복사 `-p, --preserve`: 파일 소유권, 퍼미션 정보 등을 유지하고 복사 `-R, --recursive`: 디렉토리를 재귀적으로 복사 `-v, --ver..
-
Deployment와 StatefulSetKubernetes 2023. 7. 1. 16:55
대부분의 어플리케이션은 Deployment 또는 StatefulSet 으로 파드를 배포한다. StatefulSet은 stateful(상태가 있는) 서버 (정보 또는 데이터가 있는 서버) Deployment 는 stateless(상태가 없는) 서버 (정보 또는 데이터가 없는 서버) 쉽게 예를들면 콜센터의 상담원 A와 상담을 하던 중 전화가 끊겨서 다시 전화를 했더니, 상담원 B와 연결이 되었다. A가 본인 노트에만 상담내용을 기록했다면, B는 처음부터 다시 상담을 해야한다. 위의 예 처럼 각 파드가 데이터를 각자 가지고 있으면 다른 파드로 연결되었을 때 서비스에 문제가 발생한다. 하지만 독립적인 빌드/배포/스케일링을 위해서 컨테이너를 사용하는 건데 각 파드가 스테이트풀하게 고유의 데이터를 가지면 안된다. ..