Skip to content

Commit

Permalink
Merge pull request #218 from RedHatInsights/ingress-annotations
Browse files Browse the repository at this point in the history
Ingress annotations
  • Loading branch information
adamrdrew authored Nov 7, 2024
2 parents 406c072 + 43f9bdc commit e42c008
Show file tree
Hide file tree
Showing 9 changed files with 269 additions and 13 deletions.
3 changes: 3 additions & 0 deletions api/v1alpha1/frontendenvironment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ type FrontendEnvironmentSpec struct {

// Ingress class
IngressClass string `json:"ingressClass,omitempty"`
// Ingress annotations
// These annotations will be applied to the ingress objects created by the frontend
IngressAnnotations map[string]string `json:"ingressAnnotations,omitempty"`

// Hostname
Hostname string `json:"hostname,omitempty"`
Expand Down
7 changes: 7 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions config/crd/bases/cloud.redhat.com_frontendenvironments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ spec:
hostname:
description: Hostname
type: string
ingressAnnotations:
additionalProperties:
type: string
description: |-
Ingress annotations
These annotations will be applied to the ingress objects created by the frontend
type: object
ingressClass:
description: Ingress class
type: string
Expand Down
11 changes: 11 additions & 0 deletions controllers/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,17 @@ func (r *FrontendReconciliation) createAnnotationsAndPopulate(nn types.Namespace
ingressClass = "nginx"
}

if r.FrontendEnvironment.Spec.IngressAnnotations != nil {
annotations := netobj.GetAnnotations()
if annotations == nil {
annotations = map[string]string{}
}
for k, v := range r.FrontendEnvironment.Spec.IngressAnnotations {
annotations[k] = v
}
netobj.SetAnnotations(annotations)
}

if len(r.FrontendEnvironment.Spec.Whitelist) != 0 {
annotations := netobj.GetAnnotations()
if annotations == nil {
Expand Down
8 changes: 8 additions & 0 deletions deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,14 @@ objects:
hostname:
description: Hostname
type: string
ingressAnnotations:
additionalProperties:
type: string
description: 'Ingress annotations
These annotations will be applied to the ingress objects created
by the frontend'
type: object
ingressClass:
description: Ingress class
type: string
Expand Down
161 changes: 148 additions & 13 deletions docs/antora/modules/ROOT/pages/api_reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,12 @@ BundleList contains a list of Bundle




Deprecated: Use ChromeNavItem instead, has to be switched for the updated reconciliation, needs to exist to prevent breaking changes for the Fronted resources and legacy NavItems attribute



.Appears In:
****
- xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-bundlespec[$$BundleSpec$$]
- xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-computedbundle[$$ComputedBundle$$]
- xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-extranavitem[$$ExtraNavItem$$]
- xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-frontendspec[$$FrontendSpec$$]
****

Expand Down Expand Up @@ -209,10 +206,51 @@ BundleSpec defines the desired state of Bundle
| *`appList`* __string array__ | | |
| *`envName`* __string__ | | |
| *`extraNavItems`* __xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-extranavitem[$$ExtraNavItem$$] array__ | | |
| *`customNav`* __xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-bundlenavitem[$$BundleNavItem$$] array__ | | |
| *`customNav`* __xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-chromenavitem[$$ChromeNavItem$$] array__ | | |
|===




[id="{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-chromenavitem"]
==== ChromeNavItem







.Appears In:
****
- xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-bundlespec[$$BundleSpec$$]
- xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-chromenavitem[$$ChromeNavItem$$]
- xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-computedbundle[$$ComputedBundle$$]
- xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-extranavitem[$$ExtraNavItem$$]
- xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-navigationsegment[$$NavigationSegment$$]
****

[cols="20a,50a,15a,15a", options="header"]
|===
| Field | Description | Default | Validation
| *`isHidden`* __boolean__ | | |
| *`expandable`* __boolean__ | | |
| *`href`* __string__ | | |
| *`appId`* __string__ | | |
| *`isExternal`* __boolean__ | | |
| *`title`* __string__ | | |
| *`groupId`* __string__ | | |
| *`id`* __string__ | | |
| *`product`* __string__ | | |
| *`notifier`* __string__ | | |
| *`icon`* __string__ | | |
| *`isBeta`* __boolean__ | | |
| *`navItems`* __xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-chromenavitem[$$ChromeNavItem$$] array__ | kubebuilder struggles validating recursive fields, it has to be helped a bit + | | Schemaless: {} +

| *`routes`* __xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-chromenavitem[$$ChromeNavItem$$] array__ | | | Schemaless: {} +

| *`permissions`* __xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-permission[$$Permission$$] array__ | | |
|===



Expand Down Expand Up @@ -260,7 +298,7 @@ EmbeddedRoutes allow deeply nested navs to have support for routes
|===
| Field | Description | Default | Validation
| *`name`* __string__ | | |
| *`navItem`* __xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-bundlenavitem[$$BundleNavItem$$]__ | | |
| *`navItem`* __xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-chromenavitem[$$ChromeNavItem$$]__ | | |
|===


Expand Down Expand Up @@ -406,6 +444,8 @@ FrontendEnvironmentSpec defines the desired state of FrontendEnvironment
| Field | Description | Default | Validation
| *`sso`* __string__ | Foo is an example field of FrontendEnvironment. Edit FrontendEnvironment_types.go to remove/update + | |
| *`ingressClass`* __string__ | Ingress class + | |
| *`ingressAnnotations`* __object (keys:string, values:string)__ | Ingress annotations +
These annotations will be applied to the ingress objects created by the frontend + | |
| *`hostname`* __string__ | Hostname + | |
| *`whitelist`* __string array__ | Whitelist CIDRs + | |
| *`monitoring`* __xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-monitoringconfig[$$MonitoringConfig$$]__ | MonitorMode determines where a ServiceMonitor object will be placed +
Expand All @@ -422,6 +462,7 @@ do this in epehemeral environments but not in production + | |
| *`akamaiSecretName`* __string__ | The name of the secret we will use to get the akamai credentials + | |
| *`targetNamespaces`* __string array__ | List of namespaces that should receive a copy of the frontend configuration as a config map +
By configurations we mean the fed-modules.json, navigation files, etc. + | |
| *`serviceCategories`* __xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-frontendservicecategory[$$FrontendServiceCategory$$]__ | For the ChromeUI to render additional global components + | |
|===


Expand Down Expand Up @@ -470,6 +511,77 @@ FrontendList contains a list of Frontend
|===


[id="{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-frontendservicecategory"]
==== FrontendServiceCategory



FrontendServiceCategory defines the category to which service can inject ServiceTiles
Chroming UI will use this to render the service dropdown component



.Appears In:
****
- xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-frontendenvironmentspec[$$FrontendEnvironmentSpec$$]
****

[cols="20a,50a,15a,15a", options="header"]
|===
| Field | Description | Default | Validation
| *`id`* __string__ | | |
| *`title`* __string__ | | |
| *`groups`* __xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-frontendservicecategorygroup[$$FrontendServiceCategoryGroup$$] array__ | | |
|===




[id="{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-frontendservicecategorygroup"]
==== FrontendServiceCategoryGroup







.Appears In:
****
- xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-frontendservicecategory[$$FrontendServiceCategory$$]
****

[cols="20a,50a,15a,15a", options="header"]
|===
| Field | Description | Default | Validation
| *`id`* __string__ | | |
| *`title`* __string__ | | |
|===


[id="{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-frontendservicecategorygroupgenerated"]
==== FrontendServiceCategoryGroupGenerated







.Appears In:
****
- xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-frontendservicecategorygenerated[$$FrontendServiceCategoryGenerated$$]
****

[cols="20a,50a,15a,15a", options="header"]
|===
| Field | Description | Default | Validation
| *`id`* __string__ | | |
| *`title`* __string__ | | |
| *`tiles`* __xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-servicetile[$$ServiceTile$$]__ | | |
|===


[id="{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-frontendspec"]
==== FrontendSpec

Expand Down Expand Up @@ -498,6 +610,7 @@ FrontendSpec defines the desired state of Frontend
| *`serviceMonitor`* __xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-servicemonitorconfig[$$ServiceMonitorConfig$$]__ | | |
| *`module`* __xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-fedmodule[$$FedModule$$]__ | | |
| *`navItems`* __xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-bundlenavitem[$$BundleNavItem$$] array__ | | |
| *`navigationSegments`* __xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-navigationsegment[$$NavigationSegment$$] array__ | navigation segments for the frontend + | |
| *`assetsPrefix`* __string__ | | |
| *`akamaiCacheBustDisable`* __boolean__ | Akamai cache bust opt-out + | |
| *`akamaiCacheBustPaths`* __string array__ | Files to cache bust + | |
Expand Down Expand Up @@ -611,8 +724,8 @@ FrontendSpec defines the desired state of Frontend
|===


[id="{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-permission"]
==== Permission
[id="{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-navigationsegment"]
==== NavigationSegment



Expand All @@ -622,19 +735,39 @@ FrontendSpec defines the desired state of Frontend

.Appears In:
****
- xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-route[$$Route$$]
- xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-widgetconfig[$$WidgetConfig$$]
- xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-frontendspec[$$FrontendSpec$$]
****

[cols="20a,50a,15a,15a", options="header"]
|===
| Field | Description | Default | Validation
| *`method`* __string__ | | |
| *`apps`* __string array__ | | |
| *`args`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#json-v1-apiextensions-k8s-io[$$JSON$$]__ | | |
| *`sectionId`* __string__ | | |
| *`bundleId`* __string__ | Id of the bundle to which the segment should be injected + | |
| *`position`* __integer__ | A position of the segment within the bundle +
0 is the first position +
The position "steps" should be at least 100 to make sure there is enough space in case some segments should be injected between existing ones + | |
| *`navItems`* __xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-chromenavitem[$$ChromeNavItem$$]__ | | |
|===


[id="{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-permission"]
==== Permission

_Underlying type:_ _xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-struct-method string -json-method- yaml-method- apps -string -json-apps-omitempty- yaml-apps-omitempty- args -k8s-io-apiextensions-apiserver-pkg-apis-apiextensions-v1-json -json-args-omitempty- yaml-args-omitempty-[$$struct{Method string "json:\"method\" yaml:\"method\""; Apps []string "json:\"apps,omitempty\" yaml:\"apps,omitempty\""; Args *k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1.JSON "json:\"args,omitempty\" yaml:\"args,omitempty\""}$$]_





.Appears In:
****
- xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-chromenavitem[$$ChromeNavItem$$]
- xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-route[$$Route$$]
- xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-widgetconfig[$$WidgetConfig$$]
****



[id="{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-route"]
==== Route

Expand Down Expand Up @@ -721,6 +854,7 @@ FrontendSpec defines the desired state of Frontend

.Appears In:
****
- xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-frontendservicecategorygroupgenerated[$$FrontendServiceCategoryGroupGenerated$$]
- xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-frontendspec[$$FrontendSpec$$]
****

Expand All @@ -732,6 +866,7 @@ FrontendSpec defines the desired state of Frontend
| *`id`* __string__ | | |
| *`href`* __string__ | | |
| *`title`* __string__ | | |
| *`description`* __string__ | | |
| *`icon`* __string__ | | |
| *`isExternal`* __boolean__ | | |
|===
Expand Down
8 changes: 8 additions & 0 deletions tests/e2e/ingress-annotations/00-create-namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: test-ingress-annotations
spec:
finalizers:
- kubernetes
34 changes: 34 additions & 0 deletions tests/e2e/ingress-annotations/01-create-resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
apiVersion: cloud.redhat.com/v1alpha1
kind: FrontendEnvironment
metadata:
name: test-ingress-annotations-environment
spec:
generateNavJSON: false
ssl: false
hostname: foo.redhat.com
sso: https://sso.foo.redhat.com
ingressAnnotations:
"nginx.ingress.kubernetes.io/rewrite-target" : "/"
---
apiVersion: cloud.redhat.com/v1alpha1
kind: Frontend
metadata:
name: chrome
namespace: test-ingress-annotations
spec:
API:
versions:
- v1
frontend:
paths:
- /
deploymentRepo: https://github.com/RedHatInsights/insights-chrome
envName: test-ingress-annotations-environment
image: quay.io/cloudservices/insights-chrome-frontend:720317c
module:
config:
ssoUrl: 'https://'
manifestLocation: /apps/chrome/js/fed-mods.json
title: Chrome

Loading

0 comments on commit e42c008

Please sign in to comment.