1 2 3 4

Apisix2.10.0 ACK安装测试

Apache APISIX是一个动态的、实时的、高性能的 API 网关。它提供丰富的流量管理功能,例如负载均衡、动态上游服务、金丝雀发布、断路、身份验证、可观察性等。您可以使用 Apache APISIX 来处理传统的南北流量,以及服务之间的东西流量。2019 年 10 月份,深圳支流科技把网关 APISIX 贡献给 Apache 基金会,他们提供商业版本,以下内容基于社区版本。

APISIX地址:https://github.com/apache/apisix

DashBoard:https://github.com/apache/apisix-dashboard

中文文档地址:https://apisix.apache.org/zh/docs/apisix/getting-started/

1、安装APISIX 和 APISIX Dashboard
官方文档介绍了源码包、RPM 包、Docker 以及Helm Chart安装方式,这里我们在K8s 环境下使用 apisix, 所以选择使用Helm Chart方式安装,安装文档参见 https://apisix.apache.org/zh/docs/helm-chart/apisix/

日前支流科技提供了一个在线 Helm Charts 仓库 https://charts.apiseven.com, 用户可通过该仓库轻松安装 Apache APISIX、Apache apisix-dashboard 和 Apache apisix-ingress-controller (而不需要提前 clone 对应的项目)

一共有3个Helm Chart:

添加仓库并获取更新

helm repo add apisix https://charts.apiseven.com
helm repo update

查看仓库可用的Charts包

helm search repo apisix

NAME                            	CHART VERSION	APP VERSION	DESCRIPTION
apisix/apisix                   	0.7.2        	2.10.0     	A Helm chart for Apache APISIX
apisix/apisix-dashboard         	0.3.0        	2.9.0      	A Helm chart for Apache APISIX Dashboard
apisix/apisix-ingress-controller	0.8.0        	1.3.0      	Apache APISIX Ingress Controller for Kubernetes

把apisix的Chart包拉取下来

[root@love:~/apisix-dome/dome ]# helm pull apisix/apisix
[root@love:~/apisix-dome/dome ]# ls
apisix-0.7.2.tgz
[root@love:~/apisix-dome/dome ]# tar -zxf apisix-0.7.2.tgz
[root@love:~/apisix-dome/dome ]# tree apisix
apisix
├── Chart.lock
├── charts
│   ├── apisix-dashboard
│   │   ├── Chart.yaml
│   │   ├── templates
│   │   │   ├── configmap.yaml
│   │   │   ├── deployment.yaml
│   │   │   ├── _helpers.tpl
│   │   │   ├── hpa.yaml
│   │   │   ├── ingress.yaml
│   │   │   ├── NOTES.txt
│   │   │   ├── serviceaccount.yaml
│   │   │   ├── service.yaml
│   │   │   └── tests
│   │   │       └── test-connection.yaml
│   │   └── values.yaml
│   ├── apisix-ingress-controller
│   │   ├── Chart.yaml
│   │   ├── crds
│   │   │   └── customresourcedefinitions.yaml
│   │   ├── README.md
│   │   ├── templates
│   │   │   ├── configmap.yaml
│   │   │   ├── deployment.yaml
│   │   │   ├── _helpers.tpl
│   │   │   ├── hpa.yaml
│   │   │   ├── NOTES.txt
│   │   │   ├── rbac.yaml
│   │   │   ├── service-account.yaml
│   │   │   ├── servicemonitor.yaml
│   │   │   └── service.yaml
│   │   └── values.yaml
│   └── etcd
│       ├── Chart.lock
│       ├── charts
│       │   └── common
│       │       ├── Chart.yaml
│       │       ├── README.md
│       │       ├── templates
│       │       │   ├── _affinities.tpl
│       │       │   ├── _capabilities.tpl
│       │       │   ├── _errors.tpl
│       │       │   ├── _images.tpl
│       │       │   ├── _ingress.tpl
│       │       │   ├── _labels.tpl
│       │       │   ├── _names.tpl
│       │       │   ├── _secrets.tpl
│       │       │   ├── _storage.tpl
│       │       │   ├── _tplvalues.tpl
│       │       │   ├── _utils.tpl
│       │       │   ├── validations
│       │       │   │   ├── _cassandra.tpl
│       │       │   │   ├── _mariadb.tpl
│       │       │   │   ├── _mongodb.tpl
│       │       │   │   ├── _postgresql.tpl
│       │       │   │   ├── _redis.tpl
│       │       │   │   └── _validations.tpl
│       │       │   └── _warnings.tpl
│       │       └── values.yaml
│       ├── Chart.yaml
│       ├── ci
│       │   ├── values-disaster-recovery.yaml
│       │   ├── values-metrics.yaml
│       │   └── values-pdb.yaml
│       ├── README.md
│       ├── templates
│       │   ├── configmap.yaml
│       │   ├── cronjob.yaml
│       │   ├── extra-list.yaml
│       │   ├── _helpers.tpl
│       │   ├── NOTES.txt
│       │   ├── pdb.yaml
│       │   ├── podmonitor.yaml
│       │   ├── secrets.yaml
│       │   ├── serviceaccount.yaml
│       │   ├── snapshot-pvc.yaml
│       │   ├── statefulset.yaml
│       │   ├── svc-headless.yaml
│       │   └── svc.yaml
│       └── values.yaml
├── Chart.yaml
├── README.md
├── templates
│   ├── configmap.yaml
│   ├── deployment.yaml
│   ├── _helpers.tpl
│   ├── hpa.yaml
│   ├── ingress.yaml
│   ├── NOTES.txt
│   ├── service-admin.yaml
│   └── service-gateway.yaml
└── values.yaml

