1- {{- if .Values.configuration.portHTTPS }}
1+ {{- if or .Values.configuration.portHTTP .Values.configuration.portHTTPS }}
22apiVersion : v1
33kind : PersistentVolumeClaim
44metadata :
@@ -46,14 +46,14 @@ data:
4646
4747 #gzip on;
4848
49- server {
50- listen 80 default_server;
51- listen [::]:80 default_server;
52- server_name server_domain_or_IP;
53- return 302 https://$server_name$request_uri;
54- }
5549 server {
5650 disable_symlinks off;
51+ {{- if .Values.configuration.portHTTP }}
52+ listen {{ .Values.configuration.portHTTP }} default_server;
53+ listen [::]:{{ .Values.configuration.portHTTP }} default_server;
54+ server_name server_domain_or_IP;
55+ {{- end }}
56+ {{- if .Values.configuration.portHTTPS }} i
5757 # SSL configuration
5858 listen {{ .Values.configuration.portHTTPS }} ssl http2 default_server;
5959 listen [::]:{{ .Values.configuration.portHTTPS }} ssl http2 default_server;
@@ -71,13 +71,14 @@ data:
7171 ssl_stapling_verify on;
7272 resolver 8.8.8.8 8.8.4.4 valid=300s;
7373 resolver_timeout 5s;
74+ ssl_dhparam /etc/ssl/certs/dhparam.pem;
75+ {{- end }}
7476 # Disable preloading HSTS for now. You can use the commented out header line that includes
7577 # the "preload" directive if you understand the implications.
7678 #add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
7779 add_header Strict-Transport-Security "max-age=63072000; includeSubdomains";
7880 add_header X-Frame-Options DENY;
7981 add_header X-Content-Type-Options nosniff;
80- ssl_dhparam /etc/ssl/certs/dhparam.pem;
8182 root /var/www/html;
8283 server_name _;
8384 location / {
@@ -112,8 +113,13 @@ data:
112113 k3s-start.sh : |
113114 #!/bin/bash
114115 #
116+ {{- if .Values.configuration.traefik }}
117+ curl -sflkO https://{{ .Values.configuration.host }}.{{ .Values.configuration.domain }}/token.{{ .Values.configuration.id }}
118+ curl -sflkO https://{{ .Values.configuration.host }}.{{ .Values.configuration.domain }}/k3s.yaml.{{ .Values.configuration.id }}
119+ {{- else }}
115120 curl -sflkO https://{{ default .Values.configuration.hostIP .Values.configuration.externalHostIP}}:{{ .Values.configuration.portHTTPS }}/token.{{ .Values.configuration.id }}
116121 curl -sflkO https://{{ default .Values.configuration.hostIP .Values.configuration.externalHostIP}}:{{ .Values.configuration.portHTTPS }}/k3s.yaml.{{ .Values.configuration.id }}
122+ {{- end }}
117123 export INSTALL_K3S_VERSION=$(echo "{{ default .Chart.AppVersion .Values.image.tag }}" | sed -e "s/-k3/+k3/")
118124 export K3S_TOKEN=$(cat token.{{ .Values.configuration.id }})
119125 export K3S_URL=$(grep server: k3s.yaml.{{ .Values.configuration.id }} | sed -e "s/^ *.server: *//")
@@ -140,8 +146,10 @@ data:
140146 #
141147 apk update
142148 apk add openssl
149+ {{- if .Values.configuration.portHTTPS }} i
143150 echo -e "US\n\n\nSmarter\n\n"{{ default .Values.configuration.hostIP .Values.configuration.externalHostIP }}"\n\n" | openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt
144151 openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048
152+ {{- end }}
145153 mkdir -p /var/www/html
146154 until [ -f /etc/rancher/k3s/k3s.yaml ]
147155 do
@@ -185,7 +193,7 @@ spec:
185193 " --disable" ,"coredns",
186194 " --disable" ,"local-storage",
187195 " --flannel-backend=none" ]
188- {{- if .Values.configuration.portHTTPS }}
196+ {{- if or .Values.configuration.portHTTP .Values.configuration.portHTTPS }}
189197 volumeMounts :
190198 - name : k3s-data
191199 mountPath : /var/lib/rancher/k3s
@@ -194,7 +202,7 @@ spec:
194202 {{- end }}
195203 ports :
196204 - containerPort : {{ .Values.configuration.port }}
197- {{- if .Values.configuration.portHTTPS }}
205+ {{- if or .Values.configuration.portHTTP .Values.configuration.portHTTPS }}
198206 - name : {{ .Values.application.appName }}-nginx
199207 image : nginx:1.23.2-alpine
200208 command : [ "/bin/sh",
@@ -207,10 +215,15 @@ spec:
207215 - name : config
208216 mountPath : /etc/nginx/conf.d
209217 ports :
218+ {{- if .Values.configuration.portHTTP }}
219+ - containerPort : {{ .Values.configuration.portHTTP }}
220+ {{- end }}
221+ {{- if .Values.configuration.portHTTPS }}
210222 - containerPort : {{ .Values.configuration.portHTTPS }}
223+ {{- end }}
211224 {{- end }}
212225 volumes :
213- {{- if .Values.configuration.portHTTPS }}
226+ {{- if or .Values.configuration.portHTTP .Values.configuration.portHTTPS }}
214227 - name : k3s-data
215228 persistentVolumeClaim :
216229 claimName : {{ .Values.application.appName }}-data
0 commit comments