Skip to content

Commit

Permalink
Added the gke secret retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
keegansmith21 committed Jul 8, 2024
1 parent a4fa9b3 commit fd51430
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions observatory_platform/google/gke.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,22 @@ def gke_delete_volume(*, kubernetes_conn_id: str, volume_name: str):
logging.info(f"gke_delete_volume: PersistentVolume with name={volume_name} does not exist")
else:
raise e


def gke_retrieve_secret(*, secret_name: str, namespace: str):
"""Retrieves a secret from the GKE secrets backend
:param secret_name: the name of the secret to retrieve
:param namespace: the namespace that the secret belongs to
:return: The secret
"""
v1 = client.CoreV1Api()
try:
secret = v1.read_namespaced_secret(secret_name, namespace)
except client.exceptions.ApiException as e:
if e.status == 404:
print(f"Secret '{secret_name}' not found in namespace '{namespace}'")
else:
print(f"Exception when retrieving secret: {e}")

return secret

0 comments on commit fd51430

Please sign in to comment.