本文转载自微信公众号《桐人的技术分享》,作者金伟。转载本文请联系桐人的技术分享公众号。劲威后台Ingress是Kubernetes中值得关注的一个模块。Ingresscontroller作为外部访问Kubernetes集群服务的入口,目前市面上已经有很多Ingresscontroller的实现。国内实时高性能API网关ApacheAPISIX推出的Apache/apisix-ingress-controller就是其中之一,作为更强大的ingress提供服务。笔者准备在阿里云ACK集群上部署测试。主题描述本文主要介绍apisix-ingress-controller在阿里云ACK上的部署,并使用httpbin测试了一个简单的场景。部署拓扑网络拓扑依赖阿里云的ACK集群;推荐最低配置:3个主节点:CPU2核内存4G2个工作节点:CPU4核内存8G安装步骤apisix2.1release通过helm安装apisix2.1release$kubectlcreatesapisix$gitclonehttps://github.com/apache/apisix-helm-chart。git$cd./apisix-helm-chart$helmrepoaddbitnamihttps://charts.bitnami.com/bitnami$helmdependencyupdate./chart/apisix$helminstallapisix./chart/apisix\--setgateway.type=LoadBalancer\--setallow.ipList="{0.0.0.0/0}"\--namespaceapisixtips:安装etcd时指定PVC。在阿里云上部署PVC时,需要指定PV为云盘。请在PVC的注解中添加:volume.beta.kubernetes.io/storage-class:alicloud-disk-ssd。(PVC和PV的关系可以参考这里)apisix-ingress-controller通过helm安装apisix-ingress-controller$gitclonehttps://github.com/apache/apisix-ingress-controller.git$cd./apisix-ingress-控制器$helminstallingress-apisix-base-napisix./charts/base$helminstallingress-apisix./charts/ingress-apisix\--setingressController.image.tag=dev\--setingressController.config.apisix.baseURL=http://apisix-admin:9180/apisix/admin\--setingressController.config.apisix.adminKey=edd1c9f034335f136f87ad84b625c8f1\--namespaceapisixtest查看集群是否部署成功配置简单路由测试apiVersion:apisix.apache.org/v1kind:ApisixRoutemetadata:name:httpbin-routenamespace:apisixspec:rules:-host:httpbin.apisix.comhttp:paths:-backend:serviceName:httpbinservicePort:80path:/hello*通过apisixadminapi查看结果,发现路由已正确配置。{"action":"get","count":"2","header":{"revision":"46","cluster_id":"8320356269565269865","raft_term":"2","member_id":"3807956127770623265"},"node":{"key":"/apisix/upstreams","dir":true,"modifiedIndex":27,"createdIndex":3,"nodes":[{"key":"/apisix/upstreams/00000000000000000041","modifiedIndex":42,"value":{"nodes":{"172.20.1.12:80":100},"type":"roundrobin","pass_host":"pass""hash_on":"vars","desc":"apisix_httpbin_80","create_time":1608561159,"update_time":1608561159},"createdIndex":42}]}}展开httpbin在k8s中查看httpbin在apisix中查看上游的httpbin//格式化后{..."nodes":{"172.20.1.12:80":100,"172.20.0.198:80":100,"172.20.0.197:80":100},"id":"00000000000000000041","key":"/apisix/upstreams/00000000000000000041","desc":"apisix_httpbin_80",...}总结本文在ACK集群环境中依次安装了Etcd、ApacheAPISIX、Apacheapisix-ingress-controller,并使用httpbin服务验证了ingress的基本配置功能,通过CRD配置路由,检测另外值得一提的是,apisix-ingress-controller可以全面支持ApacheAPISIX提供的所有插件,甚至是自定义插件,功能丰富,扩展性强。项目。
