赞
踩
Apache APISIX
是一个动态的、实时的、高性能的 API 网关. 本文主要测试在k8s环境下使用apisix-ingress-controlle
Helm Chart
安装所有的pod
,svc
等都放到了default
的namespace
下
$ helm repo add apisix https://charts.apiseven.com
$ helm repo update
$ helm install apisix apisix/apisix
$ helm install apisix-dashboard apisix/apisix-dashboard
$ helm install apisix-ingress-controller apisix/apisix-ingress-controller --namespace default
apisix-dashboard
和验证安装1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=apisix-dashboard,app.kubernetes.io/instance=apisix-dashboard" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT
2. username: admin password:admin
3. 使用 port-forward 可以访问 dashboard
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
2. apisix-gateway 对外暴露的 `apisix` 的端口即代理的端口
apisix-ingress-controller
日志kubectl logs <pod name> 如果没有报错即可
whoami
apiVersion: apps/v1 kind: Deployment metadata: name: whoami spec: selector: matchLabels: run: whoami replicas: 2 template: metadata: labels: run: whoami spec: containers: - name: whoami image: containous/whoami ports: - containerPort: 80
whoami
的svcapiVersion: v1
kind: Service
metadata:
name: whoami
labels:
run: whoami
spec:
ports:
- port: 80
protocol: TCP
selector:
run: whoami
apisix
的方式apisix-route.yml
apiVersion: apisix.apache.org/v2beta1
kind: ApisixRoute
metadata:
name: httpserver-route
spec:
http:
- name: rule1
match:
hosts:
- local.whoami.org
paths:
- /whoami
backend:
serviceName: whoami
servicePort: 80
ingress
的方式apisix-ingress.yml
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: httpserver-ingress spec: # apisix-ingress-controller is only interested in Ingress # resources with the matched ingressClass name, in our case, # it's apisix. ingressClassName: apisix rules: - host: local.whoami.com http: paths: - path: /whoami pathType: Prefix backend: service: name: whoami port: number: 80
whoami 修改路由的域名选项改成空
http://127.0.0.1:32186/whoami
apisix
服务apisix
的 svc
使用nodeport方式暴露apisix
服务apisix
的 api
服务. 主要用于通过api的方式将路有写入etcdapisix-admin
写入etcd ,定义在apisix-ingress-controller-configmap
apisix:
base_url: "http://apisix-admin:9180/apisix/admin"
admin_key: "edd1c9f034335f136f87ad84b625c8f1"
apisix
中的service mesh
组件envoy
. 目前此项目还是实验性的.tcp/upd
代理也可以像apisix-gateway
一样将端口转发到apisix
进行四层代理.
Helm Chart
中apisix-ingress-controller
的namespace
是ingress-apisix
. 但apisix
.apisix-dashboard
放在default
当apisix-ingress-controller
捕获k8s
的配置无法和apisix
通信helm install apisix-ingress-controller apisix/apisix-ingress-controller --namespace default 修改下即可
apisix-ingress-controller
访问apisix
返回 403
放行所有IP
helm install apisix apisix/apisix \
--set admin.allow.ipList=""
apisix
(又成了服务端代理?), 怎么区分内部和外部流量? 可以使用不同的请求头区别. 这样就可以省去springcloud
哪些组件了.apisix-mesh-agent
. 是否就抛弃了nacos
服务. 服务的上下线的实时性怎么样. 服务数量如果很多性能会怎样Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。