I'm new to Kubernetes and I have a use case where I want to read data from another deployment.
In the following file, the the RabbitmqCluster
creates a default user. I want to extract the credentials of that user into a secret for use in other services that need to publish or subscribe to that broker:
apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
name: broker
---
apiVersion: v1
kind: Secret
metadata:
name: broker-credentials-secret
type: Opaque
stringData:
username: $BROKER_USER # Available at $(kubectl get secret broker-default-user -o jsonpath='{.data.username}' | base64 --decode)
password: $BROKER_PASSWORD # Available at $(kubectl get secret broker-default-user -o jsonpath='{.data.password}' | base64 --decode)
My first thought was to separate into two different files, I could wait for the cluster to be ready and then sed
the BROKER_PASSWORD
and BROKER_USER
variables into the second config that then deploys the secret.
My question is: is there a proper way to handle this scenario? Should I just separate these two into two different files and write documentation about their intended order of deployment? Or is there a better way of doing this?