The Kubernetes Secret resource secures, stores, and controls access to tokens, passwords, certificates, and other secrets in modern computing. The Kubernetes Secrets extension provides your pipeline with access to Kubernetes secrets.
Creating Secrets
Create a secret resource using the Kubernetes yaml configuration language, and persist to your cluster using kubectl
. In the below example we store the Docker username and password.
|
|
Accessing Secrets
Once our secrets are stored in Kubernetes, we can update our yaml configuration file to request access to our secrets. First we define a secret resource in our yaml for each external secret. We include the path to the secret, and the name or key of value we want to retrieve:
|
|
We can then reference the named secrets in our pipeline:
|
|
Limiting Access
Secrets are available to all repositories and all build events by default. We strongly recommend that you limit access to secrets by repository and build events. This can be done by adding special annotations:
|
|
Limit By Repository
Use the X-Drone-Repos
key to limit which repositories can access your secret. The value is a comma-separate list of glob patterns. If a repository name matches at least one of the patterns, it is granted access to the secret.
Limit access to a single repository:
|
|
Limit access to all repositories in an organization:
|
|
Limit access to multiple repositories or organizations:
|
|
Limit By Event
Use the X-Drone-Events
key to limit which build events can access your secret. The value is a comma-separate list of events. If a build matches at least one of the events, it is granted access to the secret.
Limit access to push and tag events:
|
|
You can combine annotations to limit by repository and event:
|
|