1. ๋„คํ‹ฐ์›Œํฌ ์„œ๋น„์Šค ๊ฐœ๋…

    / [pdf]



2. Telepresense ์„ค์น˜

์„ค์น˜ ๊ฐ€์ด๋“œ (Install Client, Install Trafiic Manager ์ฐธ๊ณ )

- Telepresense CLI ๋กœ์ปฌ ์„ค์น˜

  • Linux ์„ค์น˜
  # 1. Download the latest binary (~95 MB):
# AMD
sudo curl -fL https://github.com/telepresenceio/telepresence/releases/latest/download/telepresence-linux-amd64 -o /usr/local/bin/telepresence

# ARM
sudo curl -fL https://github.com/telepresenceio/telepresence/releases/latest/download/telepresence-linux-arm64 -o /usr/local/bin/telepresence

# 2. Make the binary executable:
sudo chmod a+x /usr/local/bin/telepresence
  
  • AMD(intel) Mac ์„ค์น˜
  # 1. Download the binary.
sudo curl -fL https://github.com/telepresenceio/telepresence/releases/latest/download/telepresence-darwin-amd64 -o /usr/local/bin/telepresence

# 2. Make the binary executable:
sudo chmod a+x /usr/local/bin/telepresence
  
  • ARM(Apple Silicon) Mac ์„ค์น˜
  # 1. Ensure that no old binary exists. This is very important because Silicon macs track the executable's signature
# and just updating it in place will not work.
sudo rm -f /usr/local/bin/telepresence

# 2. Download the binary.
sudo curl -fL https://github.com/telepresenceio/telepresence/releases/latest/download/telepresence-darwin-arm64 -o /usr/local/bin/telepresence

# 3. Make the binary executable:
sudo chmod a+x /usr/local/bin/telepresence
  
  • Windows ์„ค์น˜
  # To install Telepresence, run the following commands
# from PowerShell as Administrator.

# 1. Download the latest windows zip containing telepresence.exe and its dependencies (~60 MB):
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest https://github.com/telepresenceio/telepresence/releases/latest/download/telepresence-windows-amd64.zip -OutFile telepresence.zip

# 2. Unzip the telepresence.zip file to the desired directory, then remove the zip file:
Expand-Archive -Path telepresence.zip -DestinationPath telepresenceInstaller/telepresence
Remove-Item 'telepresence.zip'
cd telepresenceInstaller/telepresence

# 3. Run the install-telepresence.ps1 to install telepresence's dependencies. It will install telepresence to
# C:\telepresence by default, but you can specify a custom path by passing in -Path C:\my\custom\path
powershell.exe -ExecutionPolicy bypass -c " . '.\install-telepresence.ps1';"

# 4. Remove the unzipped directory:
cd ../..
Remove-Item telepresenceInstaller -Recurse -Confirm:$false -Force

# 5. Telepresence is now installed and you can use telepresence commands in PowerShell.
  

- Telepresense Server๋ฅผ K8s ํด๋Ÿฌ์Šคํ„ฐ์— ์„ค์น˜

  # Telepresence namespace ์ƒ์„ฑ
kubectl create namespace telepresense

# Telepresense ์„œ๋ฒ„๋ฅผ ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค์— ์„ค์น˜
telepresence helm install -n telepresense

### -  ์„ค์น˜ ํ™•์ธ
kubectl get all -n telepresence
  

- ์—ฐ๊ฒฐ ํ•˜๊ณ  ์ƒํƒœ ํ™•์ธํ•˜๊ธฐ

  # Telepresense ํ”„๋ก์‹œ ์—ฐ๊ฒฐ
telepresence connect  --manager-namespace telepresense

# ์—ฐ๊ฒฐ ์ƒํƒœ ํ™•์ธ
telepresence status
  

3. ClusterIP

- nodes app ์ƒ์„ฑ

  • ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ž‘์„ฑ
  • app.js
  const http = require('http');
const os = require('os');

console.log("Kubia server starting...");

var handler = function(request, response) {
  console.log("Received request from " + request.connection.remoteAddress);
  response.writeHead(200);
  response.end("You've hit " + os.hostname() + "\n");
};

