Information in this document may be out of date

This document has an older update date than the original, so the information it contains may be out of date. If you're able to read English, see the English version for the most up-to-date information: Use an HTTP Proxy to Access the Kubernetes API

HTTP ํ”„๋ก์‹œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค API์— ์ ‘๊ทผ

์ด ํŽ˜์ด์ง€๋Š” ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค API์— ์ ‘๊ทผํ•˜๊ธฐ ์œ„ํ•ด HTTP ํ”„๋ก์‹œ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•œ๋‹ค.

์‹œ์ž‘ํ•˜๊ธฐ ์ „์—

์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ํด๋Ÿฌ์Šคํ„ฐ๊ฐ€ ํ•„์š”ํ•˜๊ณ , kubectl ์ปค๋งจ๋“œ-๋ผ์ธ ํˆด์ด ํด๋Ÿฌ์Šคํ„ฐ์™€ ํ†ต์‹ ํ•  ์ˆ˜ ์žˆ๋„๋ก ์„ค์ •๋˜์–ด ์žˆ์–ด์•ผ ํ•œ๋‹ค. ์ด ํŠœํ† ๋ฆฌ์–ผ์€ ์ปจํŠธ๋กค ํ”Œ๋ ˆ์ธ ํ˜ธ์ŠคํŠธ๊ฐ€ ์•„๋‹Œ ๋…ธ๋“œ๊ฐ€ ์ ์–ด๋„ 2๊ฐœ ํฌํ•จ๋œ ํด๋Ÿฌ์Šคํ„ฐ์—์„œ ์‹คํ–‰ํ•˜๋Š” ๊ฒƒ์„ ์ถ”์ฒœํ•œ๋‹ค. ๋งŒ์•ฝ, ์•„์ง ํด๋Ÿฌ์Šคํ„ฐ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์ง€ ์•Š๋‹ค๋ฉด, minikube๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์ƒ์„ฑํ•˜๊ฑฐ๋‚˜ ๋‹ค์Œ ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ํ”Œ๋ ˆ์ด๊ทธ๋ผ์šด๋“œ ์ค‘ ํ•˜๋‚˜๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

๋ฒ„์ „ ํ™•์ธ์„ ์œ„ํ•ด์„œ, ๋‹ค์Œ ์ปค๋งจ๋“œ๋ฅผ ์‹คํ–‰ kubectl version.

ํด๋Ÿฌ์Šคํ„ฐ์—์„œ ์‹คํ–‰ ์ค‘์ธ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์—†๋‹ค๋ฉด, ์•„๋ž˜ ๋ช…๋ น์„ ์ž…๋ ฅํ•˜์—ฌ Hello world ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์‹œ์ž‘ํ•œ๋‹ค.

kubectl create deployment node-hello --image=gcr.io/google-samples/node-hello:1.0 --port=8080

kubectl์„ ์‚ฌ์šฉํ•˜์—ฌ ํ”„๋ก์‹œ ์„œ๋ฒ„ ์‹œ์ž‘

์•„๋ž˜ ์ปค๋งจ๋“œ๋Š” ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค API ์„œ๋ฒ„์˜ ํ”„๋ก์‹œ๋ฅผ ์‹œ์ž‘ํ•œ๋‹ค.

kubectl proxy --port=8080

Kubernetes API ํƒ์ƒ‰

ํ”„๋ก์‹œ ์„œ๋ฒ„๊ฐ€ ์‹คํ–‰ ์ค‘์ผ ๋•Œ curl, wget ๋˜๋Š” ๋ธŒ๋ผ์šฐ์ €๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ API๋ฅผ ํƒ์ƒ‰ํ•  ์ˆ˜ ์žˆ๋‹ค.

API ๋ฒ„์ „ ๊ฐ€์ ธ์˜ค๊ธฐ.

curl http://localhost:8080/api/

์ถœ๋ ฅ์€ ๋‹ค์Œ๊ณผ ์œ ์‚ฌํ•˜๋‹ค.

{
  "kind": "APIVersions",
  "versions": [
    "v1"
  ],
  "serverAddressByClientCIDRs": [
    {
      "clientCIDR": "0.0.0.0/0",
      "serverAddress": "10.0.2.15:8443"
    }
  ]
}

ํŒŒ๋“œ ๋ชฉ๋ก ๊ฐ€์ ธ์˜ค๊ธฐ.

curl http://localhost:8080/api/v1/namespaces/default/pods

์ถœ๋ ฅ์€ ๋‹ค์Œ๊ณผ ์œ ์‚ฌํ•˜๋‹ค.

{
  "kind": "PodList",
  "apiVersion": "v1",
  "metadata": {
    "resourceVersion": "33074"
  },
  "items": [
    {
      "metadata": {
        "name": "kubernetes-bootcamp-2321272333-ix8pt",
        "generateName": "kubernetes-bootcamp-2321272333-",
        "namespace": "default",
        "uid": "ba21457c-6b1d-11e6-85f7-1ef9f1dab92b",
        "resourceVersion": "33003",
        "creationTimestamp": "2016-08-25T23:43:30Z",
        "labels": {
          "pod-template-hash": "2321272333",
          "run": "kubernetes-bootcamp"
        },
        ...
}

๋‹ค์Œ ๋‚ด์šฉ

kubectl ํ”„๋ก์‹œ์— ๋Œ€ํ•ด ๋” ๋ฐฐ์šฐ๊ธฐ.

์ตœ์ข… ์ˆ˜์ • September 02, 2022 at 1:20 AM PST: Translate http-proxy-access-api into Korean (5af3408bf1)