新ingress-kong安装(ingress-kong konga postgres)

news/2024/10/25 20:22:10/

Kong是一款基于OpenResty(Nginx + Lua模块)编写的高可用、易扩展的,由Mashape公司开源的API Gateway项目。Kong是基于NGINX和Apache Cassandra或PostgreSQL构建的

在k8s集群内部创建kong网关

kong-ingress.yaml

apiVersion: v1
kind: Namespace
metadata:name: kong
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:name: kongclusterplugins.configuration.konghq.com
spec:additionalPrinterColumns:- JSONPath: .plugindescription: Name of the pluginname: Plugin-Typetype: string- JSONPath: .metadata.creationTimestampdescription: Agename: Agetype: date- JSONPath: .disableddescription: Indicates if the plugin is disabledname: Disabledpriority: 1type: boolean- JSONPath: .configdescription: Configuration of the pluginname: Configpriority: 1type: stringgroup: configuration.konghq.comnames:kind: KongClusterPluginplural: kongclusterpluginsshortNames:- kcpscope: Clustersubresources:status: {}validation:openAPIV3Schema:properties:config:type: objectconfigFrom:properties:secretKeyRef:properties:key:type: stringname:type: stringnamespace:type: stringrequired:- name- namespace- keytype: objecttype: objectdisabled:type: booleanplugin:type: stringprotocols:items:enum:- http- https- grpc- grpcs- tcp- tlstype: stringtype: arrayrun_on:enum:- first- second- alltype: stringrequired:- pluginversion: v1
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:name: kongconsumers.configuration.konghq.com
spec:additionalPrinterColumns:- JSONPath: .usernamedescription: Username of a Kong Consumername: Usernametype: string- JSONPath: .metadata.creationTimestampdescription: Agename: Agetype: dategroup: configuration.konghq.comnames:kind: KongConsumerplural: kongconsumersshortNames:- kcscope: Namespacedsubresources:status: {}validation:openAPIV3Schema:properties:credentials:items:type: stringtype: arraycustom_id:type: stringusername:type: stringversion: v1
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:name: kongingresses.configuration.konghq.com
spec:group: configuration.konghq.comnames:kind: KongIngressplural: kongingressesshortNames:- kiscope: Namespacedsubresources:status: {}validation:openAPIV3Schema:properties:proxy:properties:connect_timeout:minimum: 0type: integerpath:pattern: ^/.*$type: stringprotocol:enum:- http- https- grpc- grpcs- tcp- tlstype: stringread_timeout:minimum: 0type: integerretries:minimum: 0type: integerwrite_timeout:minimum: 0type: integertype: objectroute:properties:headers:additionalProperties:items:type: stringtype: arraytype: objecthttps_redirect_status_code:type: integermethods:items:type: stringtype: arraypath_handling:enum:- v0- v1type: stringpreserve_host:type: booleanprotocols:items:enum:- http- https- grpc- grpcs- tcp- tlstype: stringtype: arrayregex_priority:type: integerrequest_buffering:type: booleanresponse_buffering:type: booleansnis:items:type: stringtype: arraystrip_path:type: booleanupstream:properties:algorithm:enum:- round-robin- consistent-hashing- least-connectionstype: stringhash_fallback:type: stringhash_fallback_header:type: stringhash_on:type: stringhash_on_cookie:type: stringhash_on_cookie_path:type: stringhash_on_header:type: stringhealthchecks:properties:active:properties:concurrency:minimum: 1type: integerhealthy:properties:http_statuses:items:type: integertype: arrayinterval:minimum: 0type: integersuccesses:minimum: 0type: integertype: objecthttp_path:pattern: ^/.*$type: stringtimeout:minimum: 0type: integerunhealthy:properties:http_failures:minimum: 0type: integerhttp_statuses:items:type: integertype: arrayinterval:minimum: 0type: integertcp_failures:minimum: 0type: integertimeout:minimum: 0type: integertype: objecttype: objectpassive:properties:healthy:properties:http_statuses:items:type: integertype: arrayinterval:minimum: 0type: integersuccesses:minimum: 0type: integertype: objectunhealthy:properties:http_failures:minimum: 0type: integerhttp_statuses:items:type: integertype: arrayinterval:minimum: 0type: integertcp_failures:minimum: 0type: integertimeout:minimum: 0type: integertype: objecttype: objectthreshold:type: integertype: objecthost_header:type: stringslots:minimum: 10type: integertype: objectversion: v1
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:name: kongplugins.configuration.konghq.com
spec:additionalPrinterColumns:- JSONPath: .plugindescription: Name of the pluginname: Plugin-Typetype: string- JSONPath: .metadata.creationTimestampdescription: Agename: Agetype: date- JSONPath: .disableddescription: Indicates if the plugin is disabledname: Disabledpriority: 1type: boolean- JSONPath: .configdescription: Configuration of the pluginname: Configpriority: 1type: stringgroup: configuration.konghq.comnames:kind: KongPluginplural: kongpluginsshortNames:- kpscope: Namespacedsubresources:status: {}validation:openAPIV3Schema:properties:config:type: objectconfigFrom:properties:secretKeyRef:properties:key:type: stringname:type: stringrequired:- name- keytype: objecttype: objectdisabled:type: booleanplugin:type: stringprotocols:items:enum:- http- https- grpc- grpcs- tcp- tlstype: stringtype: arrayrun_on:enum:- first- second- alltype: stringrequired:- pluginversion: v1
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:name: tcpingresses.configuration.konghq.com
spec:additionalPrinterColumns:- JSONPath: .status.loadBalancer.ingress[*].ipdescription: Address of the load balancername: Addresstype: string- JSONPath: .metadata.creationTimestampdescription: Agename: Agetype: dategroup: configuration.konghq.comnames:kind: TCPIngressplural: tcpingressesscope: Namespacedsubresources:status: {}validation:openAPIV3Schema:properties:apiVersion:type: stringkind:type: stringmetadata:type: objectspec:properties:rules:items:properties:backend:properties:serviceName:type: stringservicePort:format: int32type: integertype: objecthost:type: stringport:format: int32type: integertype: objecttype: arraytls:items:properties:hosts:items:type: stringtype: arraysecretName:type: stringtype: objecttype: arraytype: objectstatus:type: objectversion: v1beta1
status:acceptedNames:kind: ""plural: ""conditions: []storedVersions: []
---
apiVersion: v1
kind: ServiceAccount
metadata:name: kong-serviceaccountnamespace: kong
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:name: kong-ingress-clusterrole
rules:
- apiGroups:- ""resources:- endpoints- nodes- pods- secretsverbs:- list- watch
- apiGroups:- ""resources:- nodesverbs:- get
- apiGroups:- ""resources:- servicesverbs:- get- list- watch
- apiGroups:- networking.k8s.io- extensions- networking.internal.knative.devresources:- ingressesverbs:- get- list- watch
- apiGroups:- ""resources:- eventsverbs:- create- patch
- apiGroups:- networking.k8s.io- extensions- networking.internal.knative.devresources:- ingresses/statusverbs:- update
- apiGroups:- configuration.konghq.comresources:- tcpingresses/statusverbs:- update
- apiGroups:- configuration.konghq.comresources:- kongplugins- kongclusterplugins- kongcredentials- kongconsumers- kongingresses- tcpingressesverbs:- get- list- watch
- apiGroups:- ""resources:- configmapsverbs:- create- get- update
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:name: kong-ingress-clusterrole-nisa-binding
roleRef:apiGroup: rbac.authorization.k8s.iokind: ClusterRolename: kong-ingress-clusterrole
subjects:
- kind: ServiceAccountname: kong-serviceaccountnamespace: kong
---
apiVersion: v1
kind: Service
metadata:annotations:service.beta.kubernetes.io/aws-load-balancer-backend-protocol: tcpservice.beta.kubernetes.io/aws-load-balancer-type: nlbname: kong-proxynamespace: kong
spec:type: NodePortports:- name: proxyport: 80protocol: TCPtargetPort: 8000nodePort: 80- name: proxy-sslport: 443protocol: TCPtargetPort: 8443nodePort: 443selector:app: ingress-kong
---
apiVersion: v1
kind: Service
metadata:name: kong-adminnamespace: konglabels:k8s-app: kong
spec:ports:- name: adminport: 8001protocol: TCPtargetPort: 8001- name: admin-sslport: 8444protocol: TCPtargetPort: 8444selector:app: ingress-kong
---
apiVersion: v1
kind: Service
metadata:name: kong-validation-webhooknamespace: kong
spec:ports:- name: webhookport: 443protocol: TCPtargetPort: 8080selector:app: ingress-kong
---
apiVersion: apps/v1
kind: Deployment
metadata:labels:app: ingress-kongname: ingress-kongnamespace: kong
spec:replicas: 1selector:matchLabels:app: ingress-kongtemplate:metadata:annotations:kuma.io/gateway: enabledprometheus.io/port: "8100"prometheus.io/scrape: "true"traffic.sidecar.istio.io/includeInboundPorts: ""labels:app: ingress-kongspec:tolerations:- effect: NoSchedulekey: node-role.kubernetes.io/mastercontainers:- env:- name: KONG_DATABASEvalue: postgres- name: KONG_PG_HOSTvalue: postgres- name: KONG_PG_PASSWORDvalue: kong- name: KONG_PROXY_LISTENvalue: 0.0.0.0:8000, 0.0.0.0:8443 ssl http2- name: KONG_PORT_MAPSvalue: 80:8000, 443:8443- name: KONG_ADMIN_LISTENvalue: 0.0.0.0:8001, 0.0.0.0:8444 ssl- name: KONG_STATUS_LISTENvalue: 0.0.0.0:8100- name: KONG_NGINX_WORKER_PROCESSESvalue: "2"- name: KONG_ADMIN_ACCESS_LOGvalue: /dev/stdout- name: KONG_ADMIN_ERROR_LOGvalue: /dev/stderr- name: KONG_PROXY_ERROR_LOGvalue: /dev/stderrimage: kong:2.3lifecycle:preStop:exec:command:- /bin/sh- -c- kong quitlivenessProbe:failureThreshold: 3httpGet:path: /statusport: 8100scheme: HTTPinitialDelaySeconds: 5periodSeconds: 10successThreshold: 1timeoutSeconds: 1name: proxyports:- containerPort: 8000name: proxyprotocol: TCP- containerPort: 8443name: proxy-sslprotocol: TCP- containerPort: 8100name: metricsprotocol: TCPreadinessProbe:failureThreshold: 3httpGet:path: /statusport: 8100scheme: HTTPinitialDelaySeconds: 5periodSeconds: 10successThreshold: 1timeoutSeconds: 1- env:- name: CONTROLLER_KONG_ADMIN_URLvalue: http://127.0.0.1:8001- name: CONTROLLER_KONG_ADMIN_TLS_SKIP_VERIFYvalue: "false"- name: CONTROLLER_PUBLISH_SERVICEvalue: kong/kong-proxy- name: POD_NAMEvalueFrom:fieldRef:apiVersion: v1fieldPath: metadata.name- name: POD_NAMESPACEvalueFrom:fieldRef:apiVersion: v1fieldPath: metadata.namespaceimage: kong/kubernetes-ingress-controller:1.2imagePullPolicy: IfNotPresentlivenessProbe:failureThreshold: 3httpGet:path: /healthzport: 10254scheme: HTTPinitialDelaySeconds: 5periodSeconds: 10successThreshold: 1timeoutSeconds: 1name: ingress-controllerports:- containerPort: 8080name: webhookprotocol: TCPreadinessProbe:failureThreshold: 3httpGet:path: /healthzport: 10254scheme: HTTPinitialDelaySeconds: 5periodSeconds: 10successThreshold: 1timeoutSeconds: 1initContainers:- command:- /bin/sh- -c- while true; do kong migrations list; if [[ 0 -eq $? ]]; then exit 0; fi; sleep 2;  done;env:- name: KONG_PG_HOSTvalue: postgres- name: KONG_PG_PASSWORDvalue: kongimage: kong:2.3name: wait-for-migrationsserviceAccountName: kong-serviceaccount
---
apiVersion: apps/v1
kind: StatefulSet
metadata:name: postgresnamespace: kong
spec:replicas: 1selector:matchLabels:app: postgresserviceName: postgrestemplate:metadata:labels:app: postgresspec:containers:- env:- name: POSTGRES_USERvalue: kong- name: POSTGRES_PASSWORDvalue: kong- name: POSTGRES_DBvalue: kong- name: PGDATAvalue: /var/lib/postgresql/data/pgdataimage: postgres:11.5name: postgresports:- containerPort: 5432volumeMounts:- mountPath: /var/lib/postgresql/dataname: kong-pgsubPath: pgdataterminationGracePeriodSeconds: 60volumeClaimTemplates:- metadata:name: kong-pgspec:accessModes:- ReadWriteOncestorageClassName: "nfs-storage"resources:requests:storage: 3Gi
---
apiVersion: v1
kind: Service
metadata:name: postgresnamespace: kong
spec:ports:- name: pgqlport: 5432protocol: TCPtargetPort: 5432selector:app: postgres
---
apiVersion: batch/v1
kind: Job
metadata:name: kong-migrationsnamespace: kong
spec:template:metadata:name: kong-migrationsspec:containers:- command:- /bin/sh- -c- kong migrations bootstrapenv:- name: KONG_PG_PASSWORDvalue: kong- name: KONG_PG_HOSTvalue: postgres- name: KONG_PG_PORTvalue: "5432"image: kong:2.3name: kong-migrationsinitContainers:- command:- /bin/sh- -c- until nc -zv $KONG_PG_HOST $KONG_PG_PORT -w1; do echo 'waiting for db'; sleep 1; doneenv:- name: KONG_PG_HOSTvalue: postgres- name: KONG_PG_PORTvalue: "5432"image: busyboxname: wait-for-postgresrestartPolicy: OnFailure---
apiVersion: apps/v1
kind: Deployment
metadata:name: konganamespace: kong
spec:replicas: 1selector:matchLabels:app: kongatemplate:metadata:labels:app: kongaspec:containers:- name: kongaimage: pantsel/kongaenv:- name: DB_ADAPTERvalue: postgres- name: DB_HOSTvalue: postgres- name: DB_PORTvalue: '5432'- name: DB_PASSWORDvalue: kong- name: DB_USERvalue: kong- name: DB_DATABASEvalue: kongaports:- containerPort: 1337name: webinitContainers:- command:- /bin/sh- -c- while true; do kong migrations list; if [[ 0 -eq $? ]]; then exit 0; fi; sleep 2;  done;env:- name: KONG_PG_HOSTvalue: postgres- name: KONG_PG_PASSWORDvalue: kongimage: kong:2.3name: wait-for-migrations---
apiVersion: v1
kind: Service
metadata:name: konganamespace: kong
spec:ports:- port: 1337protocol: TCPtargetPort: 1337selector:app: konga
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:name: web-ingressnamespace: kongannotations:kubernetes.io/ingress.class: "kong"
spec:rules:- host: konga.test.lanhttp:paths:- path: /backend:serviceName: kongaservicePort: 1337

