Skip to content

Commit e762b88

Browse files
authored
Merge pull request #34 from appuio/fix/custom-logo-favicon
Generate favicon `Route` if a custom logo is configured
2 parents e5677c9 + 4862292 commit e762b88

File tree

9 files changed

+146
-1
lines changed

9 files changed

+146
-1
lines changed

.github/workflows/test.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
- custom-route-legacy-4.7
4040
- custom-route-managed-tls
4141
- custom-links
42+
- custom-logo
4243
defaults:
4344
run:
4445
working-directory: ${{ env.COMPONENT_NAME }}
@@ -60,6 +61,7 @@ jobs:
6061
- custom-route-legacy-4.7
6162
- custom-route-managed-tls
6263
- custom-links
64+
- custom-logo
6365
defaults:
6466
run:
6567
working-directory: ${{ env.COMPONENT_NAME }}

.sync.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- custom-route-legacy-4.7
1212
- custom-route-managed-tls
1313
- custom-links
14+
- custom-logo
1415

1516
.github/workflows/test.yaml:
1617
goldenTest_makeTarget: golden-diff -e instance=${{ matrix.instance }}

Makefile.vars.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ COMPILE_CMD ?= $(COMMODORE_CMD) component compile . $(commodore_args)
4141
JB_CMD ?= $(DOCKER_CMD) $(DOCKER_ARGS) --entrypoint /usr/local/bin/jb docker.io/projectsyn/commodore:latest install
4242

4343
instance ?= defaults
44-
test_instances = tests/defaults.yml tests/custom-route.yml tests/custom-route-4.7.yml tests/custom-route-legacy.yml tests/custom-route-legacy-4.7.yml tests/custom-route-managed-tls.yml tests/custom-links.yml
44+
test_instances = tests/defaults.yml tests/custom-route.yml tests/custom-route-4.7.yml tests/custom-route-legacy.yml tests/custom-route-legacy-4.7.yml tests/custom-route-managed-tls.yml tests/custom-links.yml tests/custom-logo.yml

component/main.jsonnet

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,38 @@ local consoleSpec =
100100
{}
101101
);
102102

103+
local faviconRoute =
104+
if logoFileName != '' && hostname != null then
105+
kube._Object('route.openshift.io/v1', 'Route', 'console-favicon') {
106+
metadata+: {
107+
namespace: 'openshift-console',
108+
labels+: {
109+
app: 'console',
110+
},
111+
annotations+: {
112+
'haproxy.router.openshift.io/rewrite-target':
113+
'/static/assets/openshift-favicon.png',
114+
},
115+
},
116+
spec: {
117+
host: hostname,
118+
path: '/favicon.ico',
119+
to: {
120+
kind: 'Service',
121+
name: 'console',
122+
weight: 100,
123+
},
124+
port: {
125+
targetPort: 'https',
126+
},
127+
tls: {
128+
termination: 'reencrypt',
129+
insecureEdgeTerminationPolicy: 'Redirect',
130+
},
131+
wildcardPolicy: 'None',
132+
},
133+
};
134+
103135
// Create ResourceLocker patch to configure console route in
104136
// ingress.config.openshift.io/cluster object
105137
local consoleRoutePatch =
@@ -224,6 +256,8 @@ local openshiftConfigNsAnnotationPatch =
224256
'10_console': kube._Object(versionGroup, 'Console', 'cluster') {
225257
spec+: consoleSpec,
226258
},
259+
[if faviconRoute != null then '10_console_favicon_route']:
260+
faviconRoute,
227261
[if !oldConfig && consoleRoutePatch != null then '20_ingress_config_patch']:
228262
consoleRoutePatch,
229263
[if openshiftConfigNsAnnotationPatch != null then '20_openshift_config_ns_annotation_patch']:

docs/modules/ROOT/pages/references/parameters.adoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ The filename needs to have a filename extension which matches the image format.
114114
For SVG logos the file must *not* be base64 encoded, but inserted directly as a string.
115115
====
116116

