refactor(hacks): use wrapper function to load kube config

This commit is contained in:
Khue Doan 2024-01-16 14:15:39 +07:00
parent 23f695b8fb
commit 6ebedfbe8c

View File

@ -21,10 +21,7 @@ from kubernetes.stream import stream
# https://git.khuedoan.com/user/settings/applications # https://git.khuedoan.com/user/settings/applications
# Doing this properly inside the cluster requires: # Doing this properly inside the cluster requires:
# - Kubernetes service account # - Kubernetes service account
try: config.load_config()
config.load_incluster_config()
except config.ConfigException:
config.load_kube_config()
gitea_host = client.NetworkingV1Api().read_namespaced_ingress('gitea', 'gitea').spec.rules[0].host gitea_host = client.NetworkingV1Api().read_namespaced_ingress('gitea', 'gitea').spec.rules[0].host
gitea_user_secret = client.CoreV1Api().read_namespaced_secret('gitea-admin-secret', 'gitea') gitea_user_secret = client.CoreV1Api().read_namespaced_secret('gitea-admin-secret', 'gitea')