Added ingressClass to route trait (#947)

* Added ingressClass to route trait

* typo

Co-authored-by: Jianbo Sun <wonderflow.sun@gmail.com>

* run make reviewable

* fixed ingress test

Co-authored-by: Jianbo Sun <wonderflow.sun@gmail.com>
This commit is contained in:
Holger Protzek
2021-02-02 02:52:20 +01:00
committed by GitHub
parent e5a9721fa5
commit f737379738
8 changed files with 23 additions and 7 deletions

View File

@@ -43,6 +43,9 @@ type RouteSpec struct {
// Provider indicate which ingress controller implementation the route trait will use, by default it's nginx-ingress
Provider string `json:"provider,omitempty"`
// IngressClass indicate which ingress class the route trait will use, by default it's nginx
IngressClass string `json:"ingressClass,omitempty"`
}
// Rule defines to route rule

View File

@@ -37,6 +37,9 @@ spec:
host:
description: Host is the host of the route
type: string
ingressClass:
description: IngressClass indicate which ingress class the route trait will use, by default it's nginx
type: string
provider:
description: Provider indicate which ingress controller implementation the route trait will use, by default it's nginx-ingress
type: string

View File

@@ -29,6 +29,9 @@ type RouteSpec struct {
// Provider indicate which ingress controller implementation the route trait will use, by default it's nginx-ingress
Provider string `json:"provider,omitempty"`
// IngressClass indicate which ingress class the route trait will use, by default it's nginx
IngressClass string `json:"ingressClass,omitempty"`
}
// Rule defines to route rule
@@ -92,7 +95,8 @@ Besides `workloadRef`, one Route will have only one `host` and many rules. `host
It's required and will be used to generate mTLS secrets.
Route Trait designed to be compatible with different ingress controller implementations, the `provider` field will allow
you to give a specified ingress controller type. Currently, only nginx-ingress is supported.
you to give a specified ingress controller type. The `ingressClass` field will allow you to set the ingressClass.
Currently, only nginx-ingress is supported.
The `tls` field allow you to specify a TLS for this route with an IssuerName, the IssuerName pointing to an [Issuer Object](https://cert-manager.io/docs/concepts/issuer/)
created by cert-manager. Cert-manager and ingress controller will handle certificate creation and binding.
@@ -148,4 +152,3 @@ route trait will check `WorkloadDefinition` for podSpec field, with the `podSpec
- 2.2 Use ChildResource: If No `PodSpecable` mechanism found in workload, we will continue discovery child resources of workload. If there
is a valid `PodTemplate` structure in child resource, we will regard it as discovery target, use the same strategy like
`workload.oam.dev/podspecable: true` but no `podSpecPath`.

View File

@@ -29,7 +29,8 @@ Name | Description | Type | Required | Default
domain | Domain name | string | true | empty
issuer | | string | true | empty
rules | | [[]rules](#rules) | false |
provider | | string | false |
provider | | string | false |
ingressClass | | string | false |
### rules

View File

@@ -35,7 +35,8 @@ spec:
rules: parameter.rules
}
provider: *"nginx" | parameter.provider
provider: *"nginx" | parameter.provider
ingressClass: *"nginx" | parameter.ingressClass
}
}
parameter: {
@@ -47,6 +48,7 @@ spec:
path: string
rewriteTarget: *"" | string
}]
provider?: string
provider?: string
ingressClass?: string
}

View File

@@ -37,6 +37,9 @@ spec:
host:
description: Host is the host of the route
type: string
ingressClass:
description: IngressClass indicate which ingress class the route trait will use, by default it's nginx
type: string
provider:
description: Provider indicate which ingress controller implementation the route trait will use, by default it's nginx-ingress
type: string

View File

@@ -121,7 +121,7 @@ func (*Nginx) Construct(routeTrait *standardv1alpha1.Route) []*v1beta1.Ingress {
var annotations = make(map[string]string)
annotations["kubernetes.io/ingress.class"] = TypeNginx
annotations["kubernetes.io/ingress.class"] = routeTrait.Spec.IngressClass
// SSL
if routeTrait.Spec.TLS != nil {

View File

@@ -46,6 +46,7 @@ func TestConstruct(t *testing.T) {
},
},
},
IngressClass: "nginx-private",
},
},
exp: []*v1beta1.Ingress{
@@ -57,7 +58,7 @@ func TestConstruct(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{
Name: "trait-test-myrule1",
Annotations: map[string]string{
"kubernetes.io/ingress.class": "nginx",
"kubernetes.io/ingress.class": "nginx-private",
"cert-manager.io/issuer": "test-issuer",
},
OwnerReferences: []metav1.OwnerReference{