k8s ingress对外暴露接口的几种方式
2021-05-26 本文已影响0人
hugoren
先看结果
DaemonSet+HostNetwork+nodeSelector
image.pngDeployment+NodePort模式的Service
image.pngDeployment+LoadBalancer模式的Service
修改deploy.yaml的service
image.png
因没有外部地址,一直处于pending状态
image.png
原理
为什么需要ingress?实际就是service的service
service不足
1.nodepoint过多,管理不便
2.cluster-ip 只能在同一个集群内访问
3.lb增加费用
调用过程controller(pod)运行着nginx-->ingress配置调用指向service
controller上运行的nginx
ingress 的service配置
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: ingress-nginx
namespace: test
annotations:
# use the shared ingress-nginx
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/use-regex: "true"
spec:
rules:
- host: hugo.com
http:
paths:
- path: /
backend:
serviceName: svc-nginx
servicePort: 80