本章节介绍使用 ingress-inginx 暴露服务
- 部署 ingress-nginx
# 留意是否需要从参考链接获取最新版本部署
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.8.2/deploy/static/provider/aws/deploy.yaml
- 部署 http-svc 服务
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/docs/examples/http-svc.yaml
- 通过 nginx-ingress 暴露 http-svc 服务
cat <<EOF > ingress-http-svc.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-http-svc
spec:
rules:
- host: http-svc.foo.org
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: http-svc
port:
number: 80
ingressClassName: nginx
EOF
kubectl apply -f ingress-http-svc.yaml