I deployed a Ingress without certificate
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: api-dev-ingress
spec:
ingressClassName: nginx
rules:
- host: api.dev
http:
paths:
- pathType: Prefix
path: /
backend:
service:
name: api-service-staging
port:
number: 80
It worked smoothly but without TLS.
Then, I installed cert-manager by Helm
helm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --version v1.8.2 --set installCRDs=true
And deployed a certificate just like below:
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-prod
spec:
acme:
server: https://acme-v02.api.letsencrypt.org/directory
email: email@email.com
privateKeySecretRef:
name: letsencrypt-prod
solvers:
- http01:
ingress:
class: nginx
and then redeployed the NGINX ingress with the tls attribute:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
acme.cert-manager.io/http01-edit-in-place: "true"
name: api-dev-ingress
spec:
tls:
- hosts:
- api.dev
secretName: letsencrypt-prod
ingressClassName: nginx
rules:
- host: api.dev
http:
paths:
- pathType: Prefix
path: /
backend:
service:
name: api-service-staging
port:
number: 80
Now I have my certificated ingress but the problem is that it's redirecting all requests to GET. I have a POST endpoint and when I run it, it's saying that it's not working.
The log stats for ingress pod is this:
10.106.0.3 - - [12/Jul/2022:13:17:17 +0000] "POST /auth/login HTTP/1.1" 301 169 "-" "PostmanRuntime/7.29.0" "-"
10.106.0.3 - - [12/Jul/2022:13:17:17 +0000] "GET /auth/login HTTP/1.1" 404 73 "http://api.dev/auth/login" "PostmanRuntime/7.29.0" "-"
So maybe it's something related to this 301 redirect. Maybe it should be 308 but I'm not sure.
Does anyone have an idea what I can do?