Compare commits

...

2 Commits

Author SHA1 Message Date
Tuan-Dat Tran 92e4b3bb27 Add k3s-server02
Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
2024-10-07 20:56:12 +02:00
Tuan-Dat Tran ed980f816f prod and staging for tls in loadbalancer
Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
2024-10-04 00:00:02 +02:00
5 changed files with 39 additions and 9 deletions

View File

@ -12,6 +12,7 @@ k3s:
ips: ips:
- 192.168.20.21 - 192.168.20.21
- 192.168.20.24 - 192.168.20.24
- 192.168.20.30
loadbalancer: loadbalancer:
ip: 192.168.20.22 ip: 192.168.20.22
default_port: 6443 default_port: 6443
@ -24,4 +25,4 @@ k3s:
- 192.168.20.26 - 192.168.20.26
- 192.168.20.27 - 192.168.20.27
k3s_db_connection_string: "postgres://{{db.user}}:{{db.password}}@{{k3s.db.ip}}:{{k3s.db.default_port}}/{{db.name}}" k3s_db_connection_string: "postgres://{{ db.user }}:{{ db.password }}@{{ k3s.db.ip }}:{{ k3s.db.default_port }}/{{ db.name }}"

View File

@ -0,0 +1,10 @@
---
ansible_user: "{{ user }}"
ansible_host: 192.168.20.30
ansible_port: 22
ansible_ssh_private_key_file: "{{ pk_path }}"
ansible_become_pass: "{{ vault.k3s.server01.sudo }}"
host:
hostname: "k3s-server02"
ip: "{{ ansible_host }}"

View File

@ -6,6 +6,7 @@ k3s-postgres
k3s-loadbalancer k3s-loadbalancer
k3s-server00 k3s-server00
k3s-server01 k3s-server01
k3s-server02
k3s-agent00 k3s-agent00
k3s-agent01 k3s-agent01
k3s-agent02 k3s-agent02
@ -13,6 +14,7 @@ k3s-agent02
[k3s_server] [k3s_server]
k3s-server00 k3s-server00
k3s-server01 k3s-server01
k3s-server02
[k3s_agent] [k3s_agent]
k3s-agent00 k3s-agent00
@ -25,12 +27,14 @@ k3s-agent01
k3s-agent02 k3s-agent02
k3s-server00 k3s-server00
k3s-server01 k3s-server01
k3s-server02
k3s-postgres k3s-postgres
k3s-loadbalancer k3s-loadbalancer
[k3s_nodes] [k3s_nodes]
k3s-server00 k3s-server00
k3s-server01 k3s-server01
k3s-server02
k3s-agent00 k3s-agent00
k3s-agent01 k3s-agent01
k3s-agent02 k3s-agent02

View File

@ -2,8 +2,8 @@ include /etc/nginx/modules-enabled/*.conf;
events {} events {}
# TCP Load Balancing for the K3s API
stream { stream {
# TCP Load Balancing for the K3s API
upstream k3s_servers { upstream k3s_servers {
{% for ip in k3s_server_ips %} {% for ip in k3s_server_ips %}
server {{ ip }}:{{k3s.loadbalancer.default_port}}; server {{ ip }}:{{k3s.loadbalancer.default_port}};
@ -14,6 +14,17 @@ stream {
listen {{k3s.loadbalancer.default_port}}; listen {{k3s.loadbalancer.default_port}};
proxy_pass k3s_servers; proxy_pass k3s_servers;
} }
upstream dns_servers {
{% for ip in k3s_server_ips %}
server {{ ip }}:53;
{% endfor %}
}
server {
listen 53 udp;
proxy_pass dns_servers;
}
} }
http { http {
@ -43,9 +54,9 @@ http {
} }
server { server {
listen 443; listen 443 ssl;
server_name staging.k3s.seyshiro.de *.staging.k3s.seyshiro.de server_name staging.k3s.seyshiro.de *.staging.k3s.seyshiro.de;
ssl_certificate /etc/nginx/ssl/staging_tls.crt; ssl_certificate /etc/nginx/ssl/staging_tls.crt;
ssl_certificate_key /etc/nginx/ssl/staging_tls.key; ssl_certificate_key /etc/nginx/ssl/staging_tls.key;
@ -59,9 +70,9 @@ http {
} }
server { server {
listen 443; listen 443 ssl;
server_name production.k3s.seyshiro.de *.production.k3s.seyshiro.de server_name k3s.seyshiro.de *.k3s.seyshiro.de;
ssl_certificate /etc/nginx/ssl/production_tls.crt; ssl_certificate /etc/nginx/ssl/production_tls.crt;
ssl_certificate_key /etc/nginx/ssl/production_tls.key; ssl_certificate_key /etc/nginx/ssl/production_tls.key;
@ -74,3 +85,5 @@ http {
} }
} }
} }

View File

@ -1,13 +1,15 @@
#!/bin/bash #!/bin/bash
kubectl -n staging get secret k3s-seyshiro-de-staging-tls -o jsonpath='{.data.tls\.crt}' | base64 -d >staging_tls.crt kubectl -n staging get secret k3s-seyshiro-de-tls -o jsonpath='{.data.tls\.crt}' | base64 -d >staging_tls.crt
kubectl -n staging get secret k3s-seyshiro-de-staging-tls -o jsonpath='{.data.tls\.key}' | base64 -d >staging_tls.key kubectl -n staging get secret k3s-seyshiro-de-tls -o jsonpath='{.data.tls\.key}' | base64 -d >staging_tls.key
kubectl -n production get secret k3s-seyshiro-de-tls -o jsonpath='{.data.tls\.crt}' | base64 -d >production_tls.crt kubectl -n production get secret k3s-seyshiro-de-tls -o jsonpath='{.data.tls\.crt}' | base64 -d >production_tls.crt
kubectl -n production get secret k3s-seyshiro-de-tls -o jsonpath='{.data.tls\.key}' | base64 -d >production_tls.key kubectl -n production get secret k3s-seyshiro-de-tls -o jsonpath='{.data.tls\.key}' | base64 -d >production_tls.key
scp ./{production,staging}_tls.{crt,key} k3s-loadbalancer:~ scp ./{production,staging}_tls.{crt,key} k3s-loadbalancer:~
rm ./{production,staging}_tls.{crt,key}
# onsite # on k3s-loadbalancer
# chmod 600 ./{production,staging}_tls.{crt,key} # chmod 600 ./{production,staging}_tls.{crt,key}
# sudo chown root:root ./{production,staging}_tls.{crt,key}
# sudo mv ./{production,staging}_tls.{crt,key} /etc/nginx/ssl/ # sudo mv ./{production,staging}_tls.{crt,key} /etc/nginx/ssl/