我正在尝试在我的 Web 界面上获取 https 作为域的 api。我尝试使用 nginx 入口。它适用于 www.example.com,但现在我需要在 api.example.com 添加 api。我尝试了以下方式,但无济于事。删除 api 相关部分,它适用于 web 界面,否则 web 界面也不起作用。如何指定我的入口文件,以便它在 api.example.com 上添加 https 并在 www.example.com 域上类似地添加?
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