mirror of
https://github.com/phfroidmont/self-hosting.git
synced 2025-12-25 05:36:59 +01:00
Add basic auth to k8s dashboard
This commit is contained in:
parent
d8d9733ed9
commit
2315ed19df
4 changed files with 75 additions and 99 deletions
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
# set basic_auth_user as non-empty to enforce basic auth
|
||||
basic_auth_user: ""
|
||||
basic_auth_password: ""
|
||||
dashboard_basic_auth_user: ""
|
||||
dashboard_basic_auth_password: ""
|
||||
|
||||
# e.g. the fqdn would be k8s.yourdomain.tld if
|
||||
# dashboard_subdomain=k8s
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
- block:
|
||||
- name: Installing python-passlib
|
||||
apt:
|
||||
name: python-passlib
|
||||
name: python3-passlib
|
||||
state: latest
|
||||
register: result
|
||||
retries: 3
|
||||
|
|
@ -11,8 +11,8 @@
|
|||
- name: Creating htpasswd file if k8s has basic auth
|
||||
htpasswd:
|
||||
path: /tmp/auth
|
||||
name: "{{ basic_auth_user }}"
|
||||
password: "{{ basic_auth_password }}"
|
||||
name: "{{ dashboard_basic_auth_user }}"
|
||||
password: "{{ dashboard_basic_auth_password }}"
|
||||
when: inventory_hostname == initial_master
|
||||
|
||||
- name: Getting secrets
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
state: absent
|
||||
when: inventory_hostname == initial_master
|
||||
|
||||
when: basic_auth_user | length > 0
|
||||
when: dashboard_basic_auth_user | length > 0
|
||||
|
||||
- name: Templating manifests
|
||||
template:
|
||||
|
|
|
|||
|
|
@ -5,12 +5,9 @@ metadata:
|
|||
name: kubernetes-dashboard
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: traefik
|
||||
{% if basic_auth_user | length > 0 %}
|
||||
ingress.kubernetes.io/auth-type: basic
|
||||
# name of the secret that contains the user/password definitions
|
||||
ingress.kubernetes.io/auth-secret: dashboard-basic-auth
|
||||
# message to display with an appropiate context why the authentication is required
|
||||
ingress.kubernetes.io/auth-realm: "Authentication is required to access the k8s dashboard "
|
||||
{% if dashboard_basic_auth_user | length > 0 %}
|
||||
traefik.ingress.kubernetes.io/auth-type: basic
|
||||
traefik.ingress.kubernetes.io/auth-secret: dashboard-basic-auth
|
||||
{% endif %}
|
||||
|
||||
spec:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue