Skip to content

Commit

Permalink
Add ramen cloud credentials secret in managed clusters
Browse files Browse the repository at this point in the history
We configured ramen to access velero cloud-credentials secret:

    veleroNamespaceSecretKeyRef:
      key: cloud
      name: cloud-credentials

Using the secret created by `velero install`. However this secret is
installed in `velero` namespace and we need it in `ramen-system`
namespace.

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
  • Loading branch information
nirs committed Jul 18, 2023
1 parent d6f4e02 commit 0205e7c
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ramenctl/ramenctl/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,28 @@ def run(args):
log=command.debug,
)

command.debug(
"Getting velero cloud credentials from cluster '%s'",
env["clusters"][0],
)
cloud = kubectl.get(
"secret/cloud-credentials",
"--namespace=velero",
"--output=jsonpath={.data.cloud}",
context=env["clusters"][0],
)
template = drenv.template(command.resource("cloud-credentials-secret.yaml"))
yaml = template.substitute(cloud=cloud, namespace=args.ramen_namespace)

for cluster in env["clusters"]:
command.info("Creating cloud credentials secret in cluster '%s'", cluster)
kubectl.apply(
"--filename=-",
input=yaml,
context=cluster,
log=command.debug,
)

command.info("Updating ramen config map")
template = drenv.template(command.resource("configmap.yaml"))
yaml = template.substitute(
Expand Down
12 changes: 12 additions & 0 deletions ramenctl/ramenctl/resources/cloud-credentials-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: cloud-credentials
namespace: $namespace
data:
cloud: $cloud
13 changes: 13 additions & 0 deletions ramenctl/ramenctl/unconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,16 @@ def run(args):
context=env["hub"],
log=command.debug,
)

template = drenv.template(command.resource("cloud-credentials-secret.yaml"))
yaml = template.substitute(cloud="", namespace=args.ramen_namespace)

for cluster in env["clusters"]:
command.info("Deleting cloud credentials secret in cluster '%s'", cluster)
kubectl.delete(
"--filename=-",
"--ignore-not-found",
input=yaml,
context=cluster,
log=command.debug,
)

0 comments on commit 0205e7c

Please sign in to comment.