My k8s howtos
At work, we deploy on Kubernetes clusters using terraform. From a developer perspective, from writing code to running in production, those technologies make it incredibly fast. Yet sometimes it can takes you hours or even days of random roundtrips between CI/CD, small terraform changes and reading logs. Some tasks are not easy to do, or well, you have to remember how to do them because you don't perform them very often. So, here is my log of useful commands.
How to copy a secret from a namespace to another one
kubectl --context sourceContext get secret mySecret -o yaml | sed 's/namespace: .*/namespace: targetNamespace/' | kubectl --context targetContext apply -f -
It simply fetches in YAML the secret we want to copy, then replace in that YAML the namespace to be the destination namespace and use that transformed YAML file to perform an apply
which will create the secret in the desired namespace. Easy.