๐ŸŽ† ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค Services [๋…ธ๋“œํฌํŠธ, ๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ]

๊น€์„ฑ์ธยท2023๋…„ 10์›” 13์ผ
0

[DevOps] ๐ŸณDocker & Kubernetes

๋ชฉ๋ก ๋ณด๊ธฐ
27/62

๋…ธ๋“œํฌํŠธ

https://kubernetes.io/ko/docs/concepts/services-networking/service/#type-nodeport

  • ์„œ๋น„์Šค yamlํŒŒ์ผ๋กœ ์ž‘์„ฑ
  • 30000~32767 ํฌํŠธ๋งŒ ์‚ฌ์šฉ ๊ฐ€๋Šฅ
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: NodePort
  selector:
    app.kubernetes.io/name: MyApp
  ports:
      # ๊ธฐ๋ณธ์ ์œผ๋กœ ๊ทธ๋ฆฌ๊ณ  ํŽธ์˜์ƒ `targetPort` ๋Š” `port` ํ•„๋“œ์™€ ๋™์ผํ•œ ๊ฐ’์œผ๋กœ ์„ค์ •๋œ๋‹ค.
    - port: 80 # ์„œ๋น„์Šค์˜ ํฌํŠธ (๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ๊ฐ€ ๋ฐ”๋กœ ๋ณด๋Š” ํฌํŠธ?)
      targetPort: 80 # ํฌ๋“œ์˜ ํฌํŠธ
      # ์„ ํƒ์  ํ•„๋“œ
      # ๊ธฐ๋ณธ์ ์œผ๋กœ ๊ทธ๋ฆฌ๊ณ  ํŽธ์˜์ƒ ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ์ปจํŠธ๋กค ํ”Œ๋ ˆ์ธ์€ ํฌํŠธ ๋ฒ”์œ„์—์„œ ํ• ๋‹นํ•œ๋‹ค(๊ธฐ๋ณธ๊ฐ’: 30000-32767)
      nodePort: 30007

gcloud compute firewall-rules create http-go-svc-rule --allow=tcp:30001 : gcp ๋ฐฉํ™”๋ฒฝ ๋ฃฐ ์ถ”๊ฐ€


๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ

apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  selector:
    app.kubernetes.io/name: MyApp
  ports:
    - protocol: TCP
      port: 80
      targetPort: 9376
  clusterIP: 10.0.171.239
  type: LoadBalancer
status:
  loadBalancer:
    ingress:
    - ip: 192.0.2.127
profile
๊ฐœ๋ฐœ์ž๊ฐ€ ๊ฟˆ์ธ 25์‚ด ๋Œ€ํ•™์ƒ์ž…๋‹ˆ๋‹ค.

0๊ฐœ์˜ ๋Œ“๊ธ€