Skip to content

Commit dff3275

Browse files
authored
Revert "Refactor nginx config in prod (#7417)" (#7706)
This reverts commit 381ffce.
1 parent 0a9048c commit dff3275

File tree

19 files changed

+85
-73
lines changed

19 files changed

+85
-73
lines changed

components/konflux-ui/production/base/proxy/auth.conf

Lines changed: 0 additions & 5 deletions
This file was deleted.

components/konflux-ui/production/base/proxy/kubearchive.conf

Lines changed: 0 additions & 7 deletions
This file was deleted.

components/konflux-ui/production/base/proxy/kustomization.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,3 @@ configMapGenerator:
77
- name: proxy
88
files:
99
- nginx.conf
10-
- name: proxy-nginx-templates
11-
files:
12-
- auth.conf
13-
- name: proxy-nginx-static
14-
files:
15-
- tekton-results.conf
16-
- tekton-results-workspaces.conf
17-
- kubearchive.conf

components/konflux-ui/production/base/proxy/nginx.conf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,24 @@ http {
139139
include /mnt/nginx-generated-config/auth.conf;
140140
}
141141

142+
# Deprecated
143+
location /api/k8s/plugins/tekton-results/workspaces/ {
144+
auth_request /oauth2/auth;
145+
146+
rewrite /api/k8s/plugins/tekton-results/workspaces/.+?/(.+) /$1 break;
147+
proxy_read_timeout 30m;
148+
include /mnt/nginx-generated-config/tekton-results.conf;
149+
include /mnt/nginx-generated-config/auth.conf;
150+
}
142151

152+
location /api/k8s/plugins/tekton-results/ {
153+
auth_request /oauth2/auth;
154+
155+
rewrite /api/k8s/plugins/tekton-results/(.+) /$1 break;
156+
proxy_read_timeout 30m;
157+
include /mnt/nginx-generated-config/tekton-results.conf;
158+
include /mnt/nginx-generated-config/auth.conf;
159+
}
143160

144161
# GET requests to /api/k8s/api/v1/namespaces and /api/k8s/api/v1/namespaces/
145162
# are handled from the namespace-lister.
@@ -183,5 +200,6 @@ http {
183200
}
184201

185202
include /mnt/nginx-additional-location-configs/*.conf;
203+
include /mnt/nginx-generated-config/kubearchive.conf;
186204
}
187205
}

components/konflux-ui/production/base/proxy/proxy.yaml

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,48 @@ spec:
5454
memory: 64Mi
5555
- name: generate-nginx-configs
5656
image: registry.access.redhat.com/ubi9/ubi@sha256:66233eebd72bb5baa25190d4f55e1dc3fff3a9b77186c1f91a0abdb274452072
57+
envFrom:
58+
- configMapRef:
59+
name: proxy-init-config
5760
command:
5861
- sh
5962
- -c
6063
- |
6164
set -e
6265
63-
# Generate auth.conf with bearer token replacement
64-
token=$(cat /mnt/api-token/token)
65-
sed "s/__BEARER_TOKEN__/$token/g" /mnt/nginx-templates/auth.conf > /mnt/nginx-generated-config/auth.conf
66+
auth_conf=/mnt/nginx-generated-config/auth.conf
67+
68+
if [[ "$IMPERSONATE" == "true" ]]; then
69+
token=$(cat /mnt/api-token/token)
70+
echo 'auth_request_set $user $upstream_http_x_auth_request_email;' > "$auth_conf"
71+
echo 'proxy_set_header Impersonate-User $user;' >> "$auth_conf"
72+
echo 'proxy_set_header Impersonate-Group system:authenticated;' >> "$auth_conf"
73+
echo "proxy_set_header Authorization \"Bearer $token\";" >> "$auth_conf"
74+
else
75+
echo "# impersonation was disabled by config" > "$auth_conf"
76+
fi
6677
67-
chmod 640 /mnt/nginx-generated-config/auth.conf
78+
chmod 640 "$auth_conf"
79+
80+
echo \
81+
"proxy_pass ${TEKTON_RESULTS_URL:?tekton results url must be provided};" \
82+
> /mnt/nginx-generated-config/tekton-results.conf
83+
84+
if [[ "$KUBEARCHIVE_URL" != "" ]]; then
85+
echo "location /api/k8s/plugins/kubearchive/ {" > /mnt/nginx-generated-config/kubearchive.conf
86+
echo "auth_request /oauth2/auth;" >> /mnt/nginx-generated-config/kubearchive.conf
87+
echo "rewrite /api/k8s/plugins/kubearchive/(.+) /\$1 break;" >> /mnt/nginx-generated-config/kubearchive.conf
88+
echo "proxy_read_timeout 30m;" >> /mnt/nginx-generated-config/kubearchive.conf
89+
echo "proxy_pass ${KUBEARCHIVE_URL};" >> /mnt/nginx-generated-config/kubearchive.conf
90+
echo "include /mnt/nginx-generated-config/auth.conf;" >> /mnt/nginx-generated-config/kubearchive.conf
91+
echo "}" >> /mnt/nginx-generated-config/kubearchive.conf
92+
else
93+
echo "# KubeArchive disabled by config" > /mnt/nginx-generated-config/kubearchive.conf
94+
fi
6895
6996
volumeMounts:
7097
- name: nginx-generated-config
7198
mountPath: /mnt/nginx-generated-config
72-
- name: nginx-templates
73-
mountPath: /mnt/nginx-templates
7499
- name: api-token
75100
mountPath: /mnt/api-token
76101
securityContext:
@@ -142,8 +167,6 @@ spec:
142167
mountPath: /mnt
143168
- name: nginx-generated-config
144169
mountPath: /mnt/nginx-generated-config
145-
- name: nginx-static
146-
mountPath: /mnt/nginx-additional-location-configs
147170
- name: static-content
148171
mountPath: /opt/app-root/src/static-content
149172
securityContext:
@@ -205,14 +228,6 @@ spec:
205228
- key: nginx.conf
206229
path: nginx.conf
207230
name: proxy
208-
- configMap:
209-
defaultMode: 420
210-
name: proxy-nginx-templates
211-
name: nginx-templates
212-
- configMap:
213-
defaultMode: 420
214-
name: proxy-nginx-static
215-
name: nginx-static
216231
- name: logs
217232
emptyDir: {}
218233
- name: nginx-tmp

components/konflux-ui/production/base/proxy/tekton-results-workspaces.conf

Lines changed: 0 additions & 9 deletions
This file was deleted.

components/konflux-ui/production/base/proxy/tekton-results.conf

Lines changed: 0 additions & 8 deletions
This file was deleted.

components/konflux-ui/production/kflux-ocp-p01/kustomization.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ configMapGenerator:
99
- name: dex
1010
files:
1111
- dex-config.yaml
12+
- name: proxy-init-config
13+
literals:
14+
- IMPERSONATE=true
15+
- TEKTON_RESULTS_URL=https://tekton-results-api-service.tekton-results.svc.cluster.local:8080
16+
- KUBEARCHIVE_URL=https://kubearchive-api-server.product-kubearchive.svc.cluster.local:8081
1217

1318
patches:
1419
- path: add-service-certs-patch.yaml

components/konflux-ui/production/kflux-osp-p01/kubearchive.conf

Lines changed: 0 additions & 1 deletion
This file was deleted.

components/konflux-ui/production/kflux-osp-p01/kustomization.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ configMapGenerator:
88
- name: dex
99
files:
1010
- dex-config.yaml
11-
- name: proxy-nginx-static
12-
files:
13-
- kubearchive.conf
14-
behavior: merge
11+
- name: proxy-init-config
12+
literals:
13+
- IMPERSONATE=true
14+
- TEKTON_RESULTS_URL=https://tekton-results-api-service.tekton-results.svc.cluster.local:8080
1515

1616
patches:
1717
- path: add-service-certs-patch.yaml

0 commit comments

Comments
 (0)