Skip to content

Commit

Permalink
Detect ipv4/ipv6 socket in pod ip for nginx conf
Browse files Browse the repository at this point in the history
  • Loading branch information
spadgett committed Feb 26, 2025
1 parent b0841e5 commit 3bfa27c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 1 addition & 2 deletions charts/openshift-console-plugin/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ data:
default_type application/octet-stream;
keepalive_timeout 65;
server {
listen {{ .Values.plugin.port }} ssl;
listen [::]:{{ .Values.plugin.port }} ssl;
listen LISTEN_ADDRESS_PORT_REPLACED_AT_RUNTIME ssl;
ssl_certificate /var/cert/tls.crt;
ssl_certificate_key /var/cert/tls.key;
root /usr/share/nginx/html;
Expand Down
16 changes: 16 additions & 0 deletions charts/openshift-console-plugin/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ spec:
containers:
- name: {{ template "openshift-console-plugin.name" . }}
image: {{ required "Plugin image must be specified!" .Values.plugin.image }}
command:
- /bin/sh
- -c
- |
if echo "$POD_IP" | grep -qE '^([0-9]{1,3}\.){3}[0-9]{1,3}$'; then
LISTEN_ADDRESS_PORT_REPLACED_AT_RUNTIME="{{ .Values.plugin.port }}"
else
LISTEN_ADDRESS_PORT_REPLACED_AT_RUNTIME="[::]:{{ .Values.plugin.port }}"
fi
sed "s/LISTEN_ADDRESS_PORT_REPLACED_AT_RUNTIME/$LISTEN_ADDRESS_PORT_REPLACED_AT_RUNTIME/g" /etc/nginx/nginx.conf > /tmp/nginx.conf
exec nginx -c /tmp/nginx.conf -g 'daemon off;'
env:
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
ports:
- containerPort: {{ .Values.plugin.port }}
protocol: TCP
Expand Down

0 comments on commit 3bfa27c

Please sign in to comment.