You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/op-csi-secrets.adoc
+45-16Lines changed: 45 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,34 +3,48 @@
3
3
// * secure/using-csi-secrets.adoc
4
4
5
5
:_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
8
8
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.
10
11
11
12
.Prerequisites
12
13
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.
14
15
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.
16
17
+
17
18
[NOTE]
18
19
====
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.
20
21
====
21
22
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.
23
24
+
24
25
[NOTE]
25
26
====
26
27
You must create the service account in the namespace in which you create pipelines and other Custom Resources (CRs) for {pipelines-shortname}.
27
28
====
28
29
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
+
29
37
.Procedure
30
38
39
+
. To allow the CSI driver to mount secrets volumes, configure the namespace to allow privileged pod security:
. 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.
32
47
+
33
-
.Example definition of the `pipeline-role` role
34
48
[source,yaml]
35
49
----
36
50
apiVersion: rbac.authorization.k8s.io/v1
@@ -46,7 +60,6 @@ rules:
46
60
47
61
. 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`.
48
62
+
49
-
.Example definition of the `pipeline-role-binding` role binding
50
63
[source,yaml]
51
64
----
52
65
apiVersion: rbac.authorization.k8s.io/v1
@@ -66,7 +79,6 @@ subjects:
66
79
67
80
. 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.
68
81
+
69
-
.Example definition of the `vault-secret``SecretProviderClass` CR
70
82
[source,yaml]
71
83
----
72
84
apiVersion: secrets-store.csi.x-k8s.io/v1
@@ -88,10 +100,14 @@ spec:
88
100
secretPath: "secret/data/my-secret"
89
101
secretKey: "password"
90
102
----
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
+
====
91
108
92
109
. 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.
93
110
+
94
-
.Example definition of a task that consumes secrets
95
111
[source,yaml]
96
112
----
97
113
apiVersion: tekton.dev/v1
@@ -123,17 +139,29 @@ spec:
123
139
+
124
140
[NOTE]
125
141
====
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.
127
145
====
128
146
129
147
. In the `PipelineRun` or `TaskRun` CR, assign the service account that is authenticated with the secret store to the task:
130
148
131
149
** 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.
132
150
+
133
-
.Example `PipelineRun` CR
134
151
[source,yaml]
135
152
----
136
153
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
137
165
kind: PipelineRun
138
166
metadata:
139
167
name: vault-secret-pipeline-run
@@ -142,20 +170,21 @@ spec:
142
170
pipelineRef:
143
171
name: vault-secret-pipeline
144
172
taskRunSpecs:
145
-
- pipelineTaskName: secret-task
173
+
- pipelineTaskName: read-secret
146
174
serviceAccountName: pipeline-sa
147
175
----
148
176
149
177
** If you create a `TaskRun` CR, use the `serviceAccountName` setting to assign the service account.
0 commit comments