diff --git a/charts/smarter-k3s-edge/Chart.yaml b/charts/smarter-k3s-edge/Chart.yaml index 161b8af..ebc9178 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.11 +version: 0.0.12 type: application appVersion: v1.25.3-k3s1 description: K3s server on kubernetes diff --git a/charts/smarter-k3s-edge/templates/k3s-edge-ingress.yaml b/charts/smarter-k3s-edge/templates/k3s-edge-ingress.yaml index 8408423..5b304bc 100644 --- a/charts/smarter-k3s-edge/templates/k3s-edge-ingress.yaml +++ b/charts/smarter-k3s-edge/templates/k3s-edge-ingress.yaml @@ -19,7 +19,7 @@ spec: port: number: {{ .Values.configuration.portHTTP }} tls: - - secretName: {{ .Values.configuration.certificateID }} + - secretName: {{ default .Values.application.appName .Values.configuration.certificateID }}-tls hosts: - {{ .Values.configuration.host }}.{{ .Values.configuration.domain }} --- diff --git a/charts/smarter-k3s-edge/values.yaml b/charts/smarter-k3s-edge/values.yaml index 98dcff9..32151c5 100644 --- a/charts/smarter-k3s-edge/values.yaml +++ b/charts/smarter-k3s-edge/values.yaml @@ -24,4 +24,3 @@ configuration: # Uncomment to enable labeling for smarter-demo #smarter_demo_labels: true wwwpath: / - certificateID: "{{ .Values.application.appName }}-tls" diff --git a/terraform/k3s/main.tf b/terraform/k3s/main.tf index a2a3e08..05d898d 100644 --- a/terraform/k3s/main.tf +++ b/terraform/k3s/main.tf @@ -77,11 +77,13 @@ do sleep 5 done echo "----- Adding smarter-edge to k3s" -sudo su - ubuntu bash -c "helm install my-smartercloud-edge smarter/smarter-k3s-edge --set configuration.externalHostIP=$ADVERTISE_IP --set configuration.hostIP=$LOCAL_IP --set configuration.port=6444 --set configuration.portHTTP=80 --set configuration.id='${random_string.k3s_edge_id.result}' --set configuration.smarter_demo_labels=true --set configuration.host=grafana --set configuration.domain=$PUBLIC_HOSTNAME.sslip.io --set configuration.traefik=true --set configuration.certificateID=my-smartercloud-grafana-tls --set configuration.wwwpath=/k3s/ --wait" +#sudo su - ubuntu bash -c "helm install my-smartercloud-edge smarter/smarter-k3s-edge --set configuration.externalHostIP=$ADVERTISE_IP --set configuration.hostIP=$LOCAL_IP --set configuration.port=6444 --set configuration.portHTTP=80 --set configuration.id='${random_string.k3s_edge_id.result}' --set configuration.smarter_demo_labels=true --set configuration.host=grafana --set configuration.domain=$PUBLIC_HOSTNAME.sslip.io --set configuration.traefik=true --set configuration.certificateID=my-smartercloud-grafana-tls --set configuration.wwwpath=/k3s/ --wait" +sudo su - ubuntu bash -c "helm install my-smartercloud-edge smarter/smarter-k3s-edge --set configuration.externalHostIP=$ADVERTISE_IP --set configuration.hostIP=$LOCAL_IP --set configuration.port=6444 --set configuration.portHTTP=80 --set configuration.id='${random_string.k3s_edge_id.result}' --set configuration.smarter_demo_labels=true --set configuration.host=k3s --set configuration.domain=$PUBLIC_HOSTNAME.sslip.io --set configuration.traefik=true --set configuration.wwwpath=/ --wait" echo "----- Waiting for k3s.yaml from k3s-edge" until [ -f /home/ubuntu/k3s.yaml.${random_string.k3s_edge_id.result} ] do - sudo su - ubuntu bash -c "wget --no-check-certificate https://grafana.$PUBLIC_HOSTNAME.sslip.io/k3s/k3s.yaml.${random_string.k3s_edge_id.result}" + #sudo su - ubuntu bash -c "wget --no-check-certificate https://grafana.$PUBLIC_HOSTNAME.sslip.io/k3s/k3s.yaml.${random_string.k3s_edge_id.result}" + sudo su - ubuntu bash -c "wget --no-check-certificate https://k3s.$PUBLIC_HOSTNAME.sslip.io/k3s.yaml.${random_string.k3s_edge_id.result}" if [ -z "$(grep 'kind: Config' /home/ubuntu/k3s.yaml.${random_string.k3s_edge_id.result})" ] then echo "Received a file but it is not a k3s.yaml file, removing" diff --git a/terraform/smarter-main.tf b/terraform/smarter-main.tf index 2406506..879808b 100644 --- a/terraform/smarter-main.tf +++ b/terraform/smarter-main.tf @@ -106,6 +106,13 @@ module "k3s" { security_group_ids = [aws_security_group.sg.id] kubeconfig_mode = "644" letsencrypt_email = var.letsencrypt_email + +} + +resource "null_resource" "k3s-wait" { + provisioner "local-exec" { + command = "until [ -z \"$(wget https://${format("k3s.%s.sslip.io",substr(split(".",module.k3s.instance.public_dns)[0],4,-1))}/k3s-start.sh.${module.k3s.k3s_edge.result} -O - 2>/dev/null)\" ];do sleep 5;done" + } } output "k3s_master_public_dns" {