kubernetes 安装kong、kong-ingress-controlor

一、关于kong的详细内容这里不再赘述,可以查看官网。

kong升级到1.0以后功能越来越完善,并切新版本的kong可以作为service-mesh使用,并可以将其作为kubernetes的ingress-controlor。虽然在作为service-mesh方面与istio还有差异,但是kong的发展前景很好,kong-ingress-controlor可以自动发现kubernetes集群里面的ingress服务并统一管理。所以我们的测试集群正在试用kong,这里先记录一下部署过程。

二、部署

提前准备好:kubernetes 集群(我线上使用的是1.13.2)、PV持久化(使用nfs做的)、helm

获取charts:

安装好了helm,可以直接使用:

helm  fetch stable/kong

这个默认repo获取是需要FQ的。

我们使用的是根据官方的定制的:

https://github.com/cuishuaigit/k8s-kong

部署前可以根据自己的需要进行定制:

修改values.yaml文件,我这里取消了admin API的https,因为是纯内网环境。然后做了admin、proxy(http、https)的nodeport端口分别为32344、32380、32343。然后就是设置了默认开启 ingressController。

部署kong:

git clone https://github.com/cuishuaigit/k8s-kong

cd k8s-kong

helm install -n kong-ingress  --tiller-namespace default  .

测试环境的tiller是部署在default这个namespace下的。

部署完的效果:

root@ku13-1:~# kubectl get pods  | grep kong
kong-ingress-kong-5c968fdb74-gsrr8                1/1     Running     0          4h14m
kong-ingress-kong-controller-5896fd6d67-4xcg5     2/2     Running     1          4h14m
kong-ingress-kong-init-migrations-k9ztt           0/1     Completed   0          4h14m
kong-ingress-postgresql-0                         1/1     Running     0          4h14m
root@ku13-1:/data/k8s-kong# kubectl get svc  | grep kong
kong-ingress-kong-admin            NodePort    192.103.113.85    <none>        8444:32344/TCP                4h18m
kong-ingress-kong-proxy            NodePort    192.96.47.146     <none>        80:32380/TCP,443:32343/TCP    4h18m
kong-ingress-postgresql            ClusterIP   192.97.113.204    <none>        5432/TCP                      4h18m
kong-ingress-postgresql-headless   ClusterIP   None              <none>        5432/TCP                      4h18m

然后根据https://github.com/Kong/kubernetes-ingress-controller/blob/master/docs/deployment/minikube.md部署了demo服务:

wget  https://raw.githubusercontent.com/Kong/kubernetes-ingress-controller/master/deploy/manifests/dummy-application.yaml

kubectl create -f dummy-application.yaml

创建ingress rule:

#cat demo-ingress.yaml

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: foo-bar
spec:
  rules:
  - host: foo.bar
    http:
      paths:
      - path: /
        backend:
          serviceName: http-svc
          servicePort: 80
kubectl  create -f demon-ingress.yaml

使用curl测试:

root@ku13-1:/data/k8s-kong# curl http://192.96.47.146 -H Host:foo.bar

Hostname: http-svc-6f459dc547-qpqmv

Pod Information:
    node name:    ku13-2
    pod name:    http-svc-6f459dc547-qpqmv
    pod namespace:    default
    pod IP:    192.244.32.25

Server values:
    server_version=nginx: 1.13.3 - lua: 10008

Request Information:
    client_address=192.244.6.216
    method=GET
    real path=/
    query=
    request_version=1.1
    request_uri=http://192.244.32.25:8080/

Request Headers:
    accept=*/*
    connection=keep-alive
    host=192.244.32.25:8080
    user-agent=curl/7.47.0
    x-forwarded-for=10.2.6.7
    x-forwarded-host=foo.bar
    x-forwarded-port=8000
    x-forwarded-proto=http
    x-real-ip=10.2.6.7

Request Body:
    -no body in request-

三、部署konga

konga是kong的一个dashboard,具体部署参考https://www.cnblogs.com/cuishuai/p/9378960.html

未完待续。。。。。

猜你喜欢

转载自www.cnblogs.com/cuishuai/p/10737737.html