Skip to content

Commit bcac0a4

Browse files
spadgettvikram-raj
authored andcommitted
Detect ipv4/ipv6 socket in pod ip for nginx conf
1 parent 9dba8eb commit bcac0a4

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

charts/openshift-console-plugin/templates/configmap.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ data:
1515
default_type application/octet-stream;
1616
keepalive_timeout 65;
1717
server {
18-
listen {{ .Values.plugin.port }} ssl;
19-
listen [::]:{{ .Values.plugin.port }} ssl;
18+
listen LISTEN_ADDRESS_PORT_REPLACED_AT_RUNTIME ssl;
2019
ssl_certificate /var/cert/tls.crt;
2120
ssl_certificate_key /var/cert/tls.key;
2221
root /usr/share/nginx/html;

charts/openshift-console-plugin/templates/deployment.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@ spec:
1919
containers:
2020
- name: {{ template "openshift-console-plugin.name" . }}
2121
image: {{ required "Plugin image must be specified!" .Values.plugin.image }}
22+
command:
23+
- /bin/sh
24+
- -c
25+
- |
26+
if echo "$POD_IP" | grep -qE '^([0-9]{1,3}\.){3}[0-9]{1,3}$'; then
27+
LISTEN_ADDRESS_PORT_REPLACED_AT_RUNTIME="{{ .Values.plugin.port }}"
28+
else
29+
LISTEN_ADDRESS_PORT_REPLACED_AT_RUNTIME="[::]:{{ .Values.plugin.port }}"
30+
fi
31+
sed "s/LISTEN_ADDRESS_PORT_REPLACED_AT_RUNTIME/$LISTEN_ADDRESS_PORT_REPLACED_AT_RUNTIME/g" /etc/nginx/nginx.conf > /tmp/nginx.conf
32+
exec nginx -c /tmp/nginx.conf -g 'daemon off;'
33+
env:
34+
- name: POD_IP
35+
valueFrom:
36+
fieldRef:
37+
fieldPath: status.podIP
2238
ports:
2339
- containerPort: {{ .Values.plugin.port }}
2440
protocol: TCP

0 commit comments

Comments
 (0)