Kong
在k8s安装Kong-ingress
安装Kong:# using YAMLs
$ kubectl apply -f https://bit.ly/k4k8s
# or using Helm
$ helm repo add kong https://charts.konghq.com
$ helm repo update
# Helm 2
$ helm install kong/kong
# Helm 3
$ helm install kong/kong --generate-name --set ingressController.installCRDs=false
部署一个应用
部署一个应用:
(1)构建一个deployment:apiVersion: apps/v1
kind: Deployment
metadata:
name: app-server
labels:
name: app-server
spec:
replicas: 1
selector:
matchLabels:
name: app-server
template:
metadata:
labels:
name: app-server
spec:
containers:
- name: app-server
image: registry.cn-shenzhen.aliyuncs.com/shikanon/ambassador-auth-demo:serverv0.1
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
构建一个service:apiVersion: v1
kind: Service
metadata:
name: app-server
spec:
ports:
- name: http
port: 8000
protocol: TCP
targetPort: 8080
selector:
name: app-server
构建一个ingress:apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: demo
annotations:
kubernetes.io/ingress.class: "kong"
spec:
rules:
- http:
paths:
- path: /open/
backend:
serviceName: app-server
servicePort: 8000
测试接口:$ curl -i http://$KongService_IP/open/
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 6
Connection: keep-alive
Date: Sun, 24 May 2020 10:49:07 GMT
X-Kong-Upstream-Latency: 1
X-Kong-Proxy-Latency: 0
Via: kong/2.0.4
/open/