Migrate to k8s¶
The local_settings.py contains:
import ldap
from django_auth_ldap.config import LDAPSearch, LDAPSearchUnion
ALLOWED_HOSTS = [ '*' ]
AUTH_LDAP_SERVER_URI="ldaps://ldap1.ungleich.ch,ldaps://ldap2.ungleich.ch"
AUTH_LDAP_BIND_DN="..."
AUTH_LDAP_BIND_PASSWORD="...."
AUTH_LDAP_USER_SEARCH = LDAPSearch("dc=ungleich,dc=ch", ldap.SCOPE_SUBTREE, "(uid=%(user)s)")
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'app'
}
}
Solutions/k8s integrations¶
Move settings towards environment variables¶
- Import ldap by default (settings.py)
- Read the following variables from env:
- ALLOWED_HOSTS
- DEBUG
- AUTH_LDAP_SERVER_URI, AUTH_LDAP_BIND_DN, AUTH_LDAP_BIND_PASSWORD, AUTH_LDAP_USER_SEARCH
- Add/inject postgresql variables
Very app specific, but easily possible.
A more generic way¶
- Define postgresql = default db
- Supply postgresql config as /db.py or similar
- If the project includes secret.py, decrypt it using sealed-secrets or sops or similar