var www = http.createServer(handler);
www.listen(8080);
  
  • Dockerfile ์ž‘์„ฑ
  # FROM ์œผ๋กœ BASE ์ด๋ฏธ์ง€ ๋กœ๋“œ
FROM node:7

# ADD ๋ช…๋ น์–ด๋กœ ์ด๋ฏธ์ง€์— app.js ํŒŒ์ผ ์ถ”๊ฐ€
ADD app.js /app.js

# ENTRYPOINT ๋ช…๋ น์–ด๋กœ node ๋ฅผ ์‹คํ–‰ํ•˜๊ณ  ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ app.js ๋ฅผ ์ „๋‹ฌ
ENTRYPOINT ["node", "app.js"]
  
  • ์ปคํ…Œ์ด๋„ˆ ๋นŒ๋“œ ๋ฐ ํ‘ธ์‹œ
  docker build -t <DOCKER ID>/nodeapp . --push
  

- POD ์ƒ์„ฑ

  • pod ์ƒ์„ฑ
  • nodeapp-deploy.yml
  apiVersion: apps/v1
kind: Deployment
metadata:
  name: nodeapp-deploy
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nodeapp-pod
  template:
    metadata:
      labels:
        app: nodeapp-pod
    spec:
      containers:
      - name: nodeapp-container
        image: dangtong/nodeapp
        ports:
        - containerPort: 8080
  

- ClusterIP ์„œ๋น„์Šค ์ƒ์„ฑ

  • ์„œ๋น„์Šค ์ƒ์„ฑ
  • nodeapp-svc.yml
  apiVersion: v1
kind: Service
metadata:
  name: nodeapp-service
spec:
  ports:
  - port: 80
    targetPort: 8080
  selector:
    app: nodeapp-pod
  

- ์„œ๋น„์Šค ํ™•์ธ

  • ์กฐํšŒ
  kubectl get  po,deploy,svc
  
  • Deployment ์ƒ์„ฑ
  kubectl apply -f ./nodeapp-deploy.yml
  
  • ์„œ๋น„์Šค ์ƒ์„ฑ
  kubectl apply -f ./nodeapp-svc.yml
  
  • port-forward to service
  kubectl port-forward service/nodeapp-service 8080:80
  
  • port-forward to pod
  
  

[์—ฐ์Šต๋ฌธ์ œ] 5-1. ClusterIP

  • nginx:1.8.9 ์ด๋ฏธ์ง€๋ฅผ ์ด์šฉํ•˜์—ฌ Replica=3 ์ธ Deployment ๋ฅผ ์ƒ์„ฑํ•˜์„ธ์š”
  • nginx ์„œ๋น„์Šค๋ฅผ ๋กœ๋“œ๋ฐธ๋ ์‹ฑ ํ•˜๋Š” ์„œ๋น„์Šค๋ฅผ ClusterIP ๋กœ ์ƒ์„ฑํ•˜์„ธ์š”
  • kubernetes port-forward๋ฅผ ์ด์šฉํ•ด์„œ ๋„คํŠธ์›Œํฌ๋ฅผ ์—ฐ๊ฒฐํ•˜๊ณ  curl ๋ช…๋ น์–ด๋กœ ์›น์‚ฌ์ดํŠธ๋ฅผ ์กฐํšŒ ํ•˜์„ธ์š”

4. NodePort (๋กœ์ปฌ ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค์—์„œ ์‹คํ–‰)

- ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ƒ์„ฑ

  apiVersion: apps/v1
kind: Deployment
metadata:
  name: nodeapp-deploy
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nodeapp-pod
  template:
    metadata:
      labels:
        app: nodeapp-pod
    spec:
      containers:
      - name: nodeapp-container
        image: dangtong/nodeapp
        ports:
        - containerPort: 8080
  

- NodePort ์ƒ์„ฑ

  apiVersion: v1
kind: Service
metadata:
  name: node-nodeport
spec:
  type: NodePort
  ports:
  - port: 80
    targetPort: 8080
    nodePort: 30123
  selector:
    app:  nodeapp-pod
  
  kubectl apply -f ./nodeapp-nodeport.yml
  
  • ๋ฆฌ์†Œ์Šค ์กฐํšŒ
  kubectl get po,rs,svc
  
  • ๋…ธ๋“œ ์กฐํšŒ
  kubectl get no -o wide
  

