2

When our site is getting deployed, the Ingress gets created and before I could get any response I get 503 for 5-6 minutes (time taken to startup).

We need to configure our ingress to redirect to a static page that is custom-made instead of the 503 error. Can I add an annotation to achieve this? If yes, please give me an example for redirect config using the status code.

0

There is no built-in configuration/annotation to handle this.

Although, you can use the server-snippet annotation to create a custom configuration that intercepts the error 503, proxying the request to a service that is serving your custom error page. Example:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/server-snippet: |
      proxy_intercept_errors on;
      error_page 503 = @errorpages;
      
      location @errorpages {
        proxy_set_header X-Code $status;
        proxy_pass http://errors-svc.default.svc.cluster.local;
      }
spec:
  rules:
  - host: ameba.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: nginx
            port:
              number: 80

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.