Kubernetes 27

쿠버네티스에서 디버그를 더 쉽게: kubectl alpha debug

kubectl alpha debug command Kubecon Europe 2020 세션에서 k8s new feature 설명을 듣다가 괜찮은 alpha 기능이 있어서 정리해본다. kubernetes를 쓰면서 어렵다고 느낀 점 중 하나는 디버깅이다. logs나 describe pod로 해당 pod의 상태/로그를 확인할 수 있고 exec로 pod에 실제 명령어를 실행시켜볼 수 있지만 어디까지나 해당 pod이 running중일 때의 얘기이고, pod 자체가 잘 뜨지 않거나 exec 명령어를 사용하기 힘든 상황일 경우에는 디버깅이 정말 어렵다. shell이나 디버깅 툴이 없는 컨테이너일 경우에도 마찬가지이다. kubectl alpha debug 기능은 이럴 경우 pod 안에 디버깅에 필요한 툴들을 포함시킨 ..

backend/kubernetes 2020.08.25

[kubernetes in action] 7. Configmaps and Secrets - 2

7.3. Setting environment variables for a container Kubernetes에서는 각각의 컨테이너에 환경변수를 지정해 줄 수 있다. 다만 아직 pod레벨에서 지정하는 방법은 없다. 환경변수로 위에서 만든 fortune image의 interval을 설정해보자. fortune-env/fortuneloop.sh #!/bin/bash trap "exit" SIGINT echo Configured to generate new fortune every $INTERVAL seconds mkdir -p /var/htdocs while : do echo $(date) Writing fortune to /var/htdocs/index.html /usr/games/fortune > /va..

DNS 서버 사용 이후 minikube에서 docker pull 안되는 문제 (`Error response from daemon: Get https://registry-1.docker.io/v2/: dial...: read: connection refused`)

DNS 서버 사용 이후 minikube에서 docker pull 안되는 문제 Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on 192.168.64.1:53: read udp 192.168.64.4:48733->192.168.64.1:53: read: connection refusedminikube를 잘 사용하고 있다가 cloudflared DNS over https를 사용한 이후로 minikube 안에서 docker pull이 안되는 문제가 발생했다. $ minikube ssh _ _ ( ) ( ) ___ ___ (_) ___ (_)| |/') _ _ | |..

backend/kubernetes 2020.06.17

[kubernetes in action] 7. Configmaps and Secrets - 1

7. ConfigMaps and Secrets configuring applications Changing the main process of a container Passing command-line options to the app Setting environment variables exposed to the app Configuring apps through ConfigMaps Passing sensitive information through Secrets 거의 모든 app이 configuration을 필요로 하고 이를 app 자체에 담을 수 없으므로 kubernetes에서 어떻게 configuration option을 넘겨줄 수 있음 7.1. Configuring containerized ap..

ReplicationController, ReplicaSet, Deployment 중 어떤것을 사용해야할까?

ReplicationController, ReplicaSet, Deployment 책을 읽으면서 ReplicationController, Replicaset, Deployment 등 비슷한 개념에 헷갈렸는데 문서에서 잘 정리되어 있어서 적어둔다. Basic pod 일반 pod. 따로 띄울 수는 있지만 권장하지 않는다. 어떤 이유로 application이 단일 파드가 필요하더라도 replicaset을 이용하는 것을 권장 ReplicationController, ReplicaSet 레플리카셋은 레플리케이션 컨트롤러를 계승하였다. 이 두 개의 용도는 동일하고, 유사하게 동작하며, 레플리케이션 컨트롤러가 레이블 사용자 가이드에 설명된 설정-기반의 셀렉터의 요건을 지원하지 않는다는 점을 제외하면 유사하다. 따라서..

backend/kubernetes 2020.06.13

[kubernetes docs] Replicaset, ReplicationController, Deployment

Container Replicasets 레플리카셋의 목적은 레플리카 파드 집합의 실행을 항상 안정적으로 유지하는 것이다. 이처럼 레플리카셋은 보통 명시된 동일 파드 개수에 대한 가용성을 보증하는데 사용 레플리카셋의 작동 방식 레플리카셋을 정의하는 필드 selector: 획득 가능한 pod를 식별 replica의 개수: 유지해야 하는 pod 개수 pod template: 신규 pod에 대한 데이터 명시 레플리카셋을 사용하는 시기 레플리카셋은 지정된 수의 파드 레플리카가 항상 실행되도록 보장한다. 그러나 디플로이먼트는 레플리카셋을 관리하고 다른 유용한 기능과 함께 파드에 대한 선언적 업데이트를 제공하는 상위 개념이다. 따라서 우리는 사용자 지정 오케스트레이션이 필요하거나 업데이트가 전혀 필요하지 않은 경우라..

[kubernetes in action] 6. Volumes: attaching disk storage to containers

Chapter 6. Volumes: attaching disk storage to containers Creating multi-container pods Creating a volume to share disk storage between containers Using a Git repository inside a pod Attaching persistent storage such as a GCE Persistent Disk to pods Using pre-provisioned persistent storage Dynamic provisioning of persistent storage 6.1. INTRODUCING VOLUMES 6.2. Usnig volumes to share data between..

[kubernetes in action] 5.6. Using a headless service for discovering individual pods

5.6. Using a headless service for discovering individual pods 지금까지는 service가 stable IP 주소를 제공하고, client가 endpoint를 통해서 랜덤으로 선택된 pod에 접근할 수 있는 것을 보았다. 하지만 만약 클라이언트가 모든 pod에 접근하고 싶다면? kubernetes는 이런 상황에 DNS lookup을 통해 pod IP들을 모두 알 수 있다. (clusterIP 필드를 None으로) Creating a headless service service의 spec에서 clusterIp 필드를 None으로 만들면 서비스를 headless로 만들고, kubernetes는 클라이언트가 pod에 붙을 수 없도록 cluster IP를 부여하지 ..

[kubernetes in action] 5.5. Signaling when a pod is ready to accept connections

5.5. Signaling when a pod is ready to accept connections Introducing readiness probes container의 readiness probe가 성공하면 해당 컨테이너는 request를 받을 준비가 된 것 liveness probe와는 다르게 readiness가 실패해도 pod가 제거되거나 다시 시작되지는 않는다. Adding a readiness probe to a pod $ kubectl edit rc kubiaAdd spec.template.spec.containers. in kubia-rc-readnessprobe.yaml apiVersion: v1 kind: ReplicationController metadata: name: kubia ..

[kubernetes in action] 5.4 Exposing services externally through an Ingress resource

5.4 Exposing services externally through an Ingress resource Ingress (noun)—The act of going in or entering; the right to enter; a means or place of entering; entryway. Understanding why Ingresses are needed LoadBalancer service는 각각의 load balancer마다 각자의 IP 주소가 있어야 하지만, Ingress는 여러 서비스에 한개의 IP 주소만 필요하다. client가 HTTP 요청을 Ingress에게 보내면 request의 host와 path로 어떤 서비스로 포워딩할지를 결정한다. Understanding that an..