您好,登录后才能下订单哦!
这篇文章主要介绍“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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。