Skip to content

Commit

Permalink
Change smarter-k3s-edge to 0.0.7
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Peixoto Ferreira <[email protected]>
  • Loading branch information
alexandref75 committed Mar 23, 2023
1 parent 3bffbe8 commit af0737d
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 14 deletions.
2 changes: 1 addition & 1 deletion charts/smarter-k3s-edge/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: smarter-k3s-edge
version: 0.0.6
version: 0.0.7
type: application
appVersion: v1.25.3-k3s1
description: K3s server on kubernetes
Expand Down
35 changes: 24 additions & 11 deletions charts/smarter-k3s-edge/templates/common.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.configuration.portHTTPS }}
{{- if or .Values.configuration.portHTTP .Values.configuration.portHTTPS }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
Expand Down Expand Up @@ -46,14 +46,14 @@ data:
#gzip on;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name server_domain_or_IP;
return 302 https://$server_name$request_uri;
}
server {
disable_symlinks off;
{{- if .Values.configuration.portHTTP }}
listen {{ .Values.configuration.portHTTP }} default_server;
listen [::]:{{ .Values.configuration.portHTTP }} default_server;
server_name server_domain_or_IP;
{{- end }}
{{- if .Values.configuration.portHTTPS }} i
# SSL configuration
listen {{ .Values.configuration.portHTTPS }} ssl http2 default_server;
listen [::]:{{ .Values.configuration.portHTTPS }} ssl http2 default_server;
Expand All @@ -71,13 +71,14 @@ data:
ssl_stapling_verify on;
resolver 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 5s;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
{{- end }}
# Disable preloading HSTS for now. You can use the commented out header line that includes
# the "preload" directive if you understand the implications.
#add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains";
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
root /var/www/html;
server_name _;
location / {
Expand Down Expand Up @@ -112,8 +113,13 @@ data:
k3s-start.sh: |
#!/bin/bash
#
{{- if .Values.configuration.traefik }}
curl -sflkO https://{{ .Values.configuration.host }}.{{ .Values.configuration.domain }}/token.{{ .Values.configuration.id }}
curl -sflkO https://{{ .Values.configuration.host }}.{{ .Values.configuration.domain }}/k3s.yaml.{{ .Values.configuration.id }}
{{- else }}
curl -sflkO https://{{ default .Values.configuration.hostIP .Values.configuration.externalHostIP}}:{{ .Values.configuration.portHTTPS }}/token.{{ .Values.configuration.id }}
curl -sflkO https://{{ default .Values.configuration.hostIP .Values.configuration.externalHostIP}}:{{ .Values.configuration.portHTTPS }}/k3s.yaml.{{ .Values.configuration.id }}
{{- end }}
export INSTALL_K3S_VERSION=$(echo "{{ default .Chart.AppVersion .Values.image.tag }}" | sed -e "s/-k3/+k3/")
export K3S_TOKEN=$(cat token.{{ .Values.configuration.id }})
export K3S_URL=$(grep server: k3s.yaml.{{ .Values.configuration.id }} | sed -e "s/^ *.server: *//")
Expand All @@ -140,8 +146,10 @@ data:
#
apk update
apk add openssl
{{- if .Values.configuration.portHTTPS }} i
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
until [ -f /etc/rancher/k3s/k3s.yaml ]
do
Expand Down Expand Up @@ -185,7 +193,7 @@ spec:
"--disable","coredns",
"--disable","local-storage",
"--flannel-backend=none" ]
{{- if .Values.configuration.portHTTPS }}
{{- if or .Values.configuration.portHTTP .Values.configuration.portHTTPS }}
volumeMounts:
- name: k3s-data
mountPath: /var/lib/rancher/k3s
Expand All @@ -194,7 +202,7 @@ spec:
{{- end }}
ports:
- containerPort: {{ .Values.configuration.port }}
{{- if .Values.configuration.portHTTPS }}
{{- if or .Values.configuration.portHTTP .Values.configuration.portHTTPS }}
- name: {{ .Values.application.appName }}-nginx
image: nginx:1.23.2-alpine
command: [ "/bin/sh",
Expand All @@ -207,10 +215,15 @@ spec:
- name: config
mountPath: /etc/nginx/conf.d
ports:
{{- if .Values.configuration.portHTTP }}
- containerPort: {{ .Values.configuration.portHTTP }}
{{- end }}
{{- if .Values.configuration.portHTTPS }}
- containerPort: {{ .Values.configuration.portHTTPS }}
{{- end }}
{{- end }}
volumes:
{{- if .Values.configuration.portHTTPS }}
{{- if or .Values.configuration.portHTTP .Values.configuration.portHTTPS }}
- name: k3s-data
persistentVolumeClaim:
claimName: {{ .Values.application.appName }}-data
Expand Down
25 changes: 25 additions & 0 deletions charts/smarter-k3s-edge/templates/k3s-edge-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- if .Values.configuration.traefik }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ .Release.Name }}-k3s-edge-ingress
annotations:
kubernetes.io/ingress.class: traefik
cert-manager.io/cluster-issuer: cert-manager-acme-issuer
spec:
rules:
- host: {{ .Values.configuration.host }}.{{ .Values.configuration.domain }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ .Values.application.appName }}
port:
number: {{ .Values.configuration.portHTTP }}
tls:
- secretName: {{ .Release.Name }}-k3s-edge-tls
hosts:
- {{ .Values.configuration.host }}.{{ .Values.configuration.domain }}
{{- end }}
5 changes: 5 additions & 0 deletions charts/smarter-k3s-edge/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ spec:
- protocol: TCP
port: {{ .Values.configuration.port }}
name: {{ .Values.application.appName }}
{{- if .Values.configuration.portHTTP }}
- protocol: TCP
port: {{ .Values.configuration.portHTTP }}
name: {{ .Values.application.appName }}-http
{{- end }}
{{- if .Values.configuration.portHTTPS }}
- protocol: TCP
port: {{ .Values.configuration.portHTTPS }}
Expand Down
9 changes: 7 additions & 2 deletions charts/smarter-k3s-edge/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ image:
pullPolicy: IfNotPresent

configuration:
host: k3s-edge
domain: example.com
hostIP: 192.168.2.222
# Use this in case of NATed AWS
#externalHostIP: 192.168.2.222
externalHostIP: 192.168.2.222
port: 6443
# Comment to remove NGINX
portHTTPS: 6453
portHTTP: 80
#portHTTPS: 6453
# Uncomment to enable traefik ingress
#traefik: True
# Uncomment to enable labeling for smarter-demo
#smarter_demo_labels: true

0 comments on commit af0737d

Please sign in to comment.