Skip to content

Commit 3f62898

Browse files
committed
Incorporated SME review comments
1 parent fc5a6f1 commit 3f62898

4 files changed

Lines changed: 65 additions & 29 deletions

File tree

_topic_maps/_topic_map.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ Topics:
117117
File: securing-webhooks-with-event-listeners
118118
- Name: Authenticating pipelines with repositories using secrets
119119
File: authenticating-pipelines-repos-using-secrets
120-
- Name: Using secrets from dedicated stores
121-
File: using-secret-stores
120+
- Name: Using secrets from external secret stores
121+
File: using-secrets-from-external-secret-stores
122122
- Name: Unprivileged building of container images using Buildah
123123
File: unprivileged-building-of-container-images-using-buildah
124124
- Name: Using buildah-ns tekton task

modules/op-csi-secrets.adoc

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,48 @@
33
// * secure/using-csi-secrets.adoc
44

55
:_mod-docs-content-type: PROCEDURE
6-
[id="configuring-results_{context}"]
7-
= Consuming secrets from an external store such as Hashicorp Vault using the Secrets Store CSI Driver
6+
[id="consuming-secrets-csi_{context}"]
7+
= Consuming secrets from external stores using the Secrets Store CSI Driver
88

9-
If you want to use secrets from an external store that has a CSI (container storage interface) provider, for example, Hashicorp Vault, you can configure {pipelines-shortname} to consume these secrets using the Secrets Store CSI Driver.
9+
[role="_abstract"]
10+
To use secrets from an external secret store that has a Container Storage Interface (CSI) provider, such as HashiCorp Vault, you can configure {pipelines-shortname} to consume these secrets using the Secrets Store CSI Driver.
1011

1112
.Prerequisites
1213

13-
* You installed the Secrets Store CSI Driver. For information about installing the CSI Driver, see the link:https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/storage/using-container-storage-interface-csi#persistent-storage-csi-secrets-store[Secrets Store CSI Driver] in the {OCP} documentation.
14+
* You installed the Secrets Store CSI Driver. For information about installing the CSI Driver, see the link:https://docs.redhat.com/en/documentation/openshift_container_platform/latest/html/storage/using-container-storage-interface-csi#persistent-storage-csi-secrets-store[Secrets Store CSI Driver] in the {OCP} documentation.
1415
15-
* You installed the CSI provider for your external secret store. For information about installing Hashicorp Vault, including its CSI provider, on {OCP}, see link:https://developer.hashicorp.com/vault/docs/deploy/kubernetes/csi/installation[Install the Vault CSI provider] in the Hashicorp documentation.
16+
* You installed the CSI provider for your external secret store. For information about installing HashiCorp Vault, including its CSI provider, on {OCP}, see link:https://developer.hashicorp.com/vault/docs/deploy/kubernetes/csi/installation[Install the Vault CSI provider] in the Hashicorp documentation.
1617
+
1718
[NOTE]
1819
====
19-
If you want to use an instance of Hashicorp Vault running outside your {OCP} cluster, you must provide the address to that instance in the Helm configuration when installing the CSI Provider. For infoamtion about providing an external Vault address, see link:https://developer.hashicorp.com/vault/docs/deploy/kubernetes/helm/configuration#externalvaultaddr[Configuration] in the Hashicorp documentation.
20+
To use an instance of HashiCorp Vault running outside your {OCP} cluster, you must provide the address to that instance in the Helm configuration when installing the CSI Provider. For information about providing an external Vault address, see link:https://developer.hashicorp.com/vault/docs/deploy/kubernetes/helm/configuration#externalvaultaddr[Configuration] in the Hashicorp documentation.
2021
====
2122
22-
* You configured authentication with the secret store for an {OCP} service account, for example, `pipeline-sa`. For information about configuring Kubernetes authentication with Hashicorp Vault, see link:https://developer.hashicorp.com/vault/docs/auth/kubernetes[Kubernetes auth method] in the Hashicorp documentation.
23+
* You configured authentication with the secret store for an {OCP} service account, for example, `pipeline-sa`. For information about configuring Kubernetes authentication with HashiCorp Vault, see link:https://developer.hashicorp.com/vault/docs/auth/kubernetes[Kubernetes auth method] in the HashiCorp documentation.
2324
+
2425
[NOTE]
2526
====
2627
You must create the service account in the namespace in which you create pipelines and other Custom Resources (CRs) for {pipelines-shortname}.
2728
====
2829
30+
* Ensure that the Secrets Store CSI Driver service account has the required cluster-wide permissions to create service account tokens in all relevant namespaces. Without these permissions, pods will fail to start and you may encounter the following error:
31+
+
32+
[source,terminal]
33+
----
34+
User "system:serviceaccount:csi-driver:secrets-store-csi-driver" cannot create resource "serviceaccounts/token" in API group "" in the namespace "tekton-vault"
35+
----
36+
2937
.Procedure
3038