注:因为apisix的helm chart会安装etcd作为存储,但是需要创建storageClass存储类,chart里面默认是没有制定的,后续执行安装的时候会提示找不到storageClass然后报错,所以要在ack集群上提前创建好storageClass,以防报错

创建完成storageClass以后去apisix/charts/etcd目录下找到values.yaml,去掉storageClass前面的注释
[root@love:~/apisix/charts/etcd]# vim values.yaml

[root@love:~/apisix/charts/etcd ]# cat values.yaml | grep apisix-etcd
storageClass: "apisix-etcd" #换成你创建的storageClass

安装 Apache APISIX 到目标 Kubernetes 集群中

helm install apisix ./apisix  --set gateway.type=NodePort --set admin.allow.ipList=""   --namespace ingress-apisix

创建了四个Service资源,apisix-etcd 和 apisix-etcd-headless是etcd服务, 一个是处理真实流量的apisix-gateway,;另一个是充当控制平面来处理所有配置更改的服务apisix-admin
网关服务类型设置为NodePort,以便客户端可以通过节点 IP 和分配的端口访问 Apache APISIX。

还有一点需要注意的是,该allow.ipList字段要根据Pod CIDR设置进行自定义,请注意我这里偷懒把所有的ip 都打开了,这个在生产环境下是不推荐这么干的。这样apisix-ingress-controller实例才能访问APISIX实例

安装apisix-dashboard,将其安装在与 Apache APISIX 相同的命名空间中

helm install apisix-dashboard apisix/apisix-dashboard --namespace ingress-apisix

安装 apisix-ingress-controller,将其安装在与 Apache APISIX 相同的命名空间中

helm install apisix-ingress-controller apisix/apisix-ingress-controller   --set config.apisix.baseURL=http://apisix-admin:9180/apisix/admin  --set config.apisix.adminKey=edd1c9f034335f136f87ad84b625c8f1  --namespace ingress-apisix
上述命令中使用的管理密钥是默认的,如果您在部署 APISIX 时更改了管理密钥配置,请记住在此处更改。将image.tag 更改为您想要的 apisix-ingress-controller 版本。

检查是否安装成功:

