This is an automated email from the ASF dual-hosted git repository.
wangyang0918 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/flink-kubernetes-operator.git
The following commit(s) were added to refs/heads/main by this push:
new 3906e66 [FLINK-26817] Update ingress docs with templating examples
3906e66 is described below
commit 3906e66416fd933d091cfa840c4e24cbcf419d41
Author: Matyas Orhidi <[email protected]>
AuthorDate: Wed Mar 23 21:39:35 2022 +0100
[FLINK-26817] Update ingress docs with templating examples
---
docs/content/docs/operations/ingress.md | 80 +++++++++++++++++++++++++++------
1 file changed, 66 insertions(+), 14 deletions(-)
diff --git a/docs/content/docs/operations/ingress.md
b/docs/content/docs/operations/ingress.md
index ff92eea..4850bf8 100644
--- a/docs/content/docs/operations/ingress.md
+++ b/docs/content/docs/operations/ingress.md
@@ -25,33 +25,85 @@ under the License.
-->
# Accessing Flinkās Web UI
-
The Flink Kubernetes Operator, by default, does not change the way the native
kubernetes integration
[exposes](https://nightlies.apache.org/flink/flink-docs-master/docs/deployment/resource-providers/native_kubernetes/#accessing-flinks-web-ui)
the Flink Web UI.
# Ingress
-The Operator also supports creating an optional
[Ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/)
entry for Web UI access. Ingress generation can be turned on by setting the
`ingressDomain` field in the FlinkDeployment:
-
+Beyond the native options, the Operator also supports creating
[Ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/)
entries for external UI access.
+Ingress generation can be turned on by defining the `ingress` field in the
`FlinkDeployment`:
```yaml
-apiVersion: flink.apache.org/v1alpha1
-kind: FlinkDeployment
metadata:
namespace: default
- name: basic-ingress
+ name: advanced-ingress
spec:
image: flink:1.14.3
flinkVersion: v1_14
- ingressDomain: flink.k8s.io
- ...
+ ingress:
+ template: "flink.k8s.io/{{namespace}}/{{name}}(/|$)(.*)"
+ className: "nginx"
+ annotations:
+ nginx.ingress.kubernetes.io/rewrite-target: "/$2"
+```
+The `ingress` specification defines a mandatory `template` field and two
optional fields `className` and `annotations`.
+When the CR is submitted, the Operator substitutes the template variables from
metadata and creates an Ingress entry on the Kubernetes cluster.
+Given the example above the Flink UI could be accessed at
https://flink.k8s.io/default/advanced-ingress/ and the generated Ingress entry
would be:
+```yaml
+apiVersion: networking.k8s.io/v1
+ kind: Ingress
+ metadata:
+ annotations:
+ nginx.ingress.kubernetes.io/rewrite-target: /$2
+ name: advanced-ingress
+ namespace: default
+ spec:
+ ingressClassName: nginx
+ rules:
+ - host: flink.k8s.io
+ - http:
+ paths:
+ - backend:
+ service:
+ name: advanced-ingress-rest
+ port:
+ number: 8081
+ path: /default/advanced-ingress(/|$)(.*)
+ pathType: ImplementationSpecific
```
-The Operator takes the `name`, `namespace` and `ingressDomain` values from the
CR and creates an Ingress entry using the template
`{{name}}.{{namespace}}.{{ingressDomain}}` as the host. This requires that
anything `*.flink.k8s.io` should be routed to the Ingress Controller on the
Kubernetes cluster.
+>Note: Flink Web UI is built with the popular [Angular](https://angular.io)
framework and uses relative path to load static resources, hence the endpoint
URL must end with trailing a `/` when accessing it from browsers through a
proxy otherwise the main page appears as blank.
+> In order to support accessing base URLs without a trailing `/` the URLs can
be [redirected](https://github.com/kubernetes/ingress-nginx/issues/4266). When
using NGINX as ingress-controller this can be achieved by adding an extra
annotation to the Ingress definition:
+```yaml
+nginx.ingress.kubernetes.io/configuration-snippet: |
+if ($uri = "/default/advanced-ingress") {rewrite .*
$1/default/advanced-ingress/ permanent;}
+```
+Beyond the example above the Operator understands other template formats too:
+**Simple domain based routing:**
+```yaml
+ingress:
+ template: "{{name}}.{{namespace}}.flink.k8s.io"
+```
+This example requires that anything `*.flink.k8s.io` must be routed to the
Ingress Controller with a wildcard DNS entry:
```shell
-kubectl get ingress
-NAME CLASS HOSTS ADDRESS
PORTS AGE
-basic-ingress nginx basic-ingress.default.flink.k8s.io 192.168.49.2
80 30m
-basic-ingress2 nginx basic-ingress2.default.flink.k8s.io 192.168.49.2
80 3m39s
+kubectl get ingress -A
+NAMESPACE NAME CLASS HOSTS
ADDRESS PORTS AGE
+default sample-job nginx sample-job.default.flink.k8s.io
192.168.49.2 80 30m
+```
+The Flink Web UI can be accessed at https://sample-job.default.flink.k8s.io
+
+**Simple path based routing:**
+```yaml
+ingress:
+ template: "/{{namespace}}/{{name}}(/|$)(.*)"
+ annotations:
+ nginx.ingress.kubernetes.io/rewrite-target: "/$2"
```
+This example requires no DNS entries.
-The examples above were created on a minikube cluster. Check the
[description](https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/)
for easily enabling the NGINX Ingress Controller on minikube.
+```shell
+kubectl get ingress -A
+NAMESPACE NAME CLASS HOSTS ADDRESS PORTS AGE
+default sample-job nginx * localhost 80 54m
+```
+The Flink Web UI can be accessed at https://localhost/defalt/sample-job/
+>Note: All the examples were created on a minikube cluster. Check the
[description](https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/)
for easily enabling the NGINX Ingress Controller on minikube.