From f489806171f0c802455b8fd86641a7255e9ea2ac Mon Sep 17 00:00:00 2001 From: Alexandre Peixoto Ferreira Date: Tue, 4 Apr 2023 15:07:00 -0500 Subject: [PATCH] Change smarter-k3s-edge to be able to be embedded in another website Signed-off-by: Alexandre Peixoto Ferreira --- charts/smarter-k3s-edge/Chart.yaml | 2 +- charts/smarter-k3s-edge/templates/common.yaml | 10 +++++----- .../smarter-k3s-edge/templates/k3s-edge-ingress.yaml | 4 ++-- charts/smarter-k3s-edge/values.yaml | 2 ++ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/charts/smarter-k3s-edge/Chart.yaml b/charts/smarter-k3s-edge/Chart.yaml index db8d200..2c77697 100644 --- a/charts/smarter-k3s-edge/Chart.yaml +++ b/charts/smarter-k3s-edge/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: smarter-k3s-edge -version: 0.0.9 +version: 0.0.10 type: application appVersion: v1.25.3-k3s1 description: K3s server on kubernetes diff --git a/charts/smarter-k3s-edge/templates/common.yaml b/charts/smarter-k3s-edge/templates/common.yaml index 0ea1434..1df3e70 100644 --- a/charts/smarter-k3s-edge/templates/common.yaml +++ b/charts/smarter-k3s-edge/templates/common.yaml @@ -81,7 +81,7 @@ data: add_header X-Content-Type-Options nosniff; root /var/www/html; server_name _; - location / { + location {{ .Values.configuration.wwwpath }} { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; @@ -150,14 +150,14 @@ data: 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 openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048 {{- end }} - mkdir -p /var/www/html + mkdir -p /var/www/html{{ .Values.configuration.wwwpath }} until [ -f /etc/rancher/k3s/k3s.yaml ] do sleep 1 done - sed -e "s/127\.0\.0\.1/"{{ default .Values.configuration.hostIP .Values.configuration.externalHostIP }}"/" /etc/rancher/k3s/k3s.yaml > /var/www/html/k3s.yaml.{{ .Values.configuration.id }} - ln -s /var/lib/rancher/k3s/server/token /var/www/html/token.{{ .Values.configuration.id }} - ln -s /etc/nginx/conf.d/k3s-start.sh /var/www/html/k3s-start.sh.{{ .Values.configuration.id }} + sed -e "s/127\.0\.0\.1/"{{ default .Values.configuration.hostIP .Values.configuration.externalHostIP }}"/" /etc/rancher/k3s/k3s.yaml > /var/www/html{{ .Values.configuration.wwwpath }}k3s.yaml.{{ .Values.configuration.id }} + ln -s /var/lib/rancher/k3s/server/token /var/www/html{{ .Values.configuration.wwwpath }}token.{{ .Values.configuration.id }} + ln -s /etc/nginx/conf.d/k3s-start.sh /var/www/html{{ .Values.configuration.wwwpath }}k3s-start.sh.{{ .Values.configuration.id }} chmod -R ago+rw /var/www/html nginx -c /etc/nginx/conf.d/default.conf -g 'daemon off;' --- diff --git a/charts/smarter-k3s-edge/templates/k3s-edge-ingress.yaml b/charts/smarter-k3s-edge/templates/k3s-edge-ingress.yaml index 7ae576b..8408423 100644 --- a/charts/smarter-k3s-edge/templates/k3s-edge-ingress.yaml +++ b/charts/smarter-k3s-edge/templates/k3s-edge-ingress.yaml @@ -11,7 +11,7 @@ spec: - host: {{ .Values.configuration.host }}.{{ .Values.configuration.domain }} http: paths: - - path: / + - path: {{ .Values.configuration.wwwpath }} pathType: Prefix backend: service: @@ -19,7 +19,7 @@ spec: port: number: {{ .Values.configuration.portHTTP }} tls: - - secretName: {{ .Values.application.appName }}-tls + - secretName: {{ .Values.configuration.certificateID }} hosts: - {{ .Values.configuration.host }}.{{ .Values.configuration.domain }} --- diff --git a/charts/smarter-k3s-edge/values.yaml b/charts/smarter-k3s-edge/values.yaml index 497124e..98dcff9 100644 --- a/charts/smarter-k3s-edge/values.yaml +++ b/charts/smarter-k3s-edge/values.yaml @@ -23,3 +23,5 @@ configuration: #traefik: True # Uncomment to enable labeling for smarter-demo #smarter_demo_labels: true + wwwpath: / + certificateID: "{{ .Values.application.appName }}-tls"