Upgrade to Pro — share decks privately, control downloads, hide ads and more …

使用 Kong 與 GitOps 來管理您企業的 API 呼叫 @ 2024 台灣雲端大會

使用 Kong 與 GitOps 來管理您企業的 API 呼叫 @ 2024 台灣雲端大會

為避免直接 API 流量直接穿透系統,您可能想要做統一 API 管理
而 Kong 身為 API Gateway 剛好可以適用這個情境,可以做到 Authentication, Rate limiting, Monitoring 等等的功能

本議程將帶大家瞭解整個 Kong 建置的架構,以及 Declarative GitOps 的導入經驗分享

#kong #gitops #api gateway #api platform #docker #kubernetes #k8s
2024.07.03 @ iThome CloudSummit 台灣雲端大會

Avatar for Johnny Sung

Johnny Sung

July 03, 2024
Tweet

More Decks by Johnny Sung

Other Decks in Technology

Transcript

  1. Full stack developer Johnny Sung (宋岡諺) https://fb.com/j796160836 https://blog.jks.co ff ee/

    https://www.slideshare.net/j796160836 https://github.com/j796160836
  2. 大 綱 (2/2) •Kong 的服 用 方 式 •kong.yml 設定檔上

    手 •純 Docker 安裝 •搭配 Kubernetes •Kong 文 件沒寫清楚的地 方 2024 大
  3. 這邊使 用 Open Source 版本的 Kong 來舉例 Disclaimer 攝影師:Ihsan Adityawarman:

    https://www.pexels.com/zh-tw/photo/1056251/ 你也可以 用 其他類似功能的軟體來替代, 概念是類似相通的 我不是 Kong 的員 工 或協 力 廠商,我只是 一 個使 用 者做分享
  4. What is Kong? Kong API Gateway 是 一 款開源的 API

    管理平台, 用 於處理 大 規模的 API 流量。它 支 援多 種微服務架構,提供負載均衡、 日 誌記錄、認證和授權等功能。Kong 可以 高 效地管理 RESTful API 和服務之間的互動,並且可以輕鬆擴展以應對 高 流量需求。它 支 援插件擴 充,允許 用戶 根據特定需求客制功能,如安全性、監控和管理。它 支 援多種通訊協議,包 括 HTTP, HTTPS, gRPC, WebSocket 等,並且能夠輕鬆擴展以應對 大 規模的流量。 https://seeklogo.com/vector-logo/394595/kong
  5. What is GitOps? GitOps 是 一 種 用 於基礎架構和應 用

    配置管理的技術 方 法,透過 Git 作為版本控 制系統來 自 動化和管理。它使得部署和運維過程變得更加透明、可追蹤及可重 現。在 GitOps 的實踐中,所有的配置 文 件都存儲在 Git 倉庫中,這樣任何的 更改都必須通過 Git 的提交和審核流程。當配置 文 件被更新後, 自 動化的 工 具 會檢測到變更並將新配置應 用 到 生 產環境中,從 而 保證系統的持續性和 一 致 性。 https://foxutech.com/lets-understand-about-gitops/
  6. •版本控制和審計跟蹤:使 用 Git 作為單 一 資訊來源 (Single source of truth),

    確保所有變更都有記錄和可追溯。 •持續部署: 自 動化的部署流程減少 手 動錯誤,加快交付速度。 • 一 致性和標準化:確保環境之間的設置 一 致性,降低複雜性。 •增強安全:透過 Pull Request 和 Code Review 強化變更的安全性和合規性。 •易於回滾和錯誤恢復:如果部署失敗或是有問題,可以輕鬆回滾 (Rollback) 到先前的穩定版本。 GitOps 的優點
  7. •計劃與設計:定義 API 的 目 標和功能、 目 標 用戶 是誰、以及他們將如何存取。 設計

    API Endpoint點,並確定如何處理資料和認證。 •開發與測試:實際寫程式開發 API、整合與初步的功能測試。測試階段則需要 確保 API 在各種情況下都能正常運作,包括壓 力 測試、安全性測試和功能測 試。 •部署:將 API 部署到 Production 環境,這可能是 一 個雲端服務、或者地端伺 服器。在部署時,架構設計負載均衡與容錯機制,以確保 高 可 用 性 (High Availability) 和擴展性 (Scalability)。 API 的 生 命週期 (1/2)
  8. •版本管理:管理 API 版本是重要的,特別是當你需要導 入 破壞性變更時。提供 版本控制可以幫助 用戶 過渡到新版本,同時也 支 援舊版本。

    •淘汰:當 API 不再被需要或有更好的替代 方 案時,進 行 API 的淘汰。淘汰過程 應該提供 足 夠的過渡期給使 用 者,並清楚溝通淘汰的時間表和替代 方 案。 API 的 生 命週期 (2/2)
  9. 小 撇步💡 •新增 一 個帶有 DB 的 Kong,使 用 GUI

    介 面 操作 •使 用 decK 指令匯出設定檔 docker run --rm kong/deck:v1.34.0 gateway dump \ --kong-addr http://192.168.1.3:8001/ > kong.yaml
  10. kong.yml _format_version: "3.0" services: - name: my-web-service enabled: true protocol:

    http host: my-web-service.myapp.svc.cluster.local path: / port: 80 retries: 5 connect_timeout: 60000 read_timeout: 60000 write_timeout: 60000 routes: - name: my-web-route protocols: - http - https paths: - /my-web path_handling: v0 https_redirect_status_code: 426 preserve_host: true regex_priority: 0 request_buffering: false response_buffering: false strip_path: true [
  11. kong.yml _format_version: "3.0" services: - name: my-web-service enabled: true protocol:

    http host: my-web-service.myapp.svc.cluster.local path: / port: 80 retries: 5 connect_timeout: 60000 read_timeout: 60000 write_timeout: 60000 routes: - name: my-web-route protocols: - http - https paths: - /my-web path_handling: v0 https_redirect_status_code: 426 preserve_host: true regex_priority: 0 request_buffering: false response_buffering: false strip_path: true [ kong.yml _format_version: "3.0" services: - name: my-web-service enabled: true protocol: http host: my-web-service.myapp.svc.cluster.local path: / port: 80 retries: 5 connect_timeout: 60000 read_timeout: 60000 write_timeout: 60000 routes: - name: my-web-route protocols: - http - https paths: - /my-web path_handling: v0 https_redirect_status_code: 426 preserve_host: true regex_priority: 0 request_buffering: false response_buffering: false strip_path: true
  12. kong.yml _format_version: "3.0" services: - name: my-web-service enabled: true protocol:

    http host: my-web-service.myapp.svc.cluster.local path: / port: 80 retries: 5 connect_timeout: 60000 read_timeout: 60000 write_timeout: 60000 routes: - name: my-web-route protocols: - http - https paths: - /my-web path_handling: v0 https_redirect_status_code: 426 preserve_host: true regex_priority: 0 request_buffering: false response_buffering: false strip_path: true kong.yml _format_version: "3.0" services: - name: my-web-service enabled: true protocol: http host: my-web-service.myapp.svc.cluster.local path: / port: 80 retries: 5 connect_timeout: 60000 read_timeout: 60000 write_timeout: 60000 routes: - name: my-web-route protocols: - http - https paths: - /my-web path_handling: v0 https_redirect_status_code: 426 preserve_host: true regex_priority: 0 request_buffering: false response_buffering: false strip_path: true
  13. kong.yml _format_version: "3.0" services: - name: my-web-service enabled: true protocol:

    http host: my-web-service.myapp.svc.cluster.local path: / port: 80 retries: 5 connect_timeout: 60000 read_timeout: 60000 write_timeout: 60000 routes: - name: my-web-route protocols: - http - https paths: - /my-web path_handling: v0 https_redirect_status_code: 426 preserve_host: true regex_priority: 0 request_buffering: false response_buffering: false strip_path: true kong.yml _format_version: "3.0" services: - name: my-web-service enabled: true protocol: http host: my-web-service.myapp.svc.cluster.local path: / port: 80 retries: 5 connect_timeout: 60000 read_timeout: 60000 write_timeout: 60000 routes: - name: my-web-route protocols: - http - https paths: - /my-web path_handling: v0 https_redirect_status_code: 426 preserve_host: true regex_priority: 0 request_buffering: false response_buffering: false strip_path: true [ [ ]
  14. in

  15. Created by Alice Design from the Noun Project PROD UAT

    https://thenounproject.com/icon/user-1994976/ https://www.svgrepo.com/svg/353929/jenkins https://en.wikiversity.org/wiki/Version_Control/Git https://en.m.wikipedia.org/wiki/File:Ansible_logo.svg Kong in Docker 架構 Commit Webhook Deploy Deploy
  16. 實驗環境 •Git repository — Gitea •Environment— Docker VM •CI/CD pipeline

    tool — Jenkins & Ansible •Image Registry — Harbor
  17. version: '3.9' services: kong: image: "${KONG_DOCKER_TAG:-kong:latest}" restart: always environment: KONG_DATABASE:

    off KONG_ADMIN_ACCESS_LOG: /dev/stdout KONG_ADMIN_ERROR_LOG: /dev/stderr KONG_PROXY_LISTEN: "${KONG_PROXY_LISTEN:-0.0.0.0:8000}" KONG_ADMIN_LISTEN: "${KONG_ADMIN_LISTEN:-0.0.0.0:8001}" KONG_ADMIN_GUI_LISTEN: "${KONG_ADMIN_GUI_LISTEN:-0.0.0.0:8002}" KONG_PROXY_ACCESS_LOG: /dev/stdout KONG_PROXY_ERROR_LOG: /dev/stderr KONG_PREFIX: ${KONG_PREFIX:-/var/run/kong} KONG_DECLARATIVE_CONFIG: "/opt/kong/kong.yaml" KONG_ADMIN_GUI_URL: http://host.docker.internal:8012 KONG_ADMIN_GUI_API_URL: http://host.docker.internal:8011 ports: - "${KONG_INBOUND_PROXY_LISTEN:-0.0.0.0}:8000:8000/tcp" - "8001:8001/tcp" - "8002:8002/tcp" volumes: - ./kong.yaml:/opt/kong/kong.yaml security_opt: - no-new-privileges https://docs.konghq.com/gateway/latest/production/deployment-topologies/db-less-and-declarative-con fi g/ Kong in DB-less mode (via docker compose) 設定重點 •image 位置(如果是 private registry) •環境變數設定 •設定 kong.yml 路徑 KONG_DATABASE: off docker-compose.yml
  18. in

  19. Created by Alice Design from the Noun Project PROD UAT

    https://thenounproject.com/icon/user-1994976/ https://www.svgrepo.com/svg/353929/jenkins https://en.wikiversity.org/wiki/Version_Control/Git https://en.m.wikipedia.org/wiki/File:Ansible_logo.svg https://www.opsmx.com/what-is-argocd/ Kong in Kubernates 架構 Commit Monitoring Deploy Deploy
  20. 小 撇步💡 •在 Kubernetes 中,可以善 用 K8s 自 帶的 DNS

    路徑, 快速找到對應的 Service my-web-service.myapp.svc.cluster.local (Service 名稱) (Namespace 名稱)
  21. 實驗環境 •Git repository — Gitea •Environment— 純地端 Kubernetes (K8s) (開三台

    Ubuntu 22.04.1 VM 使 用 kubeadm 安裝) •CI/CD pipeline tool — Jenkins •Image Registry — Harbor •GitOps tool — ArgoCD 當然你 用 雲端也可以
  22. ArgoCD 是 一 個開源的 Kubernetes 原 生 持續交付 工 具,專注於

    GitOps 自 動化 部署。它利 用 Git 儲存庫作為應 用 配置的「單 一 資訊來源 (Single source of truth)」, 自 動檢測配置變更並將其同步到指定的 Kubernetes 集群中。 ArgoCD 支 援多種配置管理 工 具,包括 Helm、Kustomize 和 Jsonnet,並提 供視覺化界 面 便於監控應 用 部署狀態和健康狀況。這使得開發者和 維運團隊能夠有效地實現持續部署和管理。 ArgoCD - 在 K8s 實現 GitOps 的幕後功 臣 https://www.opsmx.com/what-is-argocd/
  23. Kustomize Kustomize 是 一 個 Kubernetes 的配置管理 工 具,可以透過定制資源的配置來 簡化

    Kubernetes 的部署。它專注於以聲明式 方 式修改和管理 Kubernetes manifest 檔案,不需要動態 生 成配置。使 用 者可以建 立 基礎配置的 "基底", 然後在不同環境(如開發、測試和 生 產)中進 行 客製化覆蓋。Kustomize 允許 合併或替換 YAML 檔案的部分,使得配置更加模組化和可重 用 。它現在是 Kubernetes 的 一 部分,可以直接透過 kubectl 命令 行工 具使 用 。 https://zlaval.medium.com/kustomize-template-free-kubernetes-application-management-3d70ca9d2e05
  24. Helm Helm 是 一 個 用 於 Kubernetes 的套件管理 工

    具,允許開發者和運維團隊打包、 配置和部署服務。Helm 使 用 稱為 "Charts" 的配置 文 件來描述 一 組相關的 Kubernetes 資源,這些資源可以預先配置並重複使 用 。透過 Helm, 用 戶 可以輕 鬆地安裝、升級和管理 Kubernetes 應 用 ,並 支 援版本控制和回滾功能,使得部 署和維護變得更加 方 便和有效。 https://helm.sh/
  25. Created by Mas Mirza from Noun Project values.yml • deployment.yml

    • services.yml • rbac.yml • config-map.yml • …. Helm 檔案架構 https://thenounproject.com/icon/ fi le-6897025/ https://thenounproject.com/icon/puzzle-6850847/
  26. Helm 相關指令 helm show values kong/kong > kong-values.yaml helm repo

    add kong https://charts.konghq.com 加 入 helm repo 取得預設 values.yaml 參數 安裝 kong helm install kong kong/kong -n kong-dbless -f kong-values.yaml
  27. 小 撇步💡 •你可以利 用 helm template 輸出原始 yaml 設定檔做 比

    對 helm template kong kong/kong -n kong-dbless -f kong-values.yaml --output-dir ./kong-yamls
  28. apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: kong-dbless-config namespace: argocd spec:

    project: default source: repoURL: 'ssh://[email protected]/kustomize.git' path: kong-config-dbless targetRevision: HEAD destination: name: '' server: 'https://kubernetes.default.svc' namespace: kong-dbless sources: [] syncPolicy: automated: prune: true selfHeal: true syncOptions: - CreateNamespace=true argocd-application.yaml kong-config-dbless ├── kong.yml └── kustomization.yaml 資料夾結構 ArgoCD 設定 Kong 設定檔專案
  29. kong.yml _format_version: "3.0" services: - name: my-web-service enabled: true host:

    my-web-service.myapp.svc.cluster.local path: / port: 80 protocol: http connect_timeout: 60000 read_timeout: 60000 write_timeout: 60000 retries: 5 routes: - name: my-web-route https_redirect_status_code: 426 path_handling: v0 paths: - /my-web preserve_host: true protocols: - http - https regex_priority: 0 request_buffering: false response_buffering: false strip_path: true apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization configMapGenerator: - name: kong-config files: - kong.yml generatorOptions: disableNameSuffixHash: true kustomization.yaml 使 用 con fi gMapGenerator 收納 kong.yml 到 Con fi gMap
  30. apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: kong-dbless namespace: argocd spec:

    project: default source: repoURL: 'ssh://[email protected]/kustomize.git' path: helm-kong targetRevision: HEAD helm: valueFiles: - kong-values.yml destination: name: '' namespace: kong-dbless server: 'https://kubernetes.default.svc' sources: [] syncPolicy: automated: prune: true selfHeal: true syncOptions: - CreateNamespace=true argocd-application.yaml helm-kong ├── Chart.yaml └── kong-values.yml 資料夾結構 ArgoCD 設定 Kong helm 專案
  31. 這邊有 一 個重點 使 用 dependency charts 使 用一 個

    自 訂的名字把 values 給包起來 https://akuity.io/blog/argo-cd-helm-values- fi les/ apiVersion: v2 name: kong description: kong type: application version: 1.0.0 appVersion: '1.0' dependencies: - name: kong repository: https://charts.konghq.com version: 2.34.0 Chart.yaml kong-values.yml kong: # Default values for Kong's Helm Chart. # Declare variables to be passed into your templates. # # Sections: # - Deployment parameters # - Kong parameters # - Ingress Controller parameters # - Postgres sub-chart parameters # - Miscellaneous parameters # - Kong Enterprise parameters # ----------------------------------------------------------------------------- # Deployment parameters # ----------------------------------------------------------------------------- deployment: kong: # Enable or disable Kong itself # Setting this to false with ingressController.enabled=true will create a # controller-only release. enabled: true ## Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, ## for it to be considered available. # minReadySeconds: 60 ## Specify the service account to create and to be assigned to the deployment / daemonset and for the migrations serviceAccount: create: true # Automount the service account token. By default, this is disabled, and the token is only mounted on the controller # container. Some sidecars require enabling this. Note that enabling this exposes Kubernetes credentials to Kong # Lua code, increasing potential attack surface. automountServiceAccountToken: false ## Optionally specify the name of the service account to create and the annotations to add. # name: # annotations: {} ## Optionally specify any extra sidecar containers to be included in the deployment ## See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#container-v1-core # sidecarContainers: # - name: sidecar # image: sidecar:latest # initContainers: # - name: initcon # image: initcon:latest # hostAliases: # - ip: "127.0.0.1" # hostnames: # - "foo.local" # - "bar.local" …(略) ⚠ 注意縮排 values.yml
  32. image: repository: kong/kong tag: "3.5" pullPolicy: IfNotPresent 如果有 private registry

    可以在此設定 Kong in DB-less mode (kong-values.yml) values.yml
  33. # Specify Kong proxy service configuration proxy: enabled: true type:

    NodePort loadBalancerClass: nameOverride: "" annotations: {} labels: enable-metrics: "true" http: enabled: true servicePort: 80 containerPort: 8000 nodePort: 30080 parameters: [] tls: enabled: false servicePort: 443 containerPort: 8443 nodePort: 32443 parameters: - http2 設定 proxy 服務連接埠 (假設為 30080 NodePort) Kong in DB-less mode (kong-values.yml) values.yml
  34. 設定 Admin API 連接埠 (假設為 30071 NodePort) admin: enabled: true

    type: NodePort http: enabled: true servicePort: 8001 containerPort: 8001 nodePort: 32071 parameters: [] tls: enabled: false servicePort: 8444 containerPort: 8444 設定管理後台 (WebGUI) 連接埠 (假設為 30072 NodePort) manager: enabled: true type: NodePort loadBalancerClass: annotations: {} labels: {} http: enabled: true servicePort: 8002 containerPort: 8002 nodePort: 32072 parameters: [] tls: enabled: false servicePort: 8445 containerPort: 8445 parameters: - http2 Kong in DB-less mode (kong-values.yml) values.yml
  35. ## Define any volumes and mounts you want present in

    the Kong proxy container userDefinedVolumes: - name: "kong-config-vol" configMap: name: "kong-config" userDefinedVolumeMounts: - name: "kong-config-vol" mountPath: "/opt/kong/config" env: database: "off" declarative_config: /opt/kong/config/kong.yml apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization configMapGenerator: - name: kong-config files: - kong.yml generatorOptions: disableNameSuffixHash: true kustomization.yaml 這裏就是 文 件沒寫清楚的地 方 🧐 設定將(裡 面 有 kong.yml 的)Con fi gMap 掛載起來 設定環境變數, 設定 kong.yml 的位置 Kong in DB-less mode (kong-values.yml) values.yml
  36. 現在有 一 個問題 如何監控 Con fi g 變動 當 Con

    fi g 一 有變動,就更新部署 Kong?
  37. kind: Deployment metadata: annotations: reloader.stakater.com/auto: "true" spec: template: metadata: 照著

    文 件將它 Deploy 使 用 annotations 指定 con fi gMap 名稱就可以做到監聽! 接下來就是把它塞 入 Kong 的 helm chart values 中,加 入 Custom Annotations 部署 Reloader
  38. https://artifacthub.io/packages/helm/kong/kong?modal=template&template=deployment.yaml --- # Source: kong/templates/deployment.yaml apiVersion: apps/v1 kind: Deployment metadata:

    name: kong-dbless-kong namespace: default labels: app.kubernetes.io/name: kong helm.sh/chart: kong-2.35.1 app.kubernetes.io/instance: "kong-dbless" app.kubernetes.io/managed-by: "Helm" app.kubernetes.io/version: "3.5" app.kubernetes.io/component: app annotations: configmap.reloader.stakater.com/reload: "kong-config" # Annotations to be added to Kong deployment deploymentAnnotations: configmap.reloader.stakater.com/reload: "kong-config" 加 入 reloader 的 Custom Annotations,綁定重啟條件 測試 yaml 輸出結果
  39. 幾乎開箱即 用 的 Prometheus plugins plugins: - instance_name: prometheus name:

    prometheus enabled: true protocols: - grpc - grpcs - http - https config: bandwidth_metrics: true latency_metrics: true per_consumer: true status_code_metrics: true upstream_health_metrics: true •打開全域的 Prometheus plugins
  40. 幾乎開箱即 用 的 Prometheus plugins •打開全域的 Prometheus plugins •在 Kong

    API Endpoint 就可以看到 Metrics 了 # HELP kong_bandwidth_bytes Total bandwidth (ingress/egress) throughput in bytes # TYPE kong_bandwidth_bytes counter kong_bandwidth_bytes{service="example",route="example-route",direction="egress",consumer=""} 546 kong_bandwidth_bytes{service="example",route="example-route",direction="ingress",consumer=""} 2461 kong_bandwidth_bytes{service="example.com",route="example-route",direction="egress",consumer=""} 2448 kong_bandwidth_bytes{service="example.com",route="example-route",direction="ingress",consumer=""} 7461 # HELP kong_datastore_reachable Datastore reachable from Kong, 0 is unreachable # TYPE kong_datastore_reachable gauge kong_datastore_reachable 1 # HELP kong_http_requests_total HTTP status codes per consumer/service/route in Kong # TYPE kong_http_requests_total counter kong_http_requests_total{service="example",route="example-route",code="502",source="kong",consumer=""} 1 kong_http_requests_total{service="example.com",route="example-route",code="200",source="service",consumer=""} 1 kong_http_requests_total{service="example.com",route="example-route",code="404",source="service",consumer=""} 2 # HELP kong_kong_latency_ms Latency added by Kong and enabled plugins for each service/route in Kong # TYPE kong_kong_latency_ms histogram kong_kong_latency_ms_bucket{service="example",route="example-route",le="+Inf"} 1 kong_kong_latency_ms_bucket{service="example.com",route="example-route",le="15"} 1 kong_kong_latency_ms_bucket{service="example.com",route="example-route",le="20"} 1 kong_kong_latency_ms_bucket{service="example.com",route="example-route",le="30"} 2 kong_kong_latency_ms_bucket{service="example.com",route="example-route",le="50"} 2 kong_kong_latency_ms_bucket{service="example.com",route="example-route",le="75"} 2 kong_kong_latency_ms_bucket{service="example.com",route="example-route",le="100"} 2 kong_kong_latency_ms_bucket{service="example.com",route="example-route",le="200"} 2 kong_kong_latency_ms_bucket{service="example.com",route="example-route",le="500"} 3 kong_kong_latency_ms_bucket{service="example.com",route="example-route",le="750"} 3 kong_kong_latency_ms_bucket{service="example.com",route="example-route",le="1000"} 3 kong_kong_latency_ms_bucket{service="example.com",route="example-route",le="+Inf"} 3 kong_kong_latency_ms_count{service="example",route="example-route"} 1 kong_kong_latency_ms_count{service="example.com",route="example-route"} 3 kong_kong_latency_ms_sum{service="example",route="example-route"} 11977 kong_kong_latency_ms_sum{service="example.com",route="example-route"} 532 # HELP kong_memory_lua_shared_dict_bytes Allocated slabs in bytes in a shared_dict # TYPE kong_memory_lua_shared_dict_bytes gauge kong_memory_lua_shared_dict_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",shared_dict="kong",kong_subsystem="http"} 45056 kong_memory_lua_shared_dict_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",shared_dict="kong_cluster_events",kong_subsystem="h kong_memory_lua_shared_dict_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",shared_dict="kong_core_db_cache",kong_subsystem="ht kong_memory_lua_shared_dict_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",shared_dict="kong_core_db_cache_miss",kong_subsyste kong_memory_lua_shared_dict_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",shared_dict="kong_db_cache",kong_subsystem="http"} kong_memory_lua_shared_dict_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",shared_dict="kong_db_cache_miss",kong_subsystem="ht kong_memory_lua_shared_dict_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",shared_dict="kong_healthchecks",kong_subsystem="htt kong_memory_lua_shared_dict_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",shared_dict="kong_locks",kong_subsystem="http"} 614 kong_memory_lua_shared_dict_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",shared_dict="kong_rate_limiting_counters",kong_subs kong_memory_lua_shared_dict_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",shared_dict="kong_secrets",kong_subsystem="http"} 4 kong_memory_lua_shared_dict_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",shared_dict="prometheus_metrics",kong_subsystem="ht # HELP kong_memory_lua_shared_dict_total_bytes Total capacity in bytes of a shared_dict # TYPE kong_memory_lua_shared_dict_total_bytes gauge kong_memory_lua_shared_dict_total_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",shared_dict="kong",kong_subsystem="http"} 524 kong_memory_lua_shared_dict_total_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",shared_dict="kong_cluster_events",kong_subsys kong_memory_lua_shared_dict_total_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",shared_dict="kong_core_db_cache",kong_subsyst kong_memory_lua_shared_dict_total_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",shared_dict="kong_core_db_cache_miss",kong_su kong_memory_lua_shared_dict_total_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",shared_dict="kong_db_cache",kong_subsystem="h kong_memory_lua_shared_dict_total_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",shared_dict="kong_db_cache_miss",kong_subsyst kong_memory_lua_shared_dict_total_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",shared_dict="kong_healthchecks",kong_subsyste kong_memory_lua_shared_dict_total_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",shared_dict="kong_locks",kong_subsystem="http kong_memory_lua_shared_dict_total_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",shared_dict="kong_rate_limiting_counters",kon kong_memory_lua_shared_dict_total_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",shared_dict="kong_secrets",kong_subsystem="ht kong_memory_lua_shared_dict_total_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",shared_dict="prometheus_metrics",kong_subsyst # HELP kong_memory_workers_lua_vms_bytes Allocated bytes in worker Lua VM # TYPE kong_memory_workers_lua_vms_bytes gauge kong_memory_workers_lua_vms_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",pid="1323",kong_subsystem="http"} 48452110 kong_memory_workers_lua_vms_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",pid="1324",kong_subsystem="http"} 47971632 kong_memory_workers_lua_vms_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",pid="1325",kong_subsystem="http"} 47971628 kong_memory_workers_lua_vms_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",pid="1326",kong_subsystem="http"} 47971632 kong_memory_workers_lua_vms_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",pid="1327",kong_subsystem="http"} 47971560 kong_memory_workers_lua_vms_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",pid="1328",kong_subsystem="http"} 84856372 kong_memory_workers_lua_vms_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",pid="1329",kong_subsystem="http"} 47971632 kong_memory_workers_lua_vms_bytes{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",pid="1330",kong_subsystem="http"} 47971632 # HELP kong_nginx_connections_total Number of connections by subsystem # TYPE kong_nginx_connections_total gauge kong_nginx_connections_total{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",subsystem="http",state="accepted"} 258 kong_nginx_connections_total{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",subsystem="http",state="active"} 9 kong_nginx_connections_total{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",subsystem="http",state="handled"} 258 kong_nginx_connections_total{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",subsystem="http",state="reading"} 0 kong_nginx_connections_total{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",subsystem="http",state="total"} 325 kong_nginx_connections_total{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",subsystem="http",state="waiting"} 0 kong_nginx_connections_total{node_id="10e43c5c-8c63-485f-84a3-4ad97e047f1e",subsystem="http",state="writing"} 9 http://192.168.1.10:8001/metrics
  41. 幾乎開箱即 用 的 Prometheus plugins •設定 Prometheus 收集它 •加 入

    Kong 官 方 的 Grafana 面 板 https://grafana.com/grafana/dashboards/7424-kong-o ff i cial/
  42. 快速回顧 •瞭解 Kong API Gateway 的功 用 •瞭解 GitOps 重要性,應

    用 在 工 作流程中 •Kong 各種花式部署 方 式 2024 大
  43. 小 撇步整理 •使 用 ArtifactHUB 偷看 一 下 Helm Charts

    裡 面 的模板內容 •使 用 helm template 輸出原始 yaml 設定檔做 比 對 •使 用 Kong 自 帶的 decK 指令匯出設定檔 2024 大