Skip to content

Commit 446c174

Browse files
committed
Upgrade console to version 4.17
Now Requires external Plugins for Network and Monitoring tabs
1 parent bea0dde commit 446c174

File tree

14 files changed

+435
-14
lines changed

14 files changed

+435
-14
lines changed

charts/console/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ description: A Helm chart for Kubernetes
55
type: application
66

77
# This is the chart version.
8-
version: 1.0.2
8+
version: 1.1.0
99

1010
# This is the version number of the application being deployed.
1111
# https://docs.openshift.com/container-platform/4.18/release_notes/ocp-4-18-release-notes.html
12-
appVersion: "4.16.0"
12+
appVersion: "4.17.0"

charts/console/templates/_helpers.tpl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,13 @@ Create the name of the service account to use
8787
{{- else }}
8888
{{- default "default" .Values.serviceAccount.name }}
8989
{{- end }}
90-
{{- end }}
90+
{{- end }}
91+
92+
{{- define "plugins-environment-value" }}
93+
{{- $result := list -}}
94+
{{- range .Values.plugins -}}
95+
{{- $port := int .port -}}
96+
{{- $result = append $result (printf "%s=http://localhost:%d" .name $port) -}}
97+
{{- end -}}
98+
{{- join "," $result -}}
99+
{{- end -}}

charts/console/templates/deployment.yaml

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ spec:
5353
httpGet:
5454
path: /
5555
port: http
56-
resources:
57-
{{- toYaml .Values.resources | nindent 12 }}
56+
resources: {{- toYaml .Values.resources | nindent 12 }}
5857
env:
5958
{{- if .Values.extraEnv }}
6059
{{- toYaml .Values.extraEnv | nindent 12 }}
@@ -82,6 +81,41 @@ spec:
8281
- name: BRIDGE_COOKIE_AUTHENTICATION_KEY_FILE
8382
value: "/etc/bridge/oidc-authnKey"
8483
{{- end }}
84+
{{- if .Values.plugins }}
85+
- name: BRIDGE_PLUGINS
86+
value: {{ include "plugins-environment-value" . }}
87+
{{- end }}
88+
{{- if .Values.plugins }}
89+
{{- range .Values.plugins }}
90+
- name: {{ .name }}
91+
resources: {{- toYaml $.Values.resources | nindent 12 }}
92+
readinessProbe:
93+
httpGet:
94+
path: /
95+
port: plugin
96+
scheme: HTTP
97+
timeoutSeconds: 1
98+
periodSeconds: 10
99+
successThreshold: 1
100+
failureThreshold: 3
101+
livenessProbe:
102+
httpGet:
103+
path: /
104+
port: plugin
105+
scheme: HTTP
106+
timeoutSeconds: 1
107+
periodSeconds: 10
108+
successThreshold: 1
109+
failureThreshold: 3
110+
securityContext: {{- toYaml $.Values.securityContext | nindent 12 }}
111+
ports:
112+
- name: plugin
113+
containerPort: {{ .port }}
114+
protocol: TCP
115+
imagePullPolicy: {{ $.Values.image.pullPolicy }}
116+
image: {{ .image }}
117+
{{- end }}
118+
{{- end }}
85119
{{- with .Values.nodeSelector }}
86120
nodeSelector:
87121
{{- toYaml . | nindent 8 }}

charts/console/values.yaml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,20 @@ oidcIdentityProvider: ""
5252
# only modify the string elements, not the claim keys
5353
claims:
5454
preferredUsername:
55-
- preferred_username
55+
- preferred_username
5656
name:
57-
- name
57+
- name
5858
email:
59-
- email
59+
- email
6060
groups:
61-
- groups
61+
- groups
6262

6363
bridgeEnvironmentVariables:
64-
BRIDGE_USER_AUTH: oidc
65-
BRIDGE_K8S_AUTH: oidc
66-
BRIDGE_BASE_ADDRESS: # "https://my-console.cluster.example.com"
67-
BRIDGE_USER_AUTH_OIDC_CLIENT_ID: # BRIDGE_USER_AUTH_OIDC_CLIENT_ID
68-
BRIDGE_USER_AUTH_OIDC_ISSUER_URL: # https://my-oidc-prodiver.okta.jumpcloud.example.com
64+
# BRIDGE_USER_AUTH: oidc
65+
# BRIDGE_K8S_AUTH: oidc
66+
# BRIDGE_BASE_ADDRESS: "https://my-console.cluster.example.com"
67+
# BRIDGE_USER_AUTH_OIDC_CLIENT_ID: BRIDGE_USER_AUTH_OIDC_CLIENT_ID
68+
# BRIDGE_USER_AUTH_OIDC_ISSUER_URL: https://my-oidc-prodiver.okta.jumpcloud.example.com
6969
# BRIDGE_USER_AUTH_OIDC_CLIENT_SECRET defaults to consuming vaule from values.secrets.idpSecret.secretName
7070

