Kubernetes
Last updated on 2025-08-08 (history).
# Tips and tricks for Kubernetes
## Saving secret with kubectl
There are multiple ways to save secret in k8s
cluster. One of the simple ways
to do this with kubectl
is:
|
|
Instead of using echo
, the k8s
object can be store in file and secret can be
created with kubectl apply -f /path/to/file.yaml
as well.
Adding new secrets into k8s
object and applying it will results in new secret
getting added or older one's getting updated if same key is used.
For example,
|
|
With applying this secret, the following two things will happen.
username
key will be added.- Value for
password
key will be updated.
Note that, removing keys from the secret.yaml
file does not result in removal
of secret from the object in k8s cluster. For removal, kubectl edit secret ...
can be used.