Skip to content

Commit b5aca5a

Browse files
authored
K3s traefik (#33)
* Change k3s.yaml from 127.0.0.1 to correct IP Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Fix chart version so artifacts are created Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Fix k3s-start.sh script Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Allow grafana host to be renamed Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Add support for labeling node automatically Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Adding terraform scripts Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Update of terraform for running smarter on EC2 Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Fixing documentation and some leftover varibles Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Add support for traefik at nginx allowing use of letsencrypt Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Fixes for uysing traefik for nginx k3s configuration Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Fix documentation to access nip.io for k3s-start.sh script Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Fix setting deployment-name Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Organizing files on directory to simplify user interface Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Put letsencrypt email a snot define so terraform ask for it Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Add troubleshooting section Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Fixes for traefik Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Graviton instance Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Anonymize Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * A little more info for debugging Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Add letsencrypt_email as variable Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Add timing and logging information Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Add link to main README for terraform Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Add more external variables Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Add AWS_VPC_subnet_id as variable Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Changed domain to <IP>.nip.io so Let's encrypt applies to the whole domain Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Add the extra variables Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * FIx _ and < characters on README (markdown) Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Syntax fixes Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Add figure and more description Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Fix reference to Terraform script Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Rewrite main README to be clear on installation using terraform Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Fix README to put terraform first Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Add support for tfvars on README and a template Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Change to template.tfvars Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Change smarter-k3s-edge to be able to be embedded in another website Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Fix terraform to use grafana instead of k3s website Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Change to sslip.io and be a little more resilient Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> * Back to k3s host using sslip and waiting k3s to be alive to return Signed-off-by: Alexandre Peixoto Ferreira <[email protected]> --------- Signed-off-by: Alexandre Peixoto Ferreira <[email protected]>
1 parent 8cd6ed4 commit b5aca5a

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

charts/smarter-k3s-edge/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v2
22
name: smarter-k3s-edge
3-
version: 0.0.11
3+
version: 0.0.12
44
type: application
55
appVersion: v1.25.3-k3s1
66
description: K3s server on kubernetes

charts/smarter-k3s-edge/templates/k3s-edge-ingress.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ spec:
1919
port:
2020
number: {{ .Values.configuration.portHTTP }}
2121
tls:
22-
- secretName: {{ .Values.configuration.certificateID }}
22+
- secretName: {{ default .Values.application.appName .Values.configuration.certificateID }}-tls
2323
hosts:
2424
- {{ .Values.configuration.host }}.{{ .Values.configuration.domain }}
2525
---

charts/smarter-k3s-edge/values.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,3 @@ configuration:
2424
# Uncomment to enable labeling for smarter-demo
2525
#smarter_demo_labels: true
2626
wwwpath: /
27-
certificateID: "{{ .Values.application.appName }}-tls"

terraform/k3s/main.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,13 @@ do
7777
sleep 5
7878
done
7979
echo "----- Adding smarter-edge to k3s"
80-
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"
80+
#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"
81+
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"
8182
echo "----- Waiting for k3s.yaml from k3s-edge"
8283
until [ -f /home/ubuntu/k3s.yaml.${random_string.k3s_edge_id.result} ]
8384
do
84-
sudo su - ubuntu bash -c "wget --no-check-certificate https://grafana.$PUBLIC_HOSTNAME.sslip.io/k3s/k3s.yaml.${random_string.k3s_edge_id.result}"
85+
#sudo su - ubuntu bash -c "wget --no-check-certificate https://grafana.$PUBLIC_HOSTNAME.sslip.io/k3s/k3s.yaml.${random_string.k3s_edge_id.result}"
86+
sudo su - ubuntu bash -c "wget --no-check-certificate https://k3s.$PUBLIC_HOSTNAME.sslip.io/k3s.yaml.${random_string.k3s_edge_id.result}"
8587
if [ -z "$(grep 'kind: Config' /home/ubuntu/k3s.yaml.${random_string.k3s_edge_id.result})" ]
8688
then
8789
echo "Received a file but it is not a k3s.yaml file, removing"

terraform/smarter-main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ module "k3s" {
106106
security_group_ids = [aws_security_group.sg.id]
107107
kubeconfig_mode = "644"
108108
letsencrypt_email = var.letsencrypt_email
109+
110+
}
111+
112+
resource "null_resource" "k3s-wait" {
113+
provisioner "local-exec" {
114+
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"
115+
}
109116
}
110117

111118
output "k3s_master_public_dns" {

0 commit comments

Comments
 (0)