Skip to content

Commit

Permalink
Merge 2c3c03b into f79147a
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego committed Jun 9, 2020
2 parents f79147a + 2c3c03b commit 0211a08
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
6 changes: 3 additions & 3 deletions reana_commons/config.py
Expand Up @@ -49,6 +49,9 @@
- ``id``: unique identifier for the component, by default UUID4.
"""

REANA_KUBERNETES_NAMESPACE = os.getenv("REANA_KUBERNETES_NAMESPACE", "default")
"""Kubernetes namespace in which REANA is currectly deployed."""

MQ_HOST = os.getenv(
"RABBIT_MQ_HOST", "{}-message-broker".format(REANA_COMPONENT_PREFIX)
)
Expand Down Expand Up @@ -199,9 +202,6 @@
REANA_WORKFLOW_UMASK = 0o0002
"""Umask used for workflow worksapce."""

K8S_DEFAULT_NAMESPACE = "default"
"""Kubernetes workflow runtime default namespace"""

WORKFLOW_RUNTIME_USER_NAME = os.getenv("WORKFLOW_RUNTIME_USER_NAME", "reana")
"""Default OS user name for running job controller."""

Expand Down
13 changes: 8 additions & 5 deletions reana_commons/k8s/secrets.py
Expand Up @@ -14,8 +14,8 @@
from kubernetes import client
from kubernetes.client.rest import ApiException
from reana_commons.config import (
K8S_DEFAULT_NAMESPACE,
REANA_COMPONENT_PREFIX,
REANA_KUBERNETES_NAMESPACE,
REANA_USER_SECRET_MOUNT_PATH,
)
from reana_commons.errors import REANASecretAlreadyExists, REANASecretDoesNotExist
Expand All @@ -39,12 +39,15 @@ def _initialise_user_secrets_store(self):
try:
empty_k8s_secret = client.V1Secret(
api_version="v1",
metadata=client.V1ObjectMeta(name=str(self.user_secret_store_id)),
metadata=client.V1ObjectMeta(
name=str(self.user_secret_store_id),
namespace=REANA_KUBERNETES_NAMESPACE,
),
data={},
)
empty_k8s_secret.metadata.annotations = {"secrets_types": "{}"}
current_k8s_corev1_api_client.create_namespaced_secret(
K8S_DEFAULT_NAMESPACE, empty_k8s_secret
REANA_KUBERNETES_NAMESPACE, empty_k8s_secret
)
return empty_k8s_secret
except ApiException as api_e:
Expand All @@ -63,14 +66,14 @@ def _update_store(self, k8s_user_secrets):
version of the store.
"""
current_k8s_corev1_api_client.replace_namespaced_secret(
str(self.user_secret_store_id), K8S_DEFAULT_NAMESPACE, k8s_user_secrets
str(self.user_secret_store_id), REANA_KUBERNETES_NAMESPACE, k8s_user_secrets
)

def _get_k8s_user_secrets_store(self):
"""Retrieve the Kubernetes secret which contains all user secrets."""
try:
k8s_user_secrets_store = current_k8s_corev1_api_client.read_namespaced_secret(
str(self.user_secret_store_id), K8S_DEFAULT_NAMESPACE
str(self.user_secret_store_id), REANA_KUBERNETES_NAMESPACE
)
k8s_user_secrets_store.data = k8s_user_secrets_store.data or {}
return k8s_user_secrets_store
Expand Down

0 comments on commit 0211a08

Please sign in to comment.