39+
. To allow the CSI driver to mount secrets volumes, configure the namespace to allow privileged pod security:
40+
+
41+
[source,terminal]
42+
----
43+
$ oc label namespace tekton-vault pod-security.kubernetes.io/enforce=privileged
44+
----
45+
3146
. In the namespace in which you create pipelines, for example, `tekton-vault`, create a `Role` resource that allows `get`, `list`, and `watch` operations for the `secrets` resource.
3247
+
33-
.Example definition of the `pipeline-role` role
3448
[source,yaml]
3549
----
3650
apiVersion: rbac.authorization.k8s.io/v1
@@ -46,7 +60,6 @@ rules:
4660

4761
. Create a `RoleBinding` resource that binds the `pipeline-role` role to the service account which you configured for authentication with the secret store, for example, `pipeline-sa`.
4862
+
49-
.Example definition of the `pipeline-role-binding` role binding
5063
[source,yaml]
5164
----
5265
apiVersion: rbac.authorization.k8s.io/v1
@@ -66,7 +79,6 @@ subjects:
6679

6780
. Create a `SecretProviderClass` CR that defines the secrets that your pipeline or task consumes and the mount path and filename (key) for each of these secrets.
6881
+
69-
.Example definition of the `vault-secret` `SecretProviderClass` CR
7082
[source,yaml]
7183
----
7284
apiVersion: secrets-store.csi.x-k8s.io/v1
@@ -88,10 +100,14 @@ spec:
88100
secretPath: "secret/data/my-secret"
89101
secretKey: "password"
90102
----
103+
+
104+
[WARNING]
105+
====
106+
The `vaultAddress` parameter used in this example uses `http` and `vaultSkipTLSVerify`: `"true"` only for demonstration purposes. For production use, configure Vault with a secure `https` endpoint and do not skip TLS verification.
107+
====
91108

92109
. In the definition of the task that consumes the secrets, define and mount a volume that uses the CSI secrets store driver and specifies the name of the `SecretProviderClass` CR. To minimise security exposure of secrets, mount them in the definition of a task and not of an entire pipeline.
93110
+
94-
.Example definition of a task that consumes secrets
95111
[source,yaml]
96112
----
97113
apiVersion: tekton.dev/v1
@@ -123,17 +139,29 @@ spec:
123139
+
124140
[NOTE]
125141
====
126-
The mount path that you specify in the pipeline or task definition overrides the path that you specify in the `SecretProviderClass` CR.
142+
* The mount path that you specify in the pipeline or task definition overrides the path that you specify in the `SecretProviderClass` CR.
143+
144+
* This example provides secrets for demonstration purposes only. In production environment, do not log secrets as they are visible in pod logs.
127145
====
128146

129147
. In the `PipelineRun` or `TaskRun` CR, assign the service account that is authenticated with the secret store to the task:
130148

131149
** If you create a `PipelineRun` CR, use the `taskRunSpecs` section to assign the service account to the particular task. Do not assign the service account to the entire pipeline.
132150
+
133-
.Example `PipelineRun` CR
134151
[source,yaml]
135152
----
136153
apiVersion: tekton.dev/v1
154+
kind: Pipeline
155+
metadata:
156+
name: vault-secret-pipeline
157+
namespace: tekton-vault
158+
spec:
159+
tasks:
160+
- name: read-secret
161+
taskRef:
162+
name: secret-task
163+
---
164+
apiVersion: tekton.dev/v1
137165
kind: PipelineRun
138166
metadata:
139167
name: vault-secret-pipeline-run
@@ -142,20 +170,21 @@ spec:
142170
pipelineRef:
143171
name: vault-secret-pipeline
144172
taskRunSpecs:
145-
- pipelineTaskName: secret-task
173+
- pipelineTaskName: read-secret
146174
serviceAccountName: pipeline-sa
147175
----
148176

149177
** If you create a `TaskRun` CR, use the `serviceAccountName` setting to assign the service account.
150178
+
151-
.Example `TaskRun` CR
152179
[source,yaml]
153180
----
181+
apiVersion: tekton.dev/v1
154182
kind: TaskRun
155183
metadata:
156184
name: vault-secret-task-run
185+
namespace: tekton-vault
157186
spec:
158187
taskRef:
159-
name: secretTask
188+
name: secret-task
160189
serviceAccountName: pipeline-sa
161190
----

secure/using-secret-stores.adoc

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
:_mod-docs-content-type: ASSEMBLY
2+
include::_attributes/common-attributes.adoc[]
3+
[id="using-secrets-from-external-secret-stores"]
4+
= Using secrets from external secret stores
5+
:context: using-secrets-from-external-secret-stores
6+
7+
toc::[]
8+
9+
[role="_abstract"]
10+
You can configure pipelines to consume secrets from external secret stores by using the Secrets Store CSI Driver.
11+
12+
include::modules/op-csi-secrets.adoc[leveloffset=+1]
13+
14+
[role="_additional-resources"]
15+
[id="additional-resources_{context}"]
16+
== Additional resources
17+
18+
link:https://secrets-store-csi-driver.sigs.k8s.io/getting-started/installation.html[Install the Secrets Store CSI Driver]

0 commit comments

Comments
 (0)