7171
extraEnv: ""
@@ -94,6 +94,16 @@ ingress:
9494
# hosts:
9595
# - chart-example.local
9696

97+
# Enable Plugins - run as a sidecar
98+
# Since version 4.17 network tab has been extracted from console repo into a console dynamic plugin
99+
plugins: []
100+
# - name: networking-console-plugin
101+
# image: asaf400/openshift:networking-console-plugin-e8a088c
102+
# port: 8080
103+
# - name: monitoring-plugin
104+
# image: asaf400/openshift:monitoring-plugin
105+
# port: 8081
106+
97107
resources: {}
98108
# We usually recommend not to specify default resources and to leave this as a conscious
99109
# choice for the user. This also increases chances charts run on environments with little
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
ME=$(basename "$0")
6+
7+
entrypoint_log() {
8+
if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then
9+
echo "$@"
10+
fi
11+
}
12+
13+
add_stream_block() {
14+
local conffile="/etc/nginx/nginx.conf"
15+
16+
if grep -q -E "\s*stream\s*\{" "$conffile"; then
17+
entrypoint_log "$ME: $conffile contains a stream block; include $stream_output_dir/*.conf to enable stream templates"
18+
else
19+
# check if the file can be modified, e.g. not on a r/o filesystem
20+
touch "$conffile" 2>/dev/null || { entrypoint_log "$ME: info: can not modify $conffile (read-only file system?)"; exit 0; }
21+
entrypoint_log "$ME: Appending stream block to $conffile to include $stream_output_dir/*.conf"
22+
cat << END >> "$conffile"
23+
# added by "$ME" on "$(date)"
24+
stream {
25+
include $stream_output_dir/*.conf;
26+
}
27+
END
28+
fi
29+
}
30+
31+
auto_envsubst() {
32+
local template_dir="${NGINX_ENVSUBST_TEMPLATE_DIR:-/etc/nginx/templates}"
33+
local suffix="${NGINX_ENVSUBST_TEMPLATE_SUFFIX:-.template}"
34+
local output_dir="${NGINX_ENVSUBST_OUTPUT_DIR:-/etc/nginx/conf.d}"
35+
local stream_suffix="${NGINX_ENVSUBST_STREAM_TEMPLATE_SUFFIX:-.stream-template}"
36+
local stream_output_dir="${NGINX_ENVSUBST_STREAM_OUTPUT_DIR:-/etc/nginx/stream-conf.d}"
37+
local filter="${NGINX_ENVSUBST_FILTER:-}"
38+
39+
local template defined_envs relative_path output_path subdir
40+
defined_envs=$(printf '${%s} ' $(awk "END { for (name in ENVIRON) { print ( name ~ /${filter}/ ) ? name : \"\" } }" < /dev/null ))
41+
[ -d "$template_dir" ] || return 0
42+
if [ ! -w "$output_dir" ]; then
43+
entrypoint_log "$ME: ERROR: $template_dir exists, but $output_dir is not writable"
44+
return 0
45+
fi
46+
find "$template_dir" -follow -type f -name "*$suffix" -print | while read -r template; do
47+
relative_path="${template#"$template_dir/"}"
48+
output_path="$output_dir/${relative_path%"$suffix"}"
49+
subdir=$(dirname "$relative_path")
50+
# create a subdirectory where the template file exists
51+
mkdir -p "$output_dir/$subdir"
52+
entrypoint_log "$ME: Running envsubst on $template to $output_path"
53+
envsubst "$defined_envs" < "$template" > "$output_path"
54+
done
55+
56+
# Print the first file with the stream suffix, this will be false if there are none
57+
if test -n "$(find "$template_dir" -name "*$stream_suffix" -print -quit)"; then
58+
mkdir -p "$stream_output_dir"
59+
if [ ! -w "$stream_output_dir" ]; then
60+
entrypoint_log "$ME: ERROR: $template_dir exists, but $stream_output_dir is not writable"
61+
return 0
62+
fi
63+
add_stream_block
64+
find "$template_dir" -follow -type f -name "*$stream_suffix" -print | while read -r template; do
65+
relative_path="${template#"$template_dir/"}"
66+
output_path="$stream_output_dir/${relative_path%"$stream_suffix"}"
67+
subdir=$(dirname "$relative_path")
68+
# create a subdirectory where the template file exists
69+
mkdir -p "$stream_output_dir/$subdir"
70+
entrypoint_log "$ME: Running envsubst on $template to $output_path"
71+
envsubst "$defined_envs" < "$template" > "$output_path"
72+
done
73+
fi
74+
}
75+
76+
auto_envsubst
77+
78+
exit 0
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
FROM registry.redhat.io/ubi9/nodejs-18:1-118 AS web-builder
2+
3+
WORKDIR /opt/app-root
4+
5+
USER 0
6+
7+
RUN npm install --global yarn
8+
9+
ENV HUSKY=0
10+
11+
COPY web/package.json web/yarn.lock web/
12+
COPY Makefile Makefile
13+
RUN make install-frontend
14+
15+
COPY web/ web/
16+
RUN make build-frontend
17+
18+
FROM quay.io/redhat-cne/openshift-origin-release:rhel-9-golang-1.22-openshift-4.17 as go-builder
19+
20+
WORKDIR /opt/app-root
21+
22+
COPY Makefile Makefile
23+
COPY go.mod go.mod
24+
COPY go.sum go.sum
25+
26+
RUN make install-backend
27+
28+
COPY cmd/ cmd/
29+
COPY pkg/ pkg/
30+
31+
ENV GOEXPERIMENT=strictfipsruntime
32+
ENV CGO_ENABLED=1
33+
34+
RUN make build-backend BUILD_OPTS="-tags strictfipsruntime"
35+
36+
FROM amazonlinux:2023
37+
38+
RUN dnf install -y nginx findutils gettext && \
39+
mkdir /var/cache/nginx && \
40+
mkdir -p /docker-entrypoint.d && \
41+
mkdir -p /etc/nginx/templates && \
42+
chown -R 1001:0 /var/lib/nginx /var/log/nginx /run /docker-entrypoint.d /etc/nginx/templates /etc/nginx/conf.d && \
43+
chmod -R ug+rwX /var/lib/nginx /var/log/nginx /run /docker-entrypoint.d /etc/nginx/templates /etc/nginx/conf.d
44+
45+
USER 1001
46+
47+
COPY --from=web-builder /opt/app-root/web/dist /opt/app-root/web/dist
48+
COPY --from=go-builder /opt/app-root/plugin-backend /opt/app-root
49+
50+
COPY --from=web-builder /opt/app-root/web/dist /usr/share/nginx/html
51+
COPY nginx.conf.template /etc/nginx/templates/default.conf.template
52+
53+
COPY docker-entrypoint.sh /
54+
COPY 20-envsubst-on-templates.sh /docker-entrypoint.d
55+
56+
ENTRYPOINT ["/docker-entrypoint.sh"]
57+
58+
# Run the server
59+
CMD ["nginx", "-g", "daemon off;"]
60+
61+
# When nginx is removed from CMO, we can use the following ENTRYPOINT instead and remove the nginx install
62+
# ENTRYPOINT ["/opt/app-root/plugin-backend", "-static-path", "/opt/app-root/web/dist"]

images/monitoring-plugin/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[Build this Dockerfile with acompanying files in this context dir](https://github.com/openshift/monitoring-plugin/blob/release-4.17/)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/sh
2+
# vim:sw=4:ts=4:et
3+
4+
set -e
5+
6+
entrypoint_log() {
7+
if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then
8+
echo "$@"
9+
fi
10+
}
11+
12+
if [ "$1" = "nginx" ] || [ "$1" = "nginx-debug" ]; then
13+
if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then
14+
entrypoint_log "$0: /docker-entrypoint.d/ is not empty, will attempt to perform configuration"
15+
16+
entrypoint_log "$0: Looking for shell scripts in /docker-entrypoint.d/"
17+
find "/docker-entrypoint.d/" -follow -type f -print | sort -V | while read -r f; do
18+
case "$f" in
19+
*.envsh)
20+
if [ -x "$f" ]; then
21+
entrypoint_log "$0: Sourcing $f";
22+
. "$f"
23+
else
24+
# warn on shell scripts without exec bit
25+
entrypoint_log "$0: Ignoring $f, not executable";
26+
fi
27+
;;
28+
*.sh)
29+
if [ -x "$f" ]; then
30+
entrypoint_log "$0: Launching $f";
31+
"$f"
32+
else
33+
# warn on shell scripts without exec bit
34+
entrypoint_log "$0: Ignoring $f, not executable";
35+
fi
36+
;;
37+
*) entrypoint_log "$0: Ignoring $f";;
38+
esac
39+
done
40+
41+
entrypoint_log "$0: Configuration complete; ready for start up"
42+
else
43+
entrypoint_log "$0: No files found in /docker-entrypoint.d/, skipping configuration"
44+
fi
45+
fi
46+
47+
exec "$@"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
server {
2+
listen ${NGINX_PORT};
3+
listen [::]:${NGINX_PORT};
4+
}

0 commit comments

Comments
 (0)