๋กœ์ปฌ ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ๋…ธ๋“œ์˜ ํ˜ธ์ŠคํŠธ IP ํ™•์ธํ•˜๊ธฐ

  docker inspect kind
  
  • ์„œ๋น„์Šค ์ ‘์† (์—ฌ๋Ÿฌ๋ฒˆ ์ˆ˜ํ–‰)
  curl http://<host-ip>:30123
curl http://<host-ip>:30123
curl http://<host-ip>:30123
curl http://<host-ip>:30123
curl http://<host-ip>:30123
  

5. LoadBalancer

- Deployment ์ƒ์„ฑ

  apiVersion: apps/v1
kind: Deployment
metadata:
  name: nodeapp-deployment
  labels:
    app: nodeapp
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nodeapp-pod
  template:
    metadata:
      labels:
        app: nodeapp-pod
    spec:
      containers:
      - name: nodeapp-container
        image: dangtong/nodeapp
        ports:
        - containerPort: 8080
  

- LoadBalancer ์ƒ์„ฑ (AWS)

  • AWS Load Balancer ์ƒ์„ฑ
  apiVersion: v1
kind: Service
metadata:
  name:  nodeapp-lb
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-type: external
    service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: ip
    service.beta.kubernetes.io/aws-load-balancer-scheme: internet-facing
spec:
  type: LoadBalancer
  ports:
  - port: 80
    targetPort: 8080
  selector:
    app: nodeapp-pod
  
  • GCP Loadbalancer ์ƒ์„ฑ
  apiVersion: v1
kind: Service
metadata:
  name:  nodeapp-lb
spec:
  type: LoadBalancer
  ports:
  - port: 80
    targetPort: 8080
  selector:
    app: nodeapp-pod
  

- LoadBalancer ํ™•์ธ ๋ฐ ์ ‘์†

EXTERNAL-IP ์— ํ•ด๋‹นํ•˜๋Š” URL๋กœ ๋ธŒ๋ผ์šฐ์ €์—์„œ HTTP๋กœ ์ ‘์†

  kubectl get svc
  

6. Ingress

Ingress๋Š” ํด๋Ÿฌ์Šคํ„ฐ ์™ธ๋ถ€์—์„œ ํด๋Ÿฌ์Šคํ„ฐ ๋‚ด๋ถ€ ์„œ๋น„์Šค๋กœ HTTP/HTTPS ํŠธ๋ž˜ํ”ฝ์„ ๋ผ์šฐํŒ…ํ•˜๋Š” ๊ทœ์น™์„ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.

- Ingress Controller ํ™•์ธ

  kubectl get deploy -n kube-system
  

- ๊ธฐ๋ณธ Ingress ์˜ˆ์ œ

1. Deployment ์ƒ์„ฑ

  apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
  

2. Service ์ƒ์„ฑ

  apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  selector:
    app: nginx
  ports:
  - port: 80
    targetPort: 80
  

3. Ingress ์ƒ์„ฑ

  apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
  name: alb-ingress-class
spec:
  controller: ingress.k8s.aws/alb
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nginx-ingress
  annotations:
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/target-type: ip
spec:
  ingressClassName: "alb-ingress-class"
  rules:
  - host: nginx.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: nginx-service
            port:
              number: 80
  

- Ingress ํ…Œ์ŠคํŠธ

1. ๋ฆฌ์†Œ์Šค ์ƒ์„ฑ

  kubectl apply -f nginx-deployment.yaml
kubectl apply -f nginx-service.yaml
kubectl apply -f nginx-ingress.yaml
  

2. Ingress ์ƒํƒœ ํ™•์ธ

  aws elbv2 describe-load-balancers
kubectl get ingress
kubectl describe ingress nginx-ingress
  

3. ์ ‘์† ํ…Œ์ŠคํŠธ

  # Ingress IP ํ™•์ธ
kubectl run test-dns --image=busybox:1.28 --rm -it --restart=Never -- nslookup k8s-default-nginxing-d8df56bf3a-1927562401.ap-northeast-2.elb.amazonaws.com

