Skip to main content

3 posts tagged with "k8s"

View All Tags

네트워크 정책을 통한 Google Kubernetes Engine(GKE)에서 송수신 트래픽 제어

· 14 min read

image

Google Kubernetes Engine(GKE)에서는 컨테이너화된 애플리케이션을 보호하기 위해 포드 간 보안 통신을 유지하는 것이 중요합니다. 네트워크 정책은 클러스터 내 트래픽 흐름에 대한 세부적인 제어를 설정하여 이러한 목표를 달성할 수 있는 강력한 도구를 제공합니다.

다음은 GKE에서 네트워크 정책을 사용하여 인그레스 및 이그레스 트래픽을 제어하는 ​​방법을 간략하게 소개합니다.

1. 개념 이해:

  • 수신: 외부 서비스, 클러스터 내의 다른 포드 또는 로드 밸런서를 포함하여 다양한 소스에서 포드로 전달되는 수신 네트워크 트래픽을 나타냅니다.
  • 송신: 일반적으로 데이터베이스, API 또는 컨테이너 레지스트리와 같은 외부 서비스로 향하는 포드에서 발생하는 나가는 네트워크 트래픽을 나타냅니다.

2. 네트워크 정책 구현:

네트워크 정책은 GKE 클러스터 내의 YAML 리소스로 정의됩니다. 그들은 다음을 지정합니다:

  • 대상 포드: 라벨 또는 네임스페이스로 식별되어 정책이 적용되는 포드를 결정합니다.
  • 트래픽 유형: 정책이 수신, 송신 또는 둘 다를 관리하는지 여부입니다.
  • 허용된 트래픽: 대상 Pod와 통신하도록 허용된 소스 또는 대상 Pod, IP 주소 또는 서비스 계정을 지정하여 정의됩니다.

3. 네트워크 정책의 이점:

  • 보안 강화: 네트워크 정책은 무단 트래픽을 제한함으로써 클러스터 내 데이터 침해 및 무단 액세스 위험을 완화합니다.
  • 최소 권한 원칙: 세분화된 액세스 제어를 시행하여 포드가 올바르게 작동하는 데 필요한 네트워크 액세스만 갖도록 보장할 수 있습니다.
  • 향상된 네트워크 가시성: 네트워크 정책은 허용된 통신 경로에 대한 명확한 이해를 제공하여 문제 해결 및 보안 감사를 용이하게 합니다.

본질적으로 네트워크 정책은 GKE 클러스터 내에서 보안 체크포인트 역할을 하여 데이터 흐름을 규제하고 잠재적인 보안 위협으로부터 애플리케이션을 보호합니다.

구현 세부정보

이 개념 증명에서는 네임스페이스 생성에 대한 초기 단계와 해당 네임스페이스 내의 세 가지 배포를 통해 Kubernetes 환경에 대한 구성 및 설정 세부 정보를 간략하게 설명합니다.

1. 네임스페이스 생성:

Kubernetes 클러스터 내의 리소스를 격리하고 구성하기 위해 "sample"이라는 네임스페이스가 생성되었습니다.

2. 배포 개요:

세 개의 배포가 "sample" 네임스페이스 내에 설정되었으며 각각 이름은 다음과 같습니다.

  • "sample-app-1"
  • "sample-app-2"
  • "sample-app-3"

3. 이미지 선택:

배포에서는 컨테이너화를 위해 'gcloud-slim' Docker 이미지를 활용합니다. 이 이미지는 리소스 효율성 및 최적화에 대한 특정 요구 사항을 충족하기 위해 선택되었습니다.

4. YAML 파일:

sample-app-1, 2, 3의 배포 YAML은 아래와 같습니다.

apiVersion: apps/v1
kind: Deployment
metadata:
name: sample-app-1
namespace: sample
spec:
replicas: 1
selector:
matchLabels:
app: sample-app-1
template:
metadata:
labels:
app: sample-app-1
spec:
containers:
- image: google/cloud-sdk:slim
name: gcloud-test-app
command: ["sleep", "infinity"]

---

apiVersion: apps/v1
kind: Deployment
metadata:
name: sample-app-2
namespace: sample
spec:
replicas: 1
selector:
matchLabels:
app: sample-app-2
template:
metadata:
labels:
app: sample-app-2
spec:
containers:
- image: google/cloud-sdk:slim
name: gcloud-test-app
command: ["sleep", "infinity"]

---

apiVersion: apps/v1
kind: Deployment
metadata:
name: sample-app-3
namespace: sample
spec:
replicas: 1
selector:
matchLabels:
app: sample-app-3
template:
metadata:
labels:
app: sample-app-3
spec:
containers:
- image: google/cloud-sdk:slim
name: gcloud-test-app
command: ["sleep", "infinity"]

네트워크 정책은 YAML 매니페스트를 사용하여 설정되었으며 "샘플" 네임스페이스 내에서 통신 권한을 구성합니다. 특히 "sample-app-1"은 "sample-app-2"와, "sample-app-2"는 "sample-app-3"과 양방향으로 통신할 수 있으며 그 반대의 경우도 마찬가지입니다. 그러나 “sample-app-3”에서 “sample-app-1”로의 통신은 정의된 정책에 따라 제한됩니다. 설명된 설정은 제어되고 선택적인 포드 간 통신을 보장합니다.

그래픽적으로 다음과 같이 나타낼 수 있습니다.

그림 1: 기술 아키텍처 | 네트워크 정책의 도식적 표현

