您好,登錄后才能下訂單哦!
這篇文章主要介紹“kong在kubernetes中的安裝及使用方法”,在日常操作中,相信很多人在kong在kubernetes中的安裝及使用方法問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”kong在kubernetes中的安裝及使用方法”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
參考官方網站:
https://github.com/Kong/kubernetes-ingress-controller
https://github.com/Kong/charts
https://blog.csdn.net/qianghaohao/article/details/99691727
使用helm安裝
下載適合的helm example https://github.com/Kong/charts/tree/main/charts/kong/example-values
本次下載
wget https://raw.githubusercontent.com/Kong/charts/main/charts/kong/example-values/minimal-kong-standalone.yaml
-參考修改后配置 minimal-kong-standalone.yaml
image: repository: kong tag: "2.3" env: prefix: /kong_prefix/ database: postgres admin: enabled: true # 修改ClusterIP,外網不能訪問 type: ClusterIP http: enabled: true servicePort: 8001 containerPort: 8001 # 私有k8s。導出 NodePort proxy: type: NodePort http: nodePort: 30002 tls: nodePort: 30000 postgresql: enabled: true persistence: storageClass: rook-cephfs accessModes: - ReadWriteMany postgresqlUsername: kong postgresqlDatabase: kong # 固定密碼,不隨機 postgresqlPassword: Kong.=2021! postgresqlPostgresPassword: Kong.=2021! service: port: 5432 ingressController: enabled: true installCRDs: false
安裝kong
# 安裝到默認default空間 helm install kong kong/kong -f minimal-kong-standalone.yaml helm upgrade kong kong/kong -f minimal-kong-standalone.yaml
安裝konga。konga是UI庫,調用kong-admin來管理kong https://github.com/pantsel/konga
apiVersion: apps/v1 kind: Deployment metadata: name: konga labels: app: konga spec: replicas: 1 selector: matchLabels: app: konga template: metadata: labels: app: konga spec: containers: - env: - name: DB_ADAPTER value: postgres - name: DB_URI # kong-postgresql為service name value: "postgresql://kong:Kong.=2021!@kong-postgresql:5432/konga_database" image: pantsel/konga imagePullPolicy: Always name: konga ports: - containerPort: 1337 protocol: TCP restartPolicy: Always --- apiVersion: v1 kind: Service metadata: name: konga spec: ports: - name: http port: 1337 targetPort: 1337 protocol: TCP selector: app: konga --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: konga-ingress annotations: kubernetes.io/ingress.class: kong spec: rules: - host: konga.your_domain.com http: paths: - path: / pathType: ImplementationSpecific backend: service: name: konga port: number: 1337
konga運行后效果
kong的prometheus監控。首先在konga中啟用prometheus
安裝prometheus的ServiceMonitor。prometheus安裝參考 https://my.oschina.net/u/160697/blog/3197715
apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: prometheus-kong # 需固定release: prometheus。默認創建的prometheus使用此標簽來識別 labels: release: prometheus spec: # 不在同一命名空間,加上namespaceSelector namespaceSelector: matchNames: - default # 匹配的service的標簽 selector: matchLabels: app.kubernetes.io/name: kong endpoints: # service中對應的端口名稱 - port: kong-admin
到此,關于“kong在kubernetes中的安裝及使用方法”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。