# ํ˜ธ์ŠคํŠธ ํŒŒ์ผ์— ๋„๋ฉ”์ธ ์ถ”๊ฐ€ (๋กœ์ปฌ ํ…Œ์ŠคํŠธ์šฉ)
echo "<Ingress-Public-IP> nginx.example.com" >> /etc/hosts

# ์ ‘์† ํ…Œ์ŠคํŠธ
curl -H "nginx.example.com" http://nginx.example.com
  

- ๊ฒฝ๋กœ ๊ธฐ๋ฐ˜ ๋ผ์šฐํŒ… Ingress

1. ์—ฌ๋Ÿฌ ์„œ๋น„์Šค ์ƒ์„ฑ

  # app1-deploy.yml
# app1 ์„œ๋น„์Šค
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app1-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: app1
  template:
    metadata:
      labels:
        app: app1
    spec:
      containers:
      - name: app1
        image: nginx
        ports:
        - containerPort: 80
---
# app1-svc.yml
apiVersion: v1
kind: Service
metadata:
  name: app1-service
spec:
  selector:
    app: app1
  ports:
  - port: 80
    targetPort: 80
  
  # app2-deploy.yml
# app2 ์„œ๋น„์Šค
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app2-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: app2
  template:
    metadata:
      labels:
        app: app2
    spec:
      containers:
      - name: app2
        image: httpd:2.4
        ports:
        - containerPort: 80
---
# app2-svc.yml
apiVersion: v1
kind: Service
metadata:
  name: app2-service
spec:
  selector:
    app: app2
  ports:
  - port: 80
    targetPort: 80
  

2. ๊ฒฝ๋กœ ๊ธฐ๋ฐ˜ Ingress

  apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
  name: alb-ingress-class
spec:
  controller: ingress.k8s.aws/alb
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: path-based-ingress
  annotations:
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/target-type: ip
    alb.ingress.kubernetes.io/rewrite-target: /
spec:
  ingressClassName: "alb-ingress-class"
  rules:
  - host: nginx.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: app1-service
            port:
              number: 80
  - host: apache.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: app2-service
            port:
              number: 80
  

3. ์ ‘์† ํ…Œ์ŠคํŠธ

  # Ingress ์ƒํƒœ ํ™•์ธ
