enable traefik security feat
This commit is contained in:
@@ -11,9 +11,10 @@ services:
|
|||||||
command:
|
command:
|
||||||
- --configFile=/etc/traefik/traefik.yml
|
- --configFile=/etc/traefik/traefik.yml
|
||||||
ports:
|
ports:
|
||||||
- 80:80
|
- 80:80/tcp
|
||||||
- 443:443
|
- 443:443/tcp
|
||||||
- 8080:8080
|
- 443:443/udp
|
||||||
|
- 8080:8080/tcp
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||||
- ./traefik/etc:/etc/traefik:ro
|
- ./traefik/etc:/etc/traefik:ro
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## Brief
|
## Brief
|
||||||
|
|
||||||
Enabling internal access to dashboard and metrics for traefik ingress controller in k3s kubernetes cluster
|
Enabling traefik access to dashboard and metrics for traefik ingress controller in k3s kubernetes cluster
|
||||||
|
|
||||||
- by `rskntroot` on `2024-07-01`
|
- by `rskntroot` on `2024-07-01`
|
||||||
|
|
||||||
@@ -23,23 +23,30 @@ Server Version: v1.29.5+k3s1
|
|||||||
|
|
||||||
## Traefik Dashboards
|
## Traefik Dashboards
|
||||||
|
|
||||||
`Traefik Dashboards` refers to both traefik dashboard and prometheus metrics for traefik which are readily available, however, disabled by default in K3S.
|
K3S comes packaged with `Traefik Dashboard` and `Prometheus Metrics` which are disabled by default.
|
||||||
|
|
||||||
### Preparation
|
### Preparation
|
||||||
|
|
||||||
Enable `internal`+`.your.domain.com` in non-public DNS
|
=== "DNS"
|
||||||
|
|
||||||
- (alt) edit the `hosts` file on your admin to point the desired k3s host IP
|
Set DNS record `traefik.your.domain.com` in a non-public DNS
|
||||||
|
|
||||||
On host with `kubectl` access:
|
=== "Hosts File"
|
||||||
``` bash
|
|
||||||
export DOMAIN=your.domain.com
|
Alternatively, you can just edit your workstations `hosts` file.
|
||||||
```
|
|
||||||
|
``` title="/etc/hosts"
|
||||||
|
|
||||||
|
10.0.0.1 traefik.your.domain.com
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
!!! warning "This example does not include authentication. Exposing these dashboards is a security risk."
|
!!! warning "This example does not include authentication. Exposing these dashboards is a security risk."
|
||||||
|
|
||||||
### Update Manifest
|
### Update Manifest
|
||||||
|
|
||||||
|
On host with `kubectl` access.
|
||||||
|
|
||||||
Add the following to `spec.valuesContent` in:
|
Add the following to `spec.valuesContent` in:
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
@@ -102,7 +109,7 @@ Save the following to `traefik-dashboard.yml` in your workspace.
|
|||||||
|
|
||||||
=== "Traefik Dashboard"
|
=== "Traefik Dashboard"
|
||||||
|
|
||||||
``` yaml
|
``` yaml title="traefik-dashboard.yml"
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
@@ -133,7 +140,7 @@ Save the following to `traefik-dashboard.yml` in your workspace.
|
|||||||
spec.ingressClassName: traefik
|
spec.ingressClassName: traefik
|
||||||
spec:
|
spec:
|
||||||
rules:
|
rules:
|
||||||
- host: internal.${DOMAIN}
|
- host: traefik.${DOMAIN}
|
||||||
http:
|
http:
|
||||||
paths:
|
paths:
|
||||||
- path: /
|
- path: /
|
||||||
@@ -147,7 +154,7 @@ Save the following to `traefik-dashboard.yml` in your workspace.
|
|||||||
|
|
||||||
=== "Promethus Only"
|
=== "Promethus Only"
|
||||||
|
|
||||||
``` yaml
|
``` yaml title="traefik-dashboard.yml"
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
@@ -178,7 +185,7 @@ Save the following to `traefik-dashboard.yml` in your workspace.
|
|||||||
spec.ingressClassName: traefik
|
spec.ingressClassName: traefik
|
||||||
spec:
|
spec:
|
||||||
rules:
|
rules:
|
||||||
- host: internal.${DOMAIN}
|
- host: traefik.${DOMAIN}
|
||||||
http:
|
http:
|
||||||
paths:
|
paths:
|
||||||
- path: /
|
- path: /
|
||||||
@@ -199,7 +206,7 @@ Save the following to `traefik-dashboard.yml` in your workspace.
|
|||||||
|
|
||||||
=== "Both"
|
=== "Both"
|
||||||
|
|
||||||
``` yaml
|
``` yaml title="traefik-dashboard.yml"
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
@@ -251,7 +258,7 @@ Save the following to `traefik-dashboard.yml` in your workspace.
|
|||||||
spec.ingressClassName: traefik
|
spec.ingressClassName: traefik
|
||||||
spec:
|
spec:
|
||||||
rules:
|
rules:
|
||||||
- host: internal.${DOMAIN}
|
- host: traefik.${DOMAIN}
|
||||||
http:
|
http:
|
||||||
paths:
|
paths:
|
||||||
- path: /
|
- path: /
|
||||||
@@ -272,7 +279,11 @@ Save the following to `traefik-dashboard.yml` in your workspace.
|
|||||||
|
|
||||||
### Create Service & Ingress Resources
|
### Create Service & Ingress Resources
|
||||||
|
|
||||||
[envsubst](https://www.gnu.org/software/gettext/manual/html_node/envsubst-Invocation.html) - enables code-reuse by providing environment variable substituion as demonstrated below.
|
First, set the environment variable for to your domain.
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
export DOMAIN=your.domain.com
|
||||||
|
```
|
||||||
|
|
||||||
=== "Bash"
|
=== "Bash"
|
||||||
|
|
||||||
@@ -292,6 +303,10 @@ Save the following to `traefik-dashboard.yml` in your workspace.
|
|||||||
traefik-metrics ClusterIP 10.43.189.128 <none> 9100/TCP 25s
|
traefik-metrics ClusterIP 10.43.189.128 <none> 9100/TCP 25s
|
||||||
```
|
```
|
||||||
|
|
||||||
|
!!! note annotate "Why are passing the yaml file into `envsubst`? (1)"
|
||||||
|
|
||||||
|
1. `envsubst` - [gnu](https://www.gnu.org/software/gettext/manual/html_node/envsubst-Invocation.html) - enables code-reuse by providing environment variable substituion as demonstrated above.
|
||||||
|
|
||||||
### Access Dashboards
|
### Access Dashboards
|
||||||
|
|
||||||
That's it. You should now be able to access the Traefik Ingress Controller Dashboard and metrics remotely.
|
That's it. You should now be able to access the Traefik Ingress Controller Dashboard and metrics remotely.
|
||||||
@@ -301,7 +316,7 @@ Don't forget to include the appropriate uri paths:
|
|||||||
=== "Traefik Dashboard"
|
=== "Traefik Dashboard"
|
||||||
|
|
||||||
```
|
```
|
||||||
https://internal.your.domain.com/dashboard/
|
https://traefik.your.domain.com/dashboard/
|
||||||
```
|
```
|
||||||
|
|
||||||
!!! tip "When navigating to the traefik dashboard the `/` at the end is necessary. `/dashboard` will not work. "
|
!!! tip "When navigating to the traefik dashboard the `/` at the end is necessary. `/dashboard` will not work. "
|
||||||
@@ -309,7 +324,7 @@ Don't forget to include the appropriate uri paths:
|
|||||||
=== "Promethus Metrics"
|
=== "Promethus Metrics"
|
||||||
|
|
||||||
```
|
```
|
||||||
https://internal.your.domain.com/metrics
|
https://traefik.your.domain.com/metrics
|
||||||
```
|
```
|
||||||
|
|
||||||
### Disable Dashboards
|
### Disable Dashboards
|
||||||
|
|||||||
@@ -6,9 +6,10 @@ theme:
|
|||||||
name: material
|
name: material
|
||||||
features:
|
features:
|
||||||
- navigation.instant
|
- navigation.instant
|
||||||
|
- content.code.copy
|
||||||
|
- content.code.select
|
||||||
icon:
|
icon:
|
||||||
admonition:
|
admonition:
|
||||||
note: fontawesome/solid/note-sticky
|
|
||||||
abstract: fontawesome/solid/book
|
abstract: fontawesome/solid/book
|
||||||
info: fontawesome/solid/circle-info
|
info: fontawesome/solid/circle-info
|
||||||
success: fontawesome/solid/check
|
success: fontawesome/solid/check
|
||||||
@@ -18,6 +19,7 @@ theme:
|
|||||||
bug: fontawesome/solid/robot
|
bug: fontawesome/solid/robot
|
||||||
example: fontawesome/solid/flask
|
example: fontawesome/solid/flask
|
||||||
quote: fontawesome/solid/quote-left
|
quote: fontawesome/solid/quote-left
|
||||||
|
annotation: material/plus-circle
|
||||||
repo: fontawesome/brands/github
|
repo: fontawesome/brands/github
|
||||||
palette:
|
palette:
|
||||||
# Palette toggle for dark mode
|
# Palette toggle for dark mode
|
||||||
@@ -32,8 +34,10 @@ theme:
|
|||||||
icon: material/weather-night
|
icon: material/weather-night
|
||||||
name: Switch to dark mode
|
name: Switch to dark mode
|
||||||
markdown_extensions:
|
markdown_extensions:
|
||||||
- admonition
|
|
||||||
- abbr
|
- abbr
|
||||||
|
- admonition
|
||||||
|
- attr_list
|
||||||
|
- md_in_html
|
||||||
- pymdownx.snippets:
|
- pymdownx.snippets:
|
||||||
auto_append:
|
auto_append:
|
||||||
- includes/abbreviations.md
|
- includes/abbreviations.md
|
||||||
|
|||||||
@@ -10,9 +10,6 @@ server {
|
|||||||
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
|
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
|
||||||
add_header X-XSS-Protection "1; mode=block";
|
add_header X-XSS-Protection "1; mode=block";
|
||||||
|
|
||||||
ssl_protocols TLSv1.2 TLSv1.3;
|
|
||||||
ssl_prefer_server_ciphers on;
|
|
||||||
|
|
||||||
# rskio logging is handled via traefik
|
# rskio logging is handled via traefik
|
||||||
#access_log /var/log/nginx/host.access.log main;
|
#access_log /var/log/nginx/host.access.log main;
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,29 @@
|
|||||||
# To enable update provider in traefik.yml
|
# To enable update provider in traefik.yml
|
||||||
|
|
||||||
|
tls:
|
||||||
|
options:
|
||||||
|
default:
|
||||||
|
minVersion: VersionTLS12
|
||||||
|
mintls13:
|
||||||
|
minVersion: VersionTLS13
|
||||||
|
cipherSuites:
|
||||||
|
- TLS_AES_256_GCM_SHA384
|
||||||
|
- TLS_AES_128_GCM_SHA256
|
||||||
|
- TLS_CHACHA20_POLY1305_SHA256
|
||||||
|
- TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
|
||||||
|
- TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
|
||||||
|
- TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
|
||||||
|
- TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
|
||||||
|
- TLS_FALLBACK_SCSV
|
||||||
|
|
||||||
|
http:
|
||||||
|
middlewares:
|
||||||
|
secureHeaders:
|
||||||
|
headers:
|
||||||
|
browserXssFilter: true
|
||||||
|
contentTypeNosniff: true
|
||||||
|
forceSTSHeader: true
|
||||||
|
frameDeny: true
|
||||||
|
referrerPolicy: "same-origin"
|
||||||
|
sslRedirect: true
|
||||||
|
stsSeconds: 31536000
|
||||||
|
|||||||
@@ -10,12 +10,14 @@ entryPoints:
|
|||||||
entryPoint:
|
entryPoint:
|
||||||
to: websecure
|
to: websecure
|
||||||
priority: 10
|
priority: 10
|
||||||
|
middlewares:
|
||||||
|
- secureHeaders@file
|
||||||
websecure:
|
websecure:
|
||||||
address: :443
|
address: :443
|
||||||
http3:
|
http3:
|
||||||
advertisedPort: 443
|
advertisedPort: 443
|
||||||
|
|
||||||
certificatesresolvers:
|
certificatesResolvers:
|
||||||
rskio_certresolver:
|
rskio_certresolver:
|
||||||
acme:
|
acme:
|
||||||
tlschallenge: true
|
tlschallenge: true
|
||||||
@@ -40,7 +42,7 @@ providers:
|
|||||||
endpoint: unix:///var/run/docker.sock
|
endpoint: unix:///var/run/docker.sock
|
||||||
network: rskio_default
|
network: rskio_default
|
||||||
exposedByDefault: false
|
exposedByDefault: false
|
||||||
# file:
|
file:
|
||||||
# filename: /etc/traefik/dynamic.yml
|
filename: /etc/traefik/dynamic.yml
|
||||||
# watch: true
|
watch: true
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user