From a9495ecae0306030076d258513c2dbc89bf78b72 Mon Sep 17 00:00:00 2001 From: Mario Vejlupek Date: Wed, 12 Jan 2022 15:30:37 +0100 Subject: [PATCH] Add custom error pages example file (#8060) * Add custom error pages example file * Update docs/examples/customization/custom-errors/README.md Co-authored-by: Jintao Zhang Co-authored-by: Jintao Zhang --- .../customization/custom-errors/README.md | 2 ++ ...default-backend-error_pages.configMap.yaml | 19 ++++++++++++++++++ .../custom-default-backend.helm.values.yaml | 20 +++++++++++++++++++ .../custom-errors/custom-default-backend.yaml | 16 +++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 docs/examples/customization/custom-errors/custom-default-backend-error_pages.configMap.yaml create mode 100644 docs/examples/customization/custom-errors/custom-default-backend.helm.values.yaml diff --git a/docs/examples/customization/custom-errors/README.md b/docs/examples/customization/custom-errors/README.md index 00b9998590..a137fd6dc4 100644 --- a/docs/examples/customization/custom-errors/README.md +++ b/docs/examples/customization/custom-errors/README.md @@ -2,6 +2,8 @@ This example demonstrates how to use a custom backend to render custom error pages. +If you are using Helm Chart, look at [example values](https://github.com/kubernetes/ingress-nginx/blob/main/docs/examples/customization/custom-errors/custom-default-backend.helm.values.yaml) and don't forget to add [configMap](https://github.com/kubernetes/ingress-nginx/blob/main/docs/examples/customization/custom-errors/custom-default-backend-error_pages.configMap.yaml) to your deployment, otherwise continue with [Customized default backend](#customized-default-backend) manual deployment. + ## Customized default backend First, create the custom `default-backend`. It will be used by the Ingress controller later on. diff --git a/docs/examples/customization/custom-errors/custom-default-backend-error_pages.configMap.yaml b/docs/examples/customization/custom-errors/custom-default-backend-error_pages.configMap.yaml new file mode 100644 index 0000000000..86b1c44e85 --- /dev/null +++ b/docs/examples/customization/custom-errors/custom-default-backend-error_pages.configMap.yaml @@ -0,0 +1,19 @@ +# Custom error page configMap +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: custom_error_pages +data: + 404: | + + + PAGE NOT FOUND + PAGE NOT FOUND + + 503: | + + + CUSTOM SERVICE UNAVAILABLE + CUSTOM SERVICE UNAVAILABLE + diff --git a/docs/examples/customization/custom-errors/custom-default-backend.helm.values.yaml b/docs/examples/customization/custom-errors/custom-default-backend.helm.values.yaml new file mode 100644 index 0000000000..ce42bb9b55 --- /dev/null +++ b/docs/examples/customization/custom-errors/custom-default-backend.helm.values.yaml @@ -0,0 +1,20 @@ +controller: + custom-http-errors: "404,503" +defaultBackend: + enabled: true + image: + registry: k8s.gcr.io + image: ingress-nginx/nginx-errors + tag: "0.48.1" + extraVolumes: + - name: custom_error_pages + configMap: + name: custom_error_pages + items: + - key: "404" + path: "404.html" + - key: "503" + path: "503.html" + extraVolumeMounts: + - name: custom_error_pages + mountPath: /www diff --git a/docs/examples/customization/custom-errors/custom-default-backend.yaml b/docs/examples/customization/custom-errors/custom-default-backend.yaml index 579e485449..4b40d36e77 100644 --- a/docs/examples/customization/custom-errors/custom-default-backend.yaml +++ b/docs/examples/customization/custom-errors/custom-default-backend.yaml @@ -44,3 +44,19 @@ spec: # env: # - name: DEBUG # value: "true" + + # Mounting custom error page from configMap + # volumeMounts: + # - name: custom_error_pages + # mountPath: /www + + # Mounting custom error page from configMap + # volumes: + # - name: custom_error_pages + # configMap: + # name: custom_error_pages + # items: + # - key: "404" + # path: "404.html" + # - key: "503" + # path: "503.html"