image

네트워크 정책 YAML 파일:

우리는 네트워크 정책을 사용하여 시행되는 클러스터 내 트래픽을 제어하기 위해 특정 수신 및 송신 정책을 적용했습니다. 외부 트래픽의 경우 Istio 서비스 항목을 사용하고 있습니다.

수신 허용 트래픽:

  • GCP 외부 HTTPS 부하 분산기 상태 확인 IP 범위는 포트 80,443에서만 130.211.0.0/22, 35.191.0.0/16입니다.
  • 포트 80 및 443에서만 샘플 네임스페이스의 샘플-앱-2 배포에서.
  • 모든 포트의 kube-system 및 istio-system 네임스페이스 배포에서.

송신 허용 트래픽:

  • GCP의 메타데이터 서버 — 포트 988의 169.254.169.252/32 및 포트 80의 169.254.169.254/32
  • 포트 80 및 443의 네임스페이스 샘플에 샘플-앱-2를 배포합니다.
  • 모든 포트의 kube-system 및 istio-system 네임스페이스에 배포됩니다.

그림 2: 기술 아키텍처 | sample-app-1에 대한 네트워크 정책의 그래픽 표현

image

sampl-app-1의 네트워크 정책 yaml은 아래와 같습니다.

## For sample-app1, below network polciy yaml is applied

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: sample-app-1-nw-policy
namespace: sample
spec:
podSelector:
matchLabels:
app: sample-app-1
policyTypes:
- Ingress
- Egress
ingress:
- from:
- podSelector:
matchLabels:
app: sample-app-2
ports:
- port: 80
- port: 443
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: kube-system
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: istio-system
- from:
- ipBlock:
cidr: 130.211.0.0/22
ports:
- port: 80
- port: 443
- from:
- ipBlock:
cidr: 35.191.0.0/16
ports:
- port: 80
- port: 443
egress:
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: istio-system
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: kube-system
- to:
- podSelector:
matchLabels:
app: sample-app-2
ports:
- port: 80
- port: 443
- to:
- ipBlock:
cidr: 169.254.169.254/32
ports:
- port: 80
- to:
- ipBlock:
cidr: 169.254.169.252/32
ports:
- port: 988

확인

  1. 아래 명령을 사용하여 세 개의 포드 모두에 실행합니다.
kubectl exec -it <pod-name> -n sample -- bash

Sample output:

kubectl get pods -n sample
NAME READY STATUS RESTARTS AGE
sample-app-1-7f4c69bc85-wr5mq 1/1 Running 0 39s
sample-app-2-59dfd44fcd-pwpct 1/1 Running 0 32s
sample-app-3-5c8f7c9d4c-zs2p2 1/1 Running 0 26s

root@ganesh-instance-02:~/policies/sample# kubectl exec -it sample-app-1-7f4c69bc85-wr5mq -n sample -- bash

2. 세 포드 모두에 nginx, 컬, 핑 및 기타 유틸리티를 설치합니다.

apt install dnsutils
apt install net-tools
apt install iputils-ping
apt install nginx
service nginx start

sample output:


root@sample-app-1-7f4c69bc85-wr5mq:/# apt install dnsutils
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
bind9-dnsutils bind9-host bind9-libs libfstrm0 libicu72 libjemalloc2 libjson-c5 liblmdb0 libmaxminddb0 libprotobuf-c1 libuv1 libxml2
Suggested packages:
mmdb-bin
The following NEW packages will be installed:
bind9-dnsutils bind9-host bind9-libs dnsutils libfstrm0 libicu72 libjemalloc2 libjson-c5 liblmdb0 libmaxminddb0 libprotobuf-c1 libuv1 libxml2
0 upgraded, 13 newly installed, 0 to remove and 0 not upgraded.
Need to get 13.0 MB of archives.
After this operation, 45.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y


