Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set ImplementationSpecific as default for Ingress path type #363

Merged
merged 3 commits into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions bundle/tests/scorecard/minikube-kuttl/ingress/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Original file line number Diff line number Diff line change
@@ -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:
8 changes: 8 additions & 0 deletions bundle/tests/scorecard/minikube-kuttl/ingress/02-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ingress
status:
replicas: 1
readyReplicas: 1
updatedReplicas: 1
5 changes: 3 additions & 2 deletions doc/user-guide-v1beta2.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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].
halim-lee marked this conversation as resolved.
Show resolved Hide resolved
| `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`.
Expand Down Expand Up @@ -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`:

Expand Down Expand Up @@ -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.

Expand Down
7 changes: 6 additions & 1 deletion utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -924,6 +925,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 = networkingv1.PathTypeImplementationSpecific
}

ing.Spec.Rules = []networkingv1.IngressRule{
{
Host: host,
Expand Down