I am trying to get https on both my web interface as my api for a domain. I tried with nginx ingress. It works fine for www.example.com, but now I need to add the api at api.example.com. I tried in the following way, but to no avail. Removing the api related sections and it works fine for the web interface, otherwise the web interface also does not work. How can I specify my ingress file such that it adds https on the api.example.com and similarly on www.example.com domains?
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
The certmanager file is set-up as follows.
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