root@sample-app-1-7f4c69bc85-wr5mq:/# apt install net-tools
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
net-tools
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 243 kB of archives.
After this operation, 1001 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bookworm/main amd64 net-tools amd64 2.10-0.1 [243 kB]
Fetched 243 kB in 0s (1259 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package net-tools.
(Reading database ... 61295 files and directories currently installed.)
Preparing to unpack .../net-tools_2.10-0.1_amd64.deb ...
Unpacking net-tools (2.10-0.1) ...
Setting up net-tools (2.10-0.1) ...


root@sample-app-1-7f4c69bc85-wr5mq:/# apt install iputils-ping
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
libcap2-bin libpam-cap
The following NEW packages will be installed:
iputils-ping libcap2-bin libpam-cap
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 96.2 kB of archives.
After this operation, 311 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://deb.debian.org/debian bookworm/main amd64 libcap2-bin amd64 1:2.66-4 [34.7 kB]
Get:2 http://deb.debian.org/debian bookworm/main amd64 iputils-ping amd64 3:20221126-1 [47.1 kB]
Get:3 http://deb.debian.org/debian bookworm/main amd64 libpam-cap amd64 1:2.66-4 [14.5 kB]
Fetched 96.2 kB in 0s (340 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libcap2-bin.
(Reading database ... 61350 files and directories currently installed.)
Preparing to unpack .../libcap2-bin_1%3a2.66-4_amd64.deb ...
Unpacking libcap2-bin (1:2.66-4) ...
Selecting previously unselected package iputils-ping.
Preparing to unpack .../iputils-ping_3%3a20221126-1_amd64.deb ...
Unpacking iputils-ping (3:20221126-1) ...
Selecting previously unselected package libpam-cap:amd64.
Preparing to unpack .../libpam-cap_1%3a2.66-4_amd64.deb ...
Unpacking libpam-cap:amd64 (1:2.66-4) ...
Setting up libcap2-bin (1:2.66-4) ...
Setting up libpam-cap:amd64 (1:2.66-4) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline
Setting up iputils-ping (3:20221126-1) ...


root@sample-app-1-7f4c69bc85-wr5mq:/# apt install nginx
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
iproute2 libatm1 libbpf1 libelf1 libmnl0 libxtables12 nginx-common
Suggested packages:
iproute2-doc fcgiwrap nginx-doc ssl-cert
The following NEW packages will be installed:
iproute2 libatm1 libbpf1 libelf1 libmnl0 libxtables12 nginx nginx-common
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 2116 kB of archives.
After this operation, 7010 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://deb.debian.org/debian bookworm/main amd64 libelf1 amd64 0.188-2.1 [174 kB]
Get:2 http://deb.debian.org/debian bookworm/main amd64 libbpf1 amd64 1:1.1.0-1 [145 kB]
Get:3 http://deb.debian.org/debian bookworm/main amd64 libmnl0 amd64 1.0.4-3 [12.5 kB]
Get:4 http://deb.debian.org/debian bookworm/main amd64 libxtables12 amd64 1.8.9-2 [30.8 kB]
Get:5 http://deb.debian.org/debian bookworm/main amd64 iproute2 amd64 6.1.0-3 [1046 kB]
Get:6 http://deb.debian.org/debian bookworm/main amd64 libatm1 amd64 1:2.5.1-4+b2 [68.3 kB]
Get:7 http://deb.debian.org/debian bookworm/main amd64 nginx-common all 1.22.1-9 [112 kB]
Get:8 http://deb.debian.org/debian bookworm/main amd64 nginx amd64 1.22.1-9 [527 kB]
Fetched 2116 kB in 0s (5728 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libelf1:amd64.
(Reading database ... 61386 files and directories currently installed.)
Preparing to unpack .../0-libelf1_0.188-2.1_amd64.deb ...
Unpacking libelf1:amd64 (0.188-2.1) ...
Selecting previously unselected package libbpf1:amd64.
Preparing to unpack .../1-libbpf1_1%3a1.1.0-1_amd64.deb ...
Unpacking libbpf1:amd64 (1:1.1.0-1) ...
Selecting previously unselected package libmnl0:amd64.
Preparing to unpack .../2-libmnl0_1.0.4-3_amd64.deb ...
Unpacking libmnl0:amd64 (1.0.4-3) ...
Selecting previously unselected package libxtables12:amd64.
Preparing to unpack .../3-libxtables12_1.8.9-2_amd64.deb ...
Unpacking libxtables12:amd64 (1.8.9-2) ...
Selecting previously unselected package iproute2.
Preparing to unpack .../4-iproute2_6.1.0-3_amd64.deb ...
Unpacking iproute2 (6.1.0-3) ...
Selecting previously unselected package libatm1:amd64.
Preparing to unpack .../5-libatm1_1%3a2.5.1-4+b2_amd64.deb ...
Unpacking libatm1:amd64 (1:2.5.1-4+b2) ...
Selecting previously unselected package nginx-common.
Preparing to unpack .../6-nginx-common_1.22.1-9_all.deb ...
Unpacking nginx-common (1.22.1-9) ...
Selecting previously unselected package nginx.
Preparing to unpack .../7-nginx_1.22.1-9_amd64.deb ...
Unpacking nginx (1.22.1-9) ...
Setting up nginx-common (1.22.1-9) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline
Setting up libatm1:amd64 (1:2.5.1-4+b2) ...
Setting up libmnl0:amd64 (1.0.4-3) ...
Setting up libxtables12:amd64 (1.8.9-2) ...
Setting up libelf1:amd64 (0.188-2.1) ...
Setting up libbpf1:amd64 (1:1.1.0-1) ...
Setting up iproute2 (6.1.0-3) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline
Setting up nginx (1.22.1-9) ...
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.
Processing triggers for libc-bin (2.36-9+deb12u4) ...

root@sample-app-2-59dfd44fcd-pwpct:/# service nginx start
Starting nginx: nginx.

3. SSH를 통해 샘플-1 포드의 설정을 확인합니다.

1. curl <sampl-app-2-pod-ip> 80

# Expected Output - nginx welcome page must open

Sample Actual output:
root@ganesh-instance-02:~/policies/sample# kubectl get pods -n sample -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
sample-app-1-7f4c69bc85-wr5mq 1/1 Running 0 15m 10.32.0.44 gke-sample-test-nw-poli-e2-node-medium-p-ed273764-51g2 <none> <none>
sample-app-2-59dfd44fcd-pwpct 1/1 Running 0 15m 10.32.0.45 gke-sample-test-nw-poli-e2-node-medium-p-ed273764-51g2 <none> <none>
sample-app-3-5c8f7c9d4c-zs2p2 1/1 Running 0 15m 10.32.0.46 gke-sample-test-nw-poli-e2-node-medium-p-ed273764-51g2 <none> <none>
root@ganesh-instance-02:~/policies/sample# kubectl exec -it sample-app-1-7f4c69bc85-wr5mq -n sample -- bash
root@sample-app-1-7f4c69bc85-wr5mq:/# curl 10.32.0.45 80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>


2. Connect to app-3 from app-1: curl <sampl-app-3-pod-ip> 80

# Expected Output - connection should time out.

Sample Actual output:
root@ganesh-instance-02:~/policies/sample# kubectl get pods -n sample -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
sample-app-1-7f4c69bc85-wr5mq 1/1 Running 0 15m 10.32.0.44 gke-sample-test-nw-poli-e2-node-medium-p-ed273764-51g2 <none> <none>
sample-app-2-59dfd44fcd-pwpct 1/1 Running 0 15m 10.32.0.45 gke-sample-test-nw-poli-e2-node-medium-p-ed273764-51g2 <none> <none>
sample-app-3-5c8f7c9d4c-zs2p2 1/1 Running 0 15m 10.32.0.46 gke-sample-test-nw-poli-e2-node-medium-p-ed273764-51g2 <none> <none>

root@sample-app-1-7f4c69bc85-wr5mq:/# curl 10.32.0.46 80
curl: (28) Failed to connect to 10.32.0.46 port 80 after 131344 ms: Couldn't connect to server


3. Connect to Metadata server:

curl -H "Metadata-Flavor: Google" http://169.254.169.254/computeMetadata/v1/instance/service-accounts/default/email

Expected Output:
# If workload identity is setup, GCP SA must be the output. Else Cluster Service Account must be displayed. Basically, the connection must happen.

Sample Actual Output:

root@sample-app-1-7f4c69bc85-wr5mq:/# curl -H "Metadata-Flavor: Google" http://169.254.169.254/computeMetadata/v1/instance/service-accounts/default/email
test-demo-410111.svc.id.goog




4. nslookup google.com

Expected output: Must connect to nameserver and display DNS server address which is kubeDNS service IP.

Sample Actual output:

root@sample-app-1-7f4c69bc85-wr5mq:/# nslookup google.com
Server: 10.36.0.10
Address: 10.36.0.10#53

Non-authoritative answer:
Name: google.com
Address: 173.194.206.113
Name: google.com
Address: 173.194.206.101
Name: google.com
Address: 173.194.206.100
Name: google.com
Address: 173.194.206.139
Name: google.com
Address: 173.194.206.102
Name: google.com
Address: 173.194.206.138
Name: google.com
Address: 2607:f8b0:4001:c07::8b
Name: google.com
Address: 2607:f8b0:4001:c07::64
Name: google.com
Address: 2607:f8b0:4001:c07::65
Name: google.com
Address: 2607:f8b0:4001:c07::71

제한 사항

표준 GKE 클러스터에는 다음 요구사항 및 제한사항이 적용됩니다.

  • GKE용 워크로드 아이덴티티 제휴를 사용하여 네트워크 정책을 구현하는 경우 메타데이터 서버로의 이그레스를 허용해야 합니다 .
  • 네트워크 정책 적용을 활성화하면 kube-system 프로세스의 메모리 공간이 약 128MB 증가하고 약 300밀리코어의 CPU가 필요합니다. 즉, 기존 클러스터에 네트워크 정책을 사용 설정하면 예약된 작업 부하를 계속 실행하기 위해 GKE 클러스터에서 클러스터 크기를 늘려야 할 수도 있습니다 .
  • 네트워크 정책 시행을 사용 설정하려면 GKE 노드를 다시 만들어야 합니다. 클러스터에 활성 유지 관리 기간이 있는 경우 다음 유지 관리 기간까지 노드가 자동으로 다시 생성되지 않습니다.
  • 네트워크 정책 시행을 실행하기 위해 GCP에서 권장하는 최소 클러스터 크기는 e2-medium 인스턴스 3개입니다.

리소스 요구 사항이 너무 높기 때문에 노드가 f1-micro 또는 g1-small 인스턴스인 클러스터에는 네트워크 정책이 지원되지 않습니다.

결론

네트워크 정책은 GKE 클러스터 내에서 수신 및 송신 트래픽을 제어하는 ​​강력하고 유연한 접근 방식을 제공합니다. 이러한 정책을 효과적으로 정의하고 활용함으로써 우리는 다음을 달성할 수 있습니다.

  • 보안 강화: 무단 트래픽을 제한함으로써 클러스터 내에서 데이터 침해 및 무단 액세스의 위험을 크게 줄입니다.
  • 향상된 제어 및 규정 준수: 네트워크 통신에 대한 세부적인 제어는 최소 권한 원칙에 부합하며 보안 규정 준수를 용이하게 합니다.
  • 단순화된 네트워크 관리: 네트워크 정책은 허용된 통신 경로에 대한 명확한 가시성을 제공하여 문제 해결을 돕고 보안 감사를 단순화합니다.

네트워크 정책 구현에 능숙해지면 GKE 내에서 컨테이너화된 애플리케이션을 위한 보다 안전하고 잘 정의된 환경을 만들 수 있습니다. 이를 통해 우리는 잠재적인 보안 위험을 완화하면서 자신 있게 애플리케이션을 배포하고 관리할 수 있습니다.

2024년 사용하면 좋은 13가지 쿠버네티스 도구(2)

· 6 min read

image

이전 2024년 사용하면 좋은 13가지 쿠버네티스 도구(1) 에서 다뤘던 쿠버네티스 추천 도구들에 이어서 작성합니다. 

8. Skaffold

Skaffold는 쿠버네티스 앱의 지속적인 개발을 촉진하는 명령줄 도구입니다. 앱 구축, 푸시 및 배포를 위한 워크플로우를 자동화하여 개발자가 코드를 더 쉽게 반복할 수 있도록 합니다.

Skaffold 는 개발 단계에 이상적이기 때문에 개발자가 배포 프로세스에 대해 걱정하지 않고 코드 작성에 집중할 수 있게 해주기 때문에 개발 중 빠른 피드백을 통해 발전하고 싶은 팀에 유용합니다.

개발 및 배포 프로세스를 자동화하고 단순화하여, 여러 빌드 도구 및 배포 전략을 지원해 기존 CI/CD 파이프라인과 잘 통합할 수 있습니다.

GitHub: https://github.com/GoogleContainerTools/skaffold

 [GitHub - GoogleContainerTools/skaffold: Easy and Repeatable Kubernetes Development

Easy and Repeatable Kubernetes Development. Contribute to GoogleContainerTools/skaffold development by creating an account on GitHub.

github.com](https://github.com/GoogleContainerTools/skaffold)

웹사이트: https://skaffold.dev/

 [Skaffold

Easy and Repeatable Container & Kubernetes Development

skaffold.dev](https://skaffold.dev/)

사용 코드 예:

apiVersion: skaffold/v2beta13
kind: Config
build:
artifacts:
- image: my-app
deploy:
kubectl:
manifests:
- k8s-*

문서: https://skaffold.dev/docs/

 [Skaffold 2.0 Documentation

Easy and Repeatable Container & Kubernetes Development

skaffold.dev](https://skaffold.dev/docs/)

대안으로는 Tilt 가 있습니다.

9. Kubevela

Kubevela 는 기본 인프라의 복잡성을 추상화하여 앱 배포 및 관리를 단순화하는 최신 앱 배포 시스템입니다.

클라우드 네이티브 앱을 배포하고 관리하기 위해 높은 수준의 자동화 및 추상화가 필요한 환경에 가장 적합합니다.

서비스의 복잡성에 관계없이 앱 제공에 대한 단순하고 일관된 접근 방식을 제공하기 때문에 운영자에게 필요한 유연성과 성능을 유지하면서 개발자가 접근할 수 있습니다.

GitHub: https://github.com/oam-dev/kubevela

 [GitHub - kubevela/kubevela: The Modern Application Platform.

The Modern Application Platform. Contribute to kubevela/kubevela development by creating an account on GitHub.

github.com](https://github.com/oam-dev/kubevela)

웹사이트: https://kubevela.io/

 [Make shipping applications more enjoyable. | KubeVela

Make shipping applications more enjoyable.

kubevela.io](https://kubevela.io/)

사용 코드 예:

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: example-app
spec:
components:
- name: example-component
type: webservice
properties:
image: nginx
port: 80

문서: https://kubevela.io/docs/

 [Introduction | KubeVela

What is KubeVela?

kubevela.io](https://kubevela.io/docs/)

대안으로 Helm 가 있습니다.

10. Crossplane

Crossplane 은 클러스터를 확장하여 여러 공급업체 및 소스의 인프라를 표준 쿠버네티스 리소스로 관리하고 구성하는 오픈 소스 쿠버네티스 추가 기능입니다.

Crossplane 은 쿠버네티스 환경 내에서 코드형 인프라(IaC) 방식을 채택하려는 팀에 특히 유용하고, 쿠버네티스 API를 통해 데이터베이스, 클러스터, 스토리지 계정과 같은 외부 리소소를 관리할 수 있습니다.

선언적 구성을 사용하여 클라우드 네이티브 앱과 의존하는 인프라의 배포 및 관리를 통합할 수 있습니다.

GitHub: https://github.com/crossplane/crossplane

 [GitHub - crossplane/crossplane: The Cloud Native Control Plane

The Cloud Native Control Plane. Contribute to crossplane/crossplane development by creating an account on GitHub.

github.com](https://github.com/crossplane/crossplane)

홈페이지: https://crossplane.io/

 [Crossplane - The cloud-native control plane framework

Crossplane is a framework for building cloud native control planes without needing to write code. It has a highly extensible backend that enables you to build a control plane that can orchestrate applications and infrastructure no matter where they run, an

www.crossplane.io](https://crossplane.io/)

사용 코드 예:

apiVersion: database.example.org/v1alpha1
kind: MySQLInstance
metadata:
name: my-db-instance
spec:
engineVersion: "5.7"
storageGB: 20

문서: https://crossplane.io/docs/

 [Crossplane ·

docs.crossplane.io](https://crossplane.io/docs/)

대안으로는 Terraform 입니다.

11. Kube-bench

Kube-bench 는 CIS Kubernetes 벤치마크에 문서화된 검사를 실행하여 쿠버네티스 배포가 안전한지 확인하도록 설계 된 오픈 소스 도구입니다.

Kube-bench를 활용해 쿠버네티스 클러스터의 보안 준수 여부를 감사하여 CIS(Center for Internet Security) 모범 사례에 따라 잠재적 취약점을 식별하고 해결합니다.

쿠버네티스 클러스터가 CIS 벤치마크를 준수하는지 확인하면 일반적인 보안 위협으로부터 보호하고 안전한 쿠버네티스 배포를 위한 업계 표준에 맞춰 작업을 조정할 수 있습니다.

GitHub: https://github.com/aquasecurity/kube-bench

 [GitHub - aquasecurity/kube-bench: Checks whether Kubernetes is deployed according to security best practices as defined in the C

Checks whether Kubernetes is deployed according to security best practices as defined in the CIS Kubernetes Benchmark - aquasecurity/kube-bench

github.com](https://github.com/aquasecurity/kube-bench)

웹사이트: 모든 리소스와 문서는 GitHub 저장소를 참조하세요.

사용 코드 예: kube-bench를 실행하려면 일반적으로 Kubernetes 클러스터의 컨테이너 내에서 실행합니다.

kubectl run --rm -i -t kube-bench --image=aquasec/kube-bench:latest --restart=Never -- benchmarks/run

문서: GitHub 저장소의 README와 다양한 Kubernetes 버전에 대한 다양한 마크다운 파일을 통해 직접 사용할 수 있습니다.

대안으로는 Kube-hunter 입니다.

12. Kubernetes External Secrets

Kubernetes External Secrets 을 사용하면 AWS Secrets Manager 또는 HashiCorp Vault와 같은 외부 비밀 관리 시스템을 사용하여 쿠버네티스에 Secret을 안전하게 추가할 수 있습니다.

이 도구는 쿠버네티스의 기본 secret 처리 매커니즘을 외부에서 관리하고 쿠버네티스 앱 내에서 사용하기 위한 보안 브리지가 필요한 경우 필수입니다.

쿠버네티스의 기본 secret을 제공하는 것 이상으로 secret 순환, 중앙 집중식 감사, 접근 제어와 같은 고급 기능을 제공하는 전용 비밀 관리 시스템을 사용해 보안을 강화할 수 있습니다.

GitHub: https://github.com/external-secrets/kubernetes-external-secrets

 [GitHub - external-secrets/kubernetes-external-secrets: Integrate external secret management systems with Kubernetes

Integrate external secret management systems with Kubernetes - external-secrets/kubernetes-external-secrets

github.com](https://github.com/external-secrets/kubernetes-external-secrets)

웹사이트: GitHub 저장소는 정보 및 문서의 주요 소스 역할을 합니다.

사용 코드 예:

apiVersion: kubernetes-client.io/v1
kind: ExternalSecret
metadata:
name: my-database-secret
spec:
backendType: secretsManager
data:
- key: /my/organization/secrets/database/password
name: password

문서: 설정 지침, 구성 및 사용 예를 포함하여 GitHub 저장소 내에서 문서를 찾을 수 있습니다.

대안으로는 Kubernetes 통합이 포함된 HashiCorp Vault 이 있습니다.

13. Octant

Octant 는 쿠버네티스 클러스터에 대한 깊은 분석을 제공하는 확장성이 뛰어난 오픈 소스 개발자 중심의 쿠버네티스용 웹 인터페이스입니다. 클러스터 내에서 관리되는 리소스에 대한 포괄적인 보기와 문제 해결을 더 쉽게 해주는 기능을 제공합니다.

쿠버네티스 클러스터의 시각적 표현을 찾고, 문제를 디버그하고, 클러스터 리소스를 검사하거나 리소스 간 관계를 이해해야 할 때 유용하게 사용할 수 있습니다. 실시간 업데이트, 확장된 기능을 위한 플러그인 에코시스템, 쿠버네티스 리소스를 탐색할 수 있는 사용자 친화적 인터페이스를 제공하여 관리 및 문제 해결을 용이하게 합니다.

GitHub: https://github.com/vmware-tanzu/octant

 [GitHub - vmware-archive/octant: Highly extensible platform for developers to better understand the complexity of Kubernetes clus

Highly extensible platform for developers to better understand the complexity of Kubernetes clusters. - vmware-archive/octant

github.com](https://github.com/vmware-tanzu/octant)

웹사이트: https://octant.dev/

 [Octant

Real-time updates With a complete view of an object and all its related objects, you can more accurately assess the status of applications and avoid unfocused debugging when things go wrong.

octant.dev](https://octant.dev/)

사용 코드 예: Octant는 GUI 기반 도구이므로 일반적인 사용법에는 로컬 시스템에서 애플리케이션을 시작한 다음 Kubernetes 클러스터에 연결하는 것이 포함됩니다.

octant

문서: https://octant.dev/docs/

 [Documentation

If you are new to Octant check out our Getting Started guide which can help you get Octant installed and running. For complete documentation, from installation to how to get started developing plugins for Octant, visit our Octant Reference website.

octant.dev](https://octant.dev/docs/)

대안으로 Kubernetes Dashboard 가 있습니다.

지금까지 2024년에 쿠버네티스에 사용하면 좋은 도구들에 대해서 알아 봤습니다. 워낙 많은 도구들이 있어 모두 다룰 수는 없지만 알아 본 도구들을 알아두면 큰 도움이 될 것으로 보입니다! 감사합니다! 😊

2024년 사용하면 좋은 13가지 쿠버네티스 도구(1)

· 7 min read

image

최근 쿠버네티스에 관심이 생기면서 여러 가지 테스트를 해 보고 있는데, 쿠버네티스를 사용할 때 이용하면 좋은 13가지 도구를 소개해 보려고 합니다. 

쿠버네티스는 컨테이너 오케스트레이션 플랫폼 중 선도적 역할을 하고 있고 생태계 또한 아주 빠르게 발전하고 있기 때문에 데브옵스 전문가라면 배워두면 좋아 보입니다.

구성한 쿠버네티스의 구조가 복잡해 지고 방대해 질수록 이를 간소화하여 처리하기 위해 여러 도구가 필요합니다.

1. Argo CD

Argo CD는 쿠버네티스에 사용이 적합한 CD 도구로서 앱 배포를 자동화하고 Git 저장소에 저장된 구성과 일치하는지 지속적으로 체크합니다.

빠른 반복과 일관된 배포 방식이 중요한 환경에 가장 적합한데 Argo CD는 변경 사항에 대한 추적을 통해 개발 환경부터 운영 환경까지 다중 배포 전략에도 유용하게 사용합니다.

Argo CD는 GitOps 의 방식을 채택해서 팀이 Git 을 배포를 위한 단일 정보 소스로 활용해 프로세스를 단순호하고 보안 및 추적성을 향상 시킨 장점이 있습니다.

GitHub: https://github.com/argoproj/argo-cd

 [GitHub - argoproj/argo-cd: Declarative Continuous Deployment for Kubernetes

Declarative Continuous Deployment for Kubernetes. Contribute to argoproj/argo-cd development by creating an account on GitHub.

github.com](https://github.com/argoproj/argo-cd)

웹사이트: https://argoproj.github.io/argo-cd/

 [https://argoproj.github.io/argo-cd/

argoproj.github.io](https://argoproj.github.io/argo-cd/)

사용 코드 예:

argocd app create <앱 이름> \ 
--repo <your_repo_url> \
--path <path_to_app_manifests> \
--dest-server https://kubernetes.default.svc \
--dest-namespace <네임스페이스>

문서: https://argo-cd.readthedocs.io/en/stable/

 [Argo CD - Declarative GitOps CD for Kubernetes

Overview What Is Argo CD? Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. Why Argo CD? Application definitions, configurations, and environments should be declarative and version controlled. Application deployment and lifecycle ma

argo-cd.readthedocs.io](https://argo-cd.readthedocs.io/en/stable/)

대안 도구로 Flux가 있습니다.

2. Helm

Helm은 쿠버네티스용 패키지 관리자입니다. 개발자와 운영자가 쿠버네티스 클러스터에 앱을 쉽게 패키징, 구성하고 배포할 수 있게 합니다.

Helm은 간단한 명령줄 인터페이스를 통해 쿠버네티스 앱을 정의, 설치, 업그레이드 할 수 있고 복잡한 앱을 관리하기 좋습니다.

Helm 차트는 앱을 배포, 관리하며 복잡한 종속성을 지원해 간편하게 업데이트, 롤백을 수행할 수 있게 합니다.

GitHub: https://github.com/helm/helm

 [GitHub - helm/helm: The Kubernetes Package Manager

The Kubernetes Package Manager. Contribute to helm/helm development by creating an account on GitHub.

github.com](https://github.com/helm/helm)

웹사이트: https://helm.sh/

 [Helm

Helm - The Kubernetes Package Manager.

helm.sh](https://helm.sh/)

사용 코드 예:

helm install my -app ./ my -chart

문서: https://helm.sh/docs/

 [Docs Home

Everything you need to know about how the documentation is organized.

helm.sh](https://helm.sh/docs/)

대안 도구로 Kustomize 가 있습니다.

3. Kustomize

Kustomize 는 쿠버네티스의 자체 구성 관리 기능을 향상시키는 쿠버네티스 기반의 구성 관리 도구입니다.

다양한 환경, 배포 시나리오 처럼 하나의 앱에 약간씩 다른 여러 구성을 유지해야 할 때 특히 유용한 편입니다.

템플릿 처리나 수동 편집 없이 쿠버네티스 리소스 구성을 직접 정의할 수 있어 다양한 환경에서 앱 구성을 더 쉽게 관리할 수 있습니다.

GitHub: https://github.com/kubernetes-sigs/kustomize

 [GitHub - kubernetes-sigs/kustomize: Customization of kubernetes YAML configurations

Customization of kubernetes YAML configurations. Contribute to kubernetes-sigs/kustomize development by creating an account on GitHub.

github.com](https://github.com/kubernetes-sigs/kustomize)

웹사이트: https://kustomize.io/

 [Kustomize - Kubernetes native configuration management

Overview Kustomize traverses a Kubernetes manifest to add, remove or update configuration options without forking. It is available both as a standalone binary and as a native feature of kubectl. Purely declarative approach to configuration customization Na

kustomize.io](https://kustomize.io/)

사용 코드 예:

# kustomization.yaml
resources:
- deployment.yaml
- service.yaml

문서: https://kubectl.docs.kubernetes.io/

 [SIG CLI

Documentation for Kubectl and Kustomize

kubectl.docs.kubernetes.io](https://kubectl.docs.kubernetes.io/)

대안으로는 Helm 이 있습니다.

4. Prometheus

Prometheus는 차원 데이터 모델, 유연한 쿼리 언어 및 경고 기능을 갖춘 오픈 소스 모니터링 시스템입니다.

안정성과 확장성을 고려해 설계되었기 때문에 쿠버네티스 환경에 이상적인 모니터링 솔루션이라고 생각합니다.

metric을 시계열 데이터로 수집하고 저장하여 쿠버네티스 클러스터의 성능과 앱 상태에 대해 면밀한 분석이 가능합니다.

강력한 데이터 모델과 쿼리 언어(PromQL)를 통해 쿠버네티스 클러스터에 대한 자세한 관찰 및 실시간 모니터링을 지원하므로 문제를 더 쉽게 식별하고 해결할 수 있습니다.

GitHub: https://github.com/prometheus/prometheus

 [GitHub - prometheus/prometheus: The Prometheus monitoring system and time series database.

The Prometheus monitoring system and time series database. - prometheus/prometheus

github.com](https://github.com/prometheus/prometheus)

웹사이트: https://prometheus.io/

 [Prometheus - Monitoring system & time series database

An open-source monitoring system with a dimensional data model, flexible query language, efficient time series database and modern alerting approach.

prometheus.io](https://prometheus.io/)

사용 코드 예:

# Prometheus scrape configuration
scrape_configs:
- job_name: 'kubernetes-pods'
kubernetes_sd_configs:
- role: pod

문서: https://prometheus.io/docs/introduction/overview/

 [Overview | Prometheus

An open-source monitoring system with a dimensional data model, flexible query language, efficient time series database and modern alerting approach.

prometheus.io](https://prometheus.io/docs/introduction/overview/)

대안으로는 Grafana for visualization, Thanos for long-term storage enhancement 가 있습니다.

5. Istio

Istio는 마이크로서비스가 데이터를 공유하는 방법을 제어하는 방법을 제공하는 강력한 service mesh 도구입니다.

앱에 고급 트랙픽 관리, 보안 기능 및 관찰 기능을 제공합니다.

Istio는 트래픽, 보안 정책 및 서비스 모니터링을 세밀하게 제어해야 하는 복잡한 마이크로서비스 아키텍처에 특히 유용합니다.

코드를 변경할 필요 없이 서비스를 보다 효과적으로 보호, 연결 및 모니터링 할 수 있는 추가 인프라 계층을 제공합니다.

GitHub: https://github.com/istio/istio

 [GitHub - istio/istio: Connect, secure, control, and observe services.

Connect, secure, control, and observe services. Contribute to istio/istio development by creating an account on GitHub.

github.com](https://github.com/istio/istio)

홈페이지: https://istio.io/

 [Istio

A service mesh for observability, security in depth, and management that speeds deployment cycles.

istio.io](https://istio.io/)

사용 코드 예:

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: my-gateway
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "*"

문서: https://istio.io/latest/docs/

 [Documentation

Learn how to deploy, use, and operate Istio.

istio.io](https://istio.io/latest/docs/)

대안으로는 Linkerd 가 있습니다.

6. Tekton

Tekton은 CI/CD 시스템을 생성하기 위한 강력하고 유연한 쿠버네티스 기반 오픈 소스 프레임워크로, 개발자는 이를 이용해 클라우드와 온프레미스 시스템 전반에 걸쳐 구축, 테스트 및 배포할 수 있습니다.

쿠버네티스 기반 CI/CD 파이프라인을 구성하는데 가장 잘 활용됩니다. 클라우드 네이티브 방식으로 다양한 환경에서 개발 워크플로우를 표준화하려는 팀이 있다면 이것을 사용하면 좋습니다.

기본 구현 세부 정보를 추상화하고 CI/CD 파이프라인을 구축하고 실행하기 위한 표준화된 쿠버네티스 기반 구성 세트를 제공하여 확장성과 이식성이 뛰어납니다.

GitHub: https://github.com/tektoncd/pipeline

 [GitHub - tektoncd/pipeline: A cloud-native Pipeline resource.

A cloud-native Pipeline resource. Contribute to tektoncd/pipeline development by creating an account on GitHub.

github.com](https://github.com/tektoncd/pipeline)

웹사이트: https://tekton.dev/

 [Tekton

Cloud Native CI/CD

tekton.dev](https://tekton.dev/)

사용 코드 예:

apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: hello-world
spec:
steps:
- name: echo
image: ubuntu
command:
- echo
args:
- "Hello World"

문서: https://tekton.dev/docs/

 [Welcome to Tekton

Cloud Native CI/CD

tekton.dev](https://tekton.dev/docs/)

대안으로 Jenkins X 가 있습니다.

7. Flux

Flux는 쿠버네티스 클러스터 관리에 대한 GitOps의 접근 방식을 채택한 도구입니다. 클러스터 상태가 Git 저장소에 설명되고 자동으로 적용 및 업데이트 됩니다.

쿠버네티스 앱 및 인프라 관리를 위해 GitIOps 원칙을 채택하는 팀에 특히 유용하며 클러스터 상태가 항상 Git 저장소와 동기화 되도록 보장합니다.

배포 프로세스를 자동화하고 재현성, 추적성을 향상하며 쿠버네티스와 원활하게 통합되어 휴먼 오류의 위험을 줄입니다.

GitHub: https://github.com/fluxcd/flux

 [GitHub - fluxcd/flux: Successor: https://github.com/fluxcd/flux2

Successor: https://github.com/fluxcd/flux2. Contribute to fluxcd/flux development by creating an account on GitHub.

github.com](https://github.com/fluxcd/flux)

홈페이지: https://fluxcd.io/

 [Flux - the GitOps family of projects

Flux is a set of continuous and progressive delivery solutions for Kubernetes, and they are open and extensible. The APIs of Flux are stable now.

fluxcd.io](https://fluxcd.io/)

사용 코드 예:

apiVersion: helm.fluxcd.io/v1
kind: HelmRelease
metadata:
name: my-app
spec:
chart:
repository: https://charts.my-company.com/
name: my-app
version: 1.2.3

문서: https://fluxcd.io/docs/

 [Flux Documentation

Open and extensible continuous delivery solution for Kubernetes.

fluxcd.io](https://fluxcd.io/docs/)

대안으로는 Argo CD 입니다.