```bash
aws elbv2 describe-load-balancers
  

Ingress domain ํ™•์ธ

  kubectl get ingress
  

Ingress IP ํ™•์ธ

  kubectl run test-dns --image=busybox:1.28 --rm -it --restart=Never -- nslookup <ingress-domain>
  

ํ˜ธ์ŠคํŠธ ํŒŒ์ผ์— ๋„๋ฉ”์ธ ์ถ”๊ฐ€ (๋กœ์ปฌ ํ…Œ์ŠคํŠธ์šฉ)

  echo "<Ingress-Public-IP> nginx.example.com apache.example.com" >> /etc/hosts
  

์ ‘์† ํ…Œ์ŠคํŠธ

  curl -H "Host: nginx.example.com" http://nginx.example.com/

curl -H "Host: apache.example.com" http://apache.example.com/
  

- TLS/HTTPS Ingress

1. TLS Secret ์ƒ์„ฑ

  # ์ž์ฒด ์„œ๋ช… ์ธ์ฆ์„œ ์ƒ์„ฑ
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
  -keyout tls.key -out tls.crt \
  -subj "/CN=vhost.example.com/O=example.com"

# Kubernetes Secret ์ƒ์„ฑ
kubectl create secret tls tls-secret --key tls.key --cert tls.crt
  

2. TLS Ingress ์ƒ์„ฑ

  apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: tls-ingress
spec:
  tls:
  - hosts:
    - vhost.example.com
    secretName: tls-secret
  rules:
  - host: example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: nginx-service
            port:
              number: 80
  

- [์—ฐ์Šต๋ฌธ์ œ] 5-3. Ingress ์‹ค์Šต

1. ๊ธฐ๋ณธ Ingress ์ƒ์„ฑ

์•„๋ž˜ ์กฐ๊ฑด์„ ๋งŒ์กฑํ•˜๋Š” Ingress๋ฅผ ์ƒ์„ฑํ•˜์„ธ์š”:

  • Ingress ์ด๋ฆ„: my-ingress
  • ํ˜ธ์ŠคํŠธ: myapp.local
  • ์„œ๋น„์Šค: nginx-service
  • ๊ฒฝ๋กœ: /

2. ๊ฒฝ๋กœ ๊ธฐ๋ฐ˜ ๋ผ์šฐํŒ… Ingress ์ƒ์„ฑ

์•„๋ž˜ ์กฐ๊ฑด์„ ๋งŒ์กฑํ•˜๋Š” Ingress๋ฅผ ์ƒ์„ฑํ•˜์„ธ์š”:

  • Ingress ์ด๋ฆ„: path-ingress
  • ํ˜ธ์ŠคํŠธ: example.com
  • /api ๊ฒฝ๋กœ โ†’ api-service
  • /web ๊ฒฝ๋กœ โ†’ web-service

3. Ingress ํ…Œ์ŠคํŠธ

์ƒ์„ฑ๋œ Ingress๋ฅผ ํ…Œ์ŠคํŠธํ•˜์„ธ์š”.

- Ingress Controller ์„ค์น˜ (ํ•„์š”์‹œ)

Nginx Ingress Controller ์„ค์น˜

  # Helm์„ ์‚ฌ์šฉํ•œ ์„ค์น˜
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm install ingress-nginx ingress-nginx/ingress-nginx

# ๋˜๋Š” kubectl์„ ์‚ฌ์šฉํ•œ ์„ค์น˜
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.8.2/deploy/static/provider/cloud/deploy.yaml
  

- ์ •๋ฆฌ

  # ๋ฆฌ์†Œ์Šค ์‚ญ์ œ
kubectl delete ingress my-ingress
kubectl delete ingress path-ingress
kubectl delete service nginx-service
kubectl delete deployment nginx-deployment
  

7. Headless Service

Headless Service๋Š” ClusterIP๊ฐ€ ์—†๋Š” ์„œ๋น„์Šค๋กœ, DNS ์กฐํšŒ ์‹œ ๋ชจ๋“  Pod์˜ IP ์ฃผ์†Œ๋ฅผ ์ง์ ‘ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

- Headless Service ์ƒ์„ฑ

  • StatefulSet ์ƒ์„ฑ (Headless Service์™€ ํ•จ๊ป˜ ์‚ฌ์šฉ)
  # nginx-sts.yml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: web
spec:
  serviceName: "nginx"
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
          name: web
  
  • Headless Service ์ƒ์„ฑ
  # headless-svc.yml
apiVersion: v1
kind: Service
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  ports:
  - port: 80
    name: web
  clusterIP: None
  selector:
    app: nginx
  

- Headless Service ํ…Œ์ŠคํŠธ

  • ๋ฆฌ์†Œ์Šค ์ƒ์„ฑ
  kubectl apply -f statefulset.yaml
kubectl apply -f headless-service.yaml
  
  • Pod ์ƒํƒœ ํ™•์ธ
  kubectl get po,svc
  
  • DNS ์กฐํšŒ ํ…Œ์ŠคํŠธ
  # ์ž„์‹œ Pod ์ƒ์„ฑํ•˜์—ฌ DNS ํ…Œ์ŠคํŠธ
kubectl run test-dns --image=busybox:1.28 --rm -it --restart=Never -- nslookup nginx

# ๋˜๋Š” ๋‹ค๋ฅธ ๋ฐฉ๋ฒ•
kubectl run test-dns --image=busybox:1.28 --rm -it --restart=Never -- sh
# nslookup nginx
# exit
  
  • ๊ฐœ๋ณ„ Pod DNS ์กฐํšŒ
  # ํŠน์ • Pod์˜ DNS ์ด๋ฆ„์œผ๋กœ ์กฐํšŒ
kubectl run test-dns --image=busybox:1.28 --rm -it --restart=Never -- nslookup web-0.nginx
kubectl run test-dns --image=busybox:1.28 --rm -it --restart=Never -- nslookup web-1.nginx
kubectl run test-dns --image=busybox:1.28 --rm -it --restart=Never -- nslookup web-2.nginx
  

- ์ผ๋ฐ˜ Service vs Headless Service ๋น„๊ต

  • ์ผ๋ฐ˜ Service ์ƒ์„ฑ (ClusterIP)
  # plain-svc.yml
apiVersion: v1
kind: Service
metadata:
  name: nginx-clusterip
spec:
  selector:
    app: nginx
  ports:
  - port: 80
    targetPort: 80
  

- DNS ์กฐํšŒ ๊ฒฐ๊ณผ ๋น„๊ต

  • ์ผ๋ฐ˜ Service DNS ์กฐํšŒ
  kubectl run test-dns --image=busybox:1.28 --rm -it --restart=Never -- nslookup nginx-clusterip
# ๊ฒฐ๊ณผ: ๋‹จ์ผ IP ์ฃผ์†Œ ๋ฐ˜ํ™˜ (Service์˜ ClusterIP)
  
  • Headless Service DNS ์กฐํšŒ
  kubectl run test-dns --image=busybox:1.28 --rm -it --restart=Never -- nslookup nginx-headless
# ๊ฒฐ๊ณผ: ๋ชจ๋“  Pod์˜ IP ์ฃผ์†Œ ๋ฐ˜ํ™˜
  

- [์—ฐ์Šต๋ฌธ์ œ] 5-2. Headless Service ์‹ค์Šต

1. Redis StatefulSet๊ณผ Headless Service ์ƒ์„ฑ

์•„๋ž˜ ์กฐ๊ฑด์„ ๋งŒ์กฑํ•˜๋Š” ๋ฆฌ์†Œ์Šค๋ฅผ ์ƒ์„ฑํ•˜์„ธ์š”:

  • StatefulSet ์ด๋ฆ„: redis-sts
  • Replica: 3๊ฐœ
  • ์ด๋ฏธ์ง€: redis:7.2
  • Headless Service ์ด๋ฆ„: redis-headless
  • ํฌํŠธ: 6379

2. DNS ์กฐํšŒ ํ…Œ์ŠคํŠธ

Headless Service์˜ DNS ์กฐํšŒ ๊ฒฐ๊ณผ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

3. Redis ํด๋ผ์ด์–ธํŠธ๋กœ ์—ฐ๊ฒฐ ํ…Œ์ŠคํŠธ

Headless Service๋ฅผ ํ†ตํ•ด Redis์— ์—ฐ๊ฒฐํ•ด๋ณด์„ธ์š”.

- Headless Service ์‚ฌ์šฉ ์‚ฌ๋ก€

  1. StatefulSet๊ณผ ํ•จ๊ป˜ ์‚ฌ์šฉ: ๊ฐ Pod๊ฐ€ ๊ณ ์œ ํ•œ ID๋ฅผ ๊ฐ€์ ธ์•ผ ํ•  ๋•Œ
  2. ์„œ๋น„์Šค ๋””์Šค์ปค๋ฒ„๋ฆฌ: ํด๋ผ์ด์–ธํŠธ๊ฐ€ ๋ชจ๋“  Pod์— ์ง์ ‘ ์—ฐ๊ฒฐํ•ด์•ผ ํ•  ๋•Œ
  3. ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ํด๋Ÿฌ์Šคํ„ฐ: ๊ฐ ๋…ธ๋“œ๊ฐ€ ๋‹ค๋ฅธ ๋…ธ๋“œ๋ฅผ ์ง์ ‘ ์•Œ์•„์•ผ ํ•  ๋•Œ
  4. ๋ฉ”์‹œ์ง• ์‹œ์Šคํ…œ: ๊ฐ ๋…ธ๋“œ๊ฐ€ ๋‹ค๋ฅธ ๋…ธ๋“œ์™€ ์ง์ ‘ ํ†ต์‹ ํ•ด์•ผ ํ•  ๋•Œ

- ์ •๋ฆฌ

  # ๋ฆฌ์†Œ์Šค ์‚ญ์ œ
kubectl delete statefulset redis-sts
kubectl delete service redis-headless
kubectl delete service nginx
kubectl delete statefulset web