先把上面这个文件下载下来,了解以下里面主要的架构

kong网关几个注意的架构

  • ingress-kong 以kong网关建立的 Kubernetes 入口控制器

  • konga 网关管理界面

  • postgres 网关数据存储

  • job 初始化结构表数据

一般在新的集群内创建kong网关的时候是需要先进行postgres数据库的创建,数据库正常运行之后,再进行job初始化数据库表数据。最后再创建ingress-kong和konga。现在我进行将这些资源整合,变成了一个ingress-kong.yaml,我们直接通过一条命令就可以部署起来。

$ kubectl apply -f ingress-kong.yaml

等待3分钟,查看运行创建情况

$ kubectl get po -n kong
NAME                          READY   STATUS      RESTARTS   AGE
ingress-kong-f7bd9f9f-bb6rg   2/2     Running     9          126d
kong-migrations-w2v4b         0/1     Completed   0          168d
konga-85fd66dcff-jw8gn        1/1     Running     0          97d
postgres-0                    1/1     Running     1          168d

配置host

ingress-kong节点ip   konga.test.lan

访问konga管理平台http://konga.nq.lan


http://www.ppmy.cn/news/319150.html

相关文章

Linux第一本书 第四章 Linux系统中的用户管理

一、用户及用户组存在的意义 用户存在的意义 系统中每个文件归一个特定的用户所有,对文件和目录的访问受到用户的限制。如果没有用户系统的文件和目录的访问将会杂乱无章,随着这些杂乱无章的访问,系统的安全将会受到很大威胁。所以设置用户…

