Skip to content

Commit

Permalink
Process no config found
Browse files Browse the repository at this point in the history
  • Loading branch information
LeaveMyYard committed May 15, 2023
1 parent 760e6ce commit 4b1b389
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions robusta_krr/core/models/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Any, Literal, Optional, Union

import sys
import pydantic as pd
from kubernetes import config
from kubernetes.config.config_exception import ConfigException
Expand All @@ -9,10 +10,16 @@

try:
config.load_incluster_config()
IN_CLUSTER = True
except ConfigException:
config.load_kube_config()
try:
config.load_kube_config()
except ConfigException:
print("[CRITICAL] Could not load kubernetes configuration. Do you have kubeconfig set up?")
sys.exit(1)

IN_CLUSTER = False
else:
IN_CLUSTER = True


class Config(pd.BaseSettings):
Expand Down

0 comments on commit 4b1b389

Please sign in to comment.