117+
By default, OCP won't serve a favicon if a custom logo is configured for the console.
118+
This is an intentional design decision as documented in this https://bugzilla.redhat.com/show_bug.cgi?id=1844883#c1[bug report].
119+
120+
The component tries to ensure that a favicon is served even if a custom logo is configured.
121+
However, because the current workaround for the missing favicon requires an additional custom route for the console hostname, it can only be implemented for configurations which use a custom console hostname.
122+
Otherwise, the component is unable to correctly configure `spec.hostname` for the console.
123+
117124
== `secrets`
118125

119126
[horizontal]

tests/custom-logo.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
parameters:
2+
kapitan:
3+
dependencies:
4+
- type: https
5+
source: https://raw.githubusercontent.com/projectsyn/component-resource-locker/v2.1.0/lib/resource-locker.libjsonnet
6+
output_path: vendor/lib/resource-locker.libjsonnet
7+
8+
resource_locker:
9+
namespace: syn-resource-locker
10+
211
openshift4_console:
312
config:
13+
route:
14+
hostname: console.company.cloud
15+
secret:
16+
name: console-company-cloud-tls
417
customization:
518
customProductName: Company Cloud
619
custom_logo:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
apiVersion: v1
22
kind: Namespace
33
metadata:
4+
annotations:
5+
openshift.io/node-selector: node-role.kubernetes.io/master=
46
labels:
57
name: openshift-console
68
name: openshift-console
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: route.openshift.io/v1
2+
kind: Route
3+
metadata:
4+
annotations:
5+
haproxy.router.openshift.io/rewrite-target: /static/assets/openshift-favicon.png
6+
labels:
7+
app: console
8+
name: console-favicon
9+
name: console-favicon
10+
namespace: openshift-console
11+
spec:
12+
host: console.company.cloud
13+
path: /favicon.ico
14+
port:
15+
targetPort: https
16+
tls:
17+
insecureEdgeTerminationPolicy: Redirect
18+
termination: reencrypt
19+
to:
20+
kind: Service
21+
name: console
22+
weight: 100
23+
wildcardPolicy: None
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
labels:
5+
name: cluster-manager
6+
name: cluster-manager
7+
namespace: syn-resource-locker
8+
---
9+
apiVersion: rbac.authorization.k8s.io/v1
10+
kind: ClusterRole
11+
metadata:
12+
labels:
13+
name: syn-resource-locker-cluster-manager
14+
name: syn-resource-locker-cluster-manager
15+
rules:
16+
- apiGroups:
17+
- config.openshift.io
18+
resources:
19+
- ingresses
20+
verbs:
21+
- get
22+
- list
23+
- patch
24+
- watch
25+
---
26+
apiVersion: rbac.authorization.k8s.io/v1
27+
kind: ClusterRoleBinding
28+
metadata:
29+
labels:
30+
name: syn-resource-locker-cluster-manager
31+
name: syn-resource-locker-cluster-manager
32+
roleRef:
33+
apiGroup: rbac.authorization.k8s.io
34+
kind: ClusterRole
35+
name: syn-resource-locker-cluster-manager
36+
subjects:
37+
- kind: ServiceAccount
38+
name: cluster-manager
39+
namespace: syn-resource-locker
40+
---
41+
apiVersion: redhatcop.redhat.io/v1alpha1
42+
kind: ResourceLocker
43+
metadata:
44+
annotations:
45+
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
46+
argocd.argoproj.io/sync-wave: '10'
47+
labels:
48+
name: cluster
49+
name: cluster
50+
namespace: syn-resource-locker
51+
spec:
52+
patches:
53+
- id: patch1
54+
patchTemplate: "\"spec\":\n \"componentRoutes\":\n - \"hostname\": \"console.company.cloud\"\
55+
\n \"name\": \"console\"\n \"namespace\": \"openshift-console\"\n \
56+
\ \"servingCertKeyPairSecret\":\n \"name\": \"console-company-cloud-tls\""
57+
patchType: application/merge-patch+json
58+
targetObjectRef:
59+
apiVersion: config.openshift.io/v1
60+
kind: Ingress
61+
name: cluster
62+
serviceAccountRef:
63+
name: cluster-manager

0 commit comments

Comments
 (0)