[root@love.k8sworker1.130-57:~/apisix-dome/dome/apisix/charts/etcd ]# kubectl get all --namespace ingress-apisix
NAME                                             READY   STATUS    RESTARTS   AGE
pod/apisix-d8db9949f-2xw9c                       1/1     Running   0          4d20h
pod/apisix-dashboard-b644c497c-zn8l2             1/1     Running   0          5d4h
pod/apisix-etcd-0                                1/1     Running   1          11d
pod/apisix-etcd-1                                1/1     Running   1          11d
pod/apisix-etcd-2                                1/1     Running   1          11d
pod/apisix-ingress-controller-596dd4ccd5-k89l4   1/1     Running   0          4d19h
pod/aspnetappdemo-5d59c845cd-4nhp2               1/1     Running   0          11d
pod/web-685fc76fc9-pl7mf                         1/1     Running   0          11d

NAME                                TYPE        CLUSTER-IP        EXTERNAL-IP   PORT(S)             AGE
service/apisix-admin                ClusterIP   192.168.93.207    <none>        9180/TCP            11d
service/apisix-dashboard            ClusterIP   192.168.156.236   <none>        80/TCP              11d
service/apisix-etcd                 ClusterIP   192.168.106.199   <none>        2379/TCP,2380/TCP   11d
service/apisix-etcd-headless        ClusterIP   None              <none>        2379/TCP,2380/TCP   11d
service/apisix-gateway              NodePort    192.168.32.130    <none>        80:30092/TCP        11d
service/apisix-ingress-controller   ClusterIP   192.168.14.132    <none>        80/TCP              4d19h
service/aspnetdemo                  NodePort    192.168.161.193   <none>        80:32668/TCP        11d
service/web                         ClusterIP   192.168.56.122    <none>        8080/TCP            11d

NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/apisix                      1/1     1            1           11d
deployment.apps/apisix-dashboard            1/1     1            1           11d
deployment.apps/apisix-ingress-controller   1/1     1            1           4d19h
deployment.apps/aspnetappdemo               1/1     1            1           11d
deployment.apps/web                         1/1     1            1           11d

NAME                                                   DESIRED   CURRENT   READY   AGE
replicaset.apps/apisix-5979b8d95f                      0         0         0       5d20h
replicaset.apps/apisix-59bc85dc6c                      0         0         0       5d4h
replicaset.apps/apisix-5ccd567b94                      0         0         0       5d4h
replicaset.apps/apisix-665b9b4c76                      0         0         0       5d4h
replicaset.apps/apisix-6b6c56b48f                      0         0         0       6d20h
replicaset.apps/apisix-6f97f57df5                      0         0         0       5d4h
replicaset.apps/apisix-755fcbcb8                       0         0         0       5d20h
replicaset.apps/apisix-7b5bf74c66                      0         0         0       5d4h
replicaset.apps/apisix-8969bc44                        0         0         0       5d4h
replicaset.apps/apisix-8fcb7896f                       0         0         0       4d20h
replicaset.apps/apisix-d8db9949f                       1         1         1       4d20h
replicaset.apps/apisix-dashboard-57b5474cfd            0         0         0       11d
replicaset.apps/apisix-dashboard-6b44dc8b49            0         0         0       5d20h
replicaset.apps/apisix-dashboard-b644c497c             1         1         1       5d4h
replicaset.apps/apisix-ingress-controller-596dd4ccd5   1         1         1       4d19h
replicaset.apps/aspnetappdemo-5d59c845cd               1         1         1       11d
replicaset.apps/web-685fc76fc9                         1         1         1       11d
replicaset.apps/web-79d88c97d6                         0         0         0       11d

NAME                           READY   AGE
statefulset.apps/apisix-etcd   3/3     11d

NAME                                                                                          AGE
containernetworkfilesystem.storage.alibabacloud.com/default-cnfs-nas-2dcf9ba-20211020180121   54d

访问apisix-dashboard 的默认用户名/密码是admin/admin
image

引用文档:https://www.cnblogs.com/shanyou/p/apisix.html

posted @ 2021-12-14 15:45  请叫我阿鑫  阅读(610)  评论(0编辑  收藏  举报