Skip to content

Commit

Permalink
K3s traefik (#33)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
alexandref75 authored Apr 5, 2023
1 parent 8cd6ed4 commit b5aca5a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 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.11
version: 0.0.12
type: application
appVersion: v1.25.3-k3s1
description: K3s server on kubernetes
Expand Down
2 changes: 1 addition & 1 deletion charts/smarter-k3s-edge/templates/k3s-edge-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
---
Expand Down
1 change: 0 additions & 1 deletion charts/smarter-k3s-edge/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ configuration:
# Uncomment to enable labeling for smarter-demo
#smarter_demo_labels: true
wwwpath: /
certificateID: "{{ .Values.application.appName }}-tls"
6 changes: 4 additions & 2 deletions terraform/k3s/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 7 additions & 0 deletions terraform/smarter-main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit b5aca5a

Please sign in to comment.