Tanzu学习系列之TKGm 1.4 for vSphere 组件集成(四)

Harbor Registry(又称Harbor云原生制品仓库或Harbor镜像仓库)由VMware公司中国研发中心云原生实验室原创,并于2016年3月开源。Harbor在Docker Registry的基础上增加了企业用户必需的权限控制、镜像签名、安全漏洞扫描和远程复制等重要功能&am…

<Ⅳ>Linux系统中的用户管理2021-10-3

一、用户及用户组存在的意义 1.用户存在的意义 系统资源是有限的,如何合理分配系统资源? 在这个问题解决时必须要有两个资源配合 1)身份 account 2)授权 author 3)认证 auth 3A 机制,3A 机制组成系统中最…

GPGGA NTRIP RTCM 笔记

文章目录 名词简写GPGGA GNGGA格式说明Linux PTY 虚拟串口对Linux GPGGA 模拟器 NTRIPNTRIP2.x vs NTRIP1.0NTRIP2.0 Server/Caster/Client 模拟器Base64Client不发GPGGA的通信过程Client只发一次GPGGAClient周期发GPGGA一个帐号两个应用不可用的演示 RTCMWireshark千寻NTRIP抓…

Redis缓存详解(黑马-未完结)

文章目录 1.场景引入2.NoSQL数据库2.1NoSQL简介2.2NoSQL的适用场景2.3NoSQL不适用的场景2.4NoSQL数据库的意义 3.SQL与NoSQL的区别4.Redis简介5.Redis的应用场景5.1配合关系型数据库做高速缓存5.2多样的数据结构存储持久化数据 6.Redis的安装、启动服务、关闭服务6.1Redis的安装…

Spring Boot 几种启动问题的解决方案

注:本文转载自文章https://blog.csdn.net/qq_28804275/article/details/80891974 使用Spring Boot以来,遇到和解决过好几次不同的项目启动问题,大多数事故起于错误的配置和依赖。因此,本文用于汇总这些问题,以及提供相…

【SpringCloud】OpenFeign服务接口调用

提示:本文在已搭建好Eureka集群和服务提供者集群的条件下测试,OpenFeign用于服务消费端,至于怎样搭建好Eureka集群和服务提供者集群参考博客【SpringCloud】服务注册中心Eureka。 文章目录 什么是FeignFeign能干什么Feign和OpenFeign两者区别…

编译调试 chromium/v8

只是为了了解下js就没必要折腾chromium了,我编译了一天。想调试发现,8g内存的mac直接爆炸。然后就整了v8 也是一开始贪心。。。。 给一组我的数据 chromium: 下载好源码解决好依赖反正就是 马上可以编译了, 12G 编译花了10小…