mirror of
https://github.com/house-of-vanity/OutFleet.git
synced 2025-07-06 17:14:07 +00:00
34 lines
877 B
Python
34 lines
877 B
Python
|
import base64
|
||
|
import json
|
||
|
import logging
|
||
|
from kubernetes import client, config
|
||
|
from kubernetes.client.rest import ApiException
|
||
|
|
||
|
logging.basicConfig(
|
||
|
level=logging.INFO,
|
||
|
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
||
|
datefmt="%d-%m-%Y %H:%M:%S",
|
||
|
)
|
||
|
|
||
|
log = logging.getLogger("OutFleet.k8s")
|
||
|
file_handler = logging.FileHandler("sync.log")
|
||
|
file_handler.setLevel(logging.DEBUG)
|
||
|
formatter = logging.Formatter(
|
||
|
"%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
||
|
)
|
||
|
file_handler.setFormatter(formatter)
|
||
|
log.addHandler(file_handler)
|
||
|
|
||
|
config.load_incluster_config()
|
||
|
|
||
|
v1 = client.CoreV1Api()
|
||
|
|
||
|
NAMESPACE = ""
|
||
|
|
||
|
log.info("Checking for Kubernetes environment")
|
||
|
try:
|
||
|
with open("/var/run/secrets/kubernetes.io/serviceaccount/namespace") as f:
|
||
|
NAMESPACE = f.read().strip()
|
||
|
except IOError:
|
||
|
log.info("Kubernetes environment not detected")
|
||
|
pass
|