WebServer: Porovnání verzí

Z Poznámkový blok
Přejít na: navigace, hledání
(Konfigurace Helm configu)
Řádka 48: Řádka 48:
 
=Let's encrypt=
 
=Let's encrypt=
 
https://doc.traefik.io/traefik/https/acme/
 
https://doc.traefik.io/traefik/https/acme/
 +
 +
=Dashboard=
 +
apiVersion: traefik.io/v1alpha1
 +
kind: IngressRoute
 +
metadata:
 +
  name: traefik-dashboard
 +
spec:
 +
  routes:
 +
  - match: Host(`dashboard.clazzor.eu`)
 +
    kind: Rule
 +
    services:
 +
    - name: api@internal
 +
      kind: TraefikService
 +
    middlewares:
 +
      - name: test-auth
 +
---
 +
apiVersion: traefik.io/v1alpha1
 +
kind: Middleware
 +
metadata:
 +
  name: test-auth
 +
spec:
 +
  basicAuth:
 +
    secret: clazzor-auth
 +
---
 +
apiVersion: v1
 +
kind: Secret
 +
metadata:
 +
  name: clazzor-auth
 +
  namespace: default
 +
data:
 +
  users: YWRtaW46JDEkY1E0WWl2NWIkS0hQMGFSZkhkTXVGd2Q5RVVyNGZOLgo=

Verze z 15. 10. 2023, 18:23

Instalace

K3S přeinstalovaný

K3S už má součástí traefik nainstalovaný, konfigurační soubory jdou najít v /var/lib/rancher/k3s/server/manifests/traefik.yaml, ty ale při aktualizaci se přepíšou, proto se musí vytvořit externí soubor

Helm

helm repo add traefik https://traefik.github.io/charts
helm repo update
helm install traefik traefik/traefik

Pokud chceme už změnit nějaký nastavení v helmu tak můžeme pomocí dodatečného souboru (override.yml)

helm install traefik-dev traefik/traefik -f override.yaml

Konfigurace Helm configu

Vytvoříme si soubor v /var/lib/rancher/k3s/server/manifests/

sudo touch /var/lib/rancher/k3s/server/manifests/traefik-config.yaml
sudo nano /var/lib/rancher/k3s/server/manifests/traefik-config.yaml

Základní struktura configu je

apiVersion: helm.cattle.io/v1
kind: HelmChartConfig
metadata:
  name: traefik
  namespace: kube-system
spec:
  valuesContent: |-

config se uplatní po restartu nebo aplikování

kubectl apply -f /var/lib/rancher/k3s/server/manifests/traefik-config.yaml

HTTP/3

experimental:
  http3: true

entryPoints:
  name:
    http3:
      advertisedPort: 443

Problém s duplicitním treafikem

kubectl api-resources | grep traefik

Pokud se zde nachází dva ty APIVERSION traefiku, znamená to že se zde nachází buď 2 traefiky a nebo jeden byl odstraněn bez smazání api resources, je dobré to smazat a mít jenom ten co funguje, pokud budeme vytvářet middlewares/routes/tls tak si musíme dát pozor na apiversion viz: https://traefik.io/v1alpha1

Aktualizace

Již stažené verze Traefiku pomocí Helm můžeme vidět v /var/lib/rancher/k3s/server/static/charts

sudo ls /var/lib/rancher/k3s/server/static/charts

Let's encrypt

https://doc.traefik.io/traefik/https/acme/

Dashboard

apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: traefik-dashboard
spec:
  routes:
  - match: Host(`dashboard.clazzor.eu`)
    kind: Rule
    services:
    - name: api@internal
      kind: TraefikService
    middlewares:
      - name: test-auth
---
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
  name: test-auth
spec:
  basicAuth:
    secret: clazzor-auth
---
apiVersion: v1
kind: Secret
metadata:
  name: clazzor-auth
  namespace: default
data:
  users: YWRtaW46JDEkY1E0WWl2NWIkS0hQMGFSZkhkTXVGd2Q5RVVyNGZOLgo=