今天介绍如何在 k8s 上安装 APISIX 相关组件(Apache APISIX、Apache APISIX Dashboard、Apache APISIX Ingress Controller)。

Apache APISIX

由于 APISIX helm 组件将相关组件集合在一起了,所以只要装一个就好了。

安装步骤

  1. 前提 要创建好相应的 PV .
  2. 命令
1
2
3
helm repo add apisix https://charts.apiseven.com
helm repo update
helm install apisix apisix/apisix --set gateway.type=NodePort --set ingress-controller.enabled=true --set dashboard.enabled=true --set etcd.volumePermissions.enabled=true   --namespace ingress-apisix
  1. 如果看到如下信息并且执行 kubectl get pods -n ingress-apisix 就表示 apisix 安装成功。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
NNAME: apisix
LAST DEPLOYED: Wed Oct 27 03:00:23 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
1. Get the application URL by running these commands:
  export NODE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services apisix-gateway)
  export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}")
  echo http://$NODE_IP:$NODE_PORT
  
  
NAME                                         READY   STATUS    RESTARTS   AGE
apisix-69459554d4-tc7sd                      1/1     Running   0          8m49s
apisix-etcd-0                                1/1     Running   0          8m49s
apisix-etcd-1                                1/1     Running   0          8m49s
apisix-etcd-2                                1/1     Running   0          5m16s
apisix-ingress-controller-678d8b5f6d-h6kq8   1/1     Running   0          8m49s
  1. 修改 apisix-dashboard service 的 spec.type 为 NodePort

安装过程的问题及解决

etcd pod 启动失败

2021-10-27 06:29:47.259764 C | etcdmain: cannot access data directory: mkdir /bitnami/etcd/data: permission denied

解决

在安装时增加 —set etcd.volumePermissions.enabled=true