我试图在两个Web界面上都将https作为域的api。我尝试了Nginx Ingress。它适用于www.example.com,但现在我需要在api.example.com上添加api。我尝试了以下方式,但无济于事。删除与api相关的部分,它对于Web界面适用,否则Web界面也不起作用。如何指定我的入口文件,以便在api.example.com上以及类似地在www.example.com域上添加https?
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-service
annotations:
kubernetes.io/ingress.class: nginx
kubernetes.io/tls-acme: "true"
nginx.ingress.kubernetes.io/add-base-url: "true"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
certmanager.k8s.io/cluster-issuer: "letsencrypt-prod"
spec:
tls:
- hosts:
- www.example.com
- api.example.com
secretName: example-secret
rules:
- host: www.example.com
http:
paths:
- path: /
backend:
serviceName: web-cluster-ip-service
servicePort: 5000
- host: api.example.com
http:
paths:
- path: /
backend:
serviceName: api-cluster-ip-service
servicePort: 5005
certmanager文件的设置如下。
apiVersion: certmanager.k8s.io/v1alpha1
kind: Certificate
metadata:
name: example-tls
spec:
secretName: example-secret
issuerRef:
name: letsencrypt-prod
kind: ClusterIssuer
commonName: example.com
dnsNames:
- example.com
acme:
config:
- http01:
ingressClass: nginx
domains:
- example.com