需求说明
内网后端地址:http://10.10.246.29:9000
如图:
外网域名:https://devhtk.ntmaorong.com/
要求:
https://devhtk.ntmaorong.com/minio/ ---> 访问 http://10.10.246.29:9000/minio/
service+endpoint+ingress配置
apiVersion: v1
kind: Service
metadata:
labels:
app: vchain-minio
name: vchain-minio
namespace: haian-dev
spec:
ports:
- name: tcp-9000
port: 9000
protocol: TCP
targetPort: 9000
selector:
app: vchain-minio
sessionAffinity: None
type: ClusterIP
---
apiVersion: v1
kind: Endpoints
metadata:
labels:
app: vchain-minio
name: vchain-minio
namespace: haian-dev
subsets:
- addresses:
- ip: 10.10.246.29
ports:
- name: tcp-9000
port: 9000
protocol: TCP
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
nginn.ingress.kubernetes.io/proxy-body-size: 50m
nginx.ingress.kubernetes.io/rewrite-target: /minio/(.*)
nginx.ingress.kubernetes.io/use-regex: "true"
name: vchain-minio
namespace: haian-dev
spec:
ingressClassName: nginx
rules:
- host: devhtk.ntmaorong.com
http:
paths:
- backend:
service:
name: vchain-minio
port:
number: 9000
path: /minio/(.*)
pathType: ImplementationSpecific
tls:
- hosts:
- devhtk.ntmaorong.com
secretName: ntmaorong-secret
启动:
# kubectl create -f vchain-minio.yaml
检查效果
内网地址访问效果:
外网地址访问效果:
外网地址原来的页面没有受到影响: