访问原理架构图
ingress访问原理图.png
部署集群外部服务
1.以webhook服务为咧
服务访问地址如下
http://10.41.1.20:9001/hooks/test-webhook?token=5656
ip+端口的方式(10.41.1.20:9001)
测试端口是否正常
root@devops-test:~# telnet 10.41.1.20 9001
Trying 10.41.1.20...
Connected to 10.41.1.20.
Escape character is '^]'.
配置k8s的yaml文件测试链接性
service.yaml文件
apiVersion: v1
kind: Service
metadata:
name: webhook
spec:
type: ClusterIP
ports:
- port: 9001
targetPort: 9001
name: webhook
endpoints.yaml文件
apiVersion: v1
kind: Endpoints
metadata:
name: webhook
subsets:
- addresses:
- ip: 10.41.1.20
ports:
- port: 9001
protocol: TCP
name: webhook
ingress-service.yaml文件
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: webhook
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: webhook.test.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: webhook
port:
servicePort: 9001
即可通过域名进行链接调试是否完成