From 5a1729d4f7cf4cd01ef82d5c1fa46d25768c1f86 Mon Sep 17 00:00:00 2001 From: Melissa Lee Date: Tue, 5 Apr 2022 11:13:07 -0400 Subject: [PATCH 1/3] Set ImplementationSpecific as default for Ingress path type --- doc/user-guide-v1beta2.adoc | 5 +++-- utils/utils.go | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/user-guide-v1beta2.adoc b/doc/user-guide-v1beta2.adoc index 2cb64934e..5fb6f567f 100644 --- a/doc/user-guide-v1beta2.adoc +++ b/doc/user-guide-v1beta2.adoc @@ -106,7 +106,7 @@ Each `RuntimeComponent` CR must at least specify the `.spec.applicationImage` fi | `route.annotations` | Annotations to be added to the Route. | `route.host` | Hostname to be used for the Route. | `route.path` | Path to be used for Route. -| `route.pathType` | Path type to be used. Required field for Ingress. See link:++https://kubernetes.io/docs/concepts/services-networking/ingress/#path-types++[Ingress path types]. +| `route.pathType` | Path type to specify how Ingress paths should be matched. Required field for Ingress. If not specified, the default value is `ImplementationSpecific`. See link:++https://kubernetes.io/docs/concepts/services-networking/ingress/#path-types++[Ingress path types]. | `route.termination` | TLS termination policy. Can be one of `edge`, `reencrypt` and `passthrough`. | `route.insecureEdgeTerminationPolicy` | HTTP traffic policy with TLS enabled. Can be one of `Allow`, `Redirect` and `None`. | `route.certificateSecretRef` | A name of a secret that already contains TLS key, certificate and CA to be used in the route. It can also contain destination CA certificate. The following keys are valid in the secret: `ca.crt`, `destCA.crt`, `tls.crt`, and `tls.key`. @@ -548,6 +548,7 @@ _The Ingress resource is created only if the `Route` resource is not available o To use the Ingress resource, set the `defaultHostName` variable in the _runtime-component-operator_ ConfigMap object to a host name such as _mycompany.com_ +The Ingress resource requires `pathType` field to be specified. `pathType` can be specified using `.spec.route.pathType` field. If `.spec.route.pathType` is not specified in a CR, it is set to `ImplementationSpecific` by default. ===== Simple Ingress that uses `defaultHostName` and no `TLS`: @@ -586,7 +587,7 @@ spec: ===== Advanced Ingress configuration: -Most of the Ingress configuraiton is achieved through annotations. Annotations such as Nginx, HAProxy, Traefik, and others are specific to the ingress controller implementation. +Most of the Ingress configuration is achieved through annotations. Annotations such as Nginx, HAProxy, Traefik, and others are specific to the ingress controller implementation. You can provide an existing TLS secret and set a custom hostname. diff --git a/utils/utils.go b/utils/utils.go index d98cb7b71..6e9423c2e 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -924,6 +924,10 @@ func CustomizeIngress(ing *networkingv1.Ingress, ba common.BaseComponent) { l.Info("No Ingress hostname is provided. Ingress might not function correctly without hostname. It is recommended to set Ingress host or to provide default value through operator's config map.") } + if pathType == "" { + pathType = "ImplementationSpecific" + } + ing.Spec.Rules = []networkingv1.IngressRule{ { Host: host, From 068b4ca3ad77a1787c3e68f2c0c752fb5c66128b Mon Sep 17 00:00:00 2001 From: Melissa Lee Date: Tue, 5 Apr 2022 12:04:02 -0400 Subject: [PATCH 2/3] Edit kuttl tests for ingress --- .../scorecard/minikube-kuttl/ingress/01-assert.yaml | 13 +++++++++++++ .../minikube-kuttl/ingress/01-default-pathtype.yaml | 10 ++++++++++ .../scorecard/minikube-kuttl/ingress/02-assert.yaml | 8 ++++++++ ...1-delete-ingress.yaml => 02-delete-ingress.yaml} | 0 .../ingress/{01-errors.yaml => 02-errors.yaml} | 0 utils/utils.go | 5 +++-- 6 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 bundle/tests/scorecard/minikube-kuttl/ingress/01-default-pathtype.yaml create mode 100644 bundle/tests/scorecard/minikube-kuttl/ingress/02-assert.yaml rename bundle/tests/scorecard/minikube-kuttl/ingress/{01-delete-ingress.yaml => 02-delete-ingress.yaml} (100%) rename bundle/tests/scorecard/minikube-kuttl/ingress/{01-errors.yaml => 02-errors.yaml} (100%) diff --git a/bundle/tests/scorecard/minikube-kuttl/ingress/01-assert.yaml b/bundle/tests/scorecard/minikube-kuttl/ingress/01-assert.yaml index 8902dd486..e7f2fa356 100644 --- a/bundle/tests/scorecard/minikube-kuttl/ingress/01-assert.yaml +++ b/bundle/tests/scorecard/minikube-kuttl/ingress/01-assert.yaml @@ -6,3 +6,16 @@ status: replicas: 1 readyReplicas: 1 updatedReplicas: 1 +--- +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: ingress +spec: + rules: + - host: myapp.mycompany.com + http: + paths: + - path: / + pathType: ImplementationSpecific + diff --git a/bundle/tests/scorecard/minikube-kuttl/ingress/01-default-pathtype.yaml b/bundle/tests/scorecard/minikube-kuttl/ingress/01-default-pathtype.yaml new file mode 100644 index 000000000..258673a2c --- /dev/null +++ b/bundle/tests/scorecard/minikube-kuttl/ingress/01-default-pathtype.yaml @@ -0,0 +1,10 @@ +apiVersion: rc.app.stacks/v1beta2 +kind: RuntimeComponent +metadata: + name: ingress +spec: + # Add fields here + route: + host: myapp.mycompany.com + path: "/" + pathType: diff --git a/bundle/tests/scorecard/minikube-kuttl/ingress/02-assert.yaml b/bundle/tests/scorecard/minikube-kuttl/ingress/02-assert.yaml new file mode 100644 index 000000000..8902dd486 --- /dev/null +++ b/bundle/tests/scorecard/minikube-kuttl/ingress/02-assert.yaml @@ -0,0 +1,8 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ingress +status: + replicas: 1 + readyReplicas: 1 + updatedReplicas: 1 diff --git a/bundle/tests/scorecard/minikube-kuttl/ingress/01-delete-ingress.yaml b/bundle/tests/scorecard/minikube-kuttl/ingress/02-delete-ingress.yaml similarity index 100% rename from bundle/tests/scorecard/minikube-kuttl/ingress/01-delete-ingress.yaml rename to bundle/tests/scorecard/minikube-kuttl/ingress/02-delete-ingress.yaml diff --git a/bundle/tests/scorecard/minikube-kuttl/ingress/01-errors.yaml b/bundle/tests/scorecard/minikube-kuttl/ingress/02-errors.yaml similarity index 100% rename from bundle/tests/scorecard/minikube-kuttl/ingress/01-errors.yaml rename to bundle/tests/scorecard/minikube-kuttl/ingress/02-errors.yaml diff --git a/utils/utils.go b/utils/utils.go index 6e9423c2e..74cd74d02 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -901,7 +901,8 @@ func CustomizeIngress(ing *networkingv1.Ingress, ba common.BaseComponent) { servicePort := strconv.Itoa(int(ba.GetService().GetPort())) + "-tcp" host := "" path := "" - var pathType networkingv1.PathType + pathType := networkingv1.PathType("") + rt := ba.GetRoute() if rt != nil { host = rt.GetHost() @@ -925,7 +926,7 @@ func CustomizeIngress(ing *networkingv1.Ingress, ba common.BaseComponent) { } if pathType == "" { - pathType = "ImplementationSpecific" + pathType = networkingv1.PathTypeImplementationSpecific } ing.Spec.Rules = []networkingv1.IngressRule{ From d2fba5b2f316ce9dcb2d510ccdd943d33ef5eda1 Mon Sep 17 00:00:00 2001 From: Melissa Lee Date: Tue, 5 Apr 2022 13:55:30 -0400 Subject: [PATCH 3/3] User guide edit --- doc/user-guide-v1beta2.adoc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/user-guide-v1beta2.adoc b/doc/user-guide-v1beta2.adoc index 5fb6f567f..c4e9f4d81 100644 --- a/doc/user-guide-v1beta2.adoc +++ b/doc/user-guide-v1beta2.adoc @@ -106,7 +106,7 @@ Each `RuntimeComponent` CR must at least specify the `.spec.applicationImage` fi | `route.annotations` | Annotations to be added to the Route. | `route.host` | Hostname to be used for the Route. | `route.path` | Path to be used for Route. -| `route.pathType` | Path type to specify how Ingress paths should be matched. Required field for Ingress. If not specified, the default value is `ImplementationSpecific`. See link:++https://kubernetes.io/docs/concepts/services-networking/ingress/#path-types++[Ingress path types]. +| `route.pathType` | Path type to be used. Required field for Ingress. See link:++https://kubernetes.io/docs/concepts/services-networking/ingress/#path-types++[Ingress path types]. | `route.termination` | TLS termination policy. Can be one of `edge`, `reencrypt` and `passthrough`. | `route.insecureEdgeTerminationPolicy` | HTTP traffic policy with TLS enabled. Can be one of `Allow`, `Redirect` and `None`. | `route.certificateSecretRef` | A name of a secret that already contains TLS key, certificate and CA to be used in the route. It can also contain destination CA certificate. The following keys are valid in the secret: `ca.crt`, `destCA.crt`, `tls.crt`, and `tls.key`. @@ -548,7 +548,6 @@ _The Ingress resource is created only if the `Route` resource is not available o To use the Ingress resource, set the `defaultHostName` variable in the _runtime-component-operator_ ConfigMap object to a host name such as _mycompany.com_ -The Ingress resource requires `pathType` field to be specified. `pathType` can be specified using `.spec.route.pathType` field. If `.spec.route.pathType` is not specified in a CR, it is set to `ImplementationSpecific` by default. ===== Simple Ingress that uses `defaultHostName` and no `TLS`: