Skip to content

Commit 849618b

Browse files
authored
ADD userguide/managingApp/secret-management (#6412)
* ADD managingApp/secret-management Signed-off-by: rahulshendre <rahulshendre789@gmail.com> * Enchance wording Signed-off-by: rahulshendre <rahulshendre789@gmail.com> * removed lambda fuction Signed-off-by: rahulshendre <rahulshendre789@gmail.com> --------- Signed-off-by: rahulshendre <rahulshendre789@gmail.com>
1 parent 1443975 commit 849618b

File tree

1 file changed

+114
-0
lines changed

1 file changed

+114
-0
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
title: "Secret management"
3+
linkTitle: "Secret management"
4+
weight: 9
5+
description: >
6+
Storing secrets safely in the Git repository.
7+
---
8+
9+
GitOps workflows use Git as the single source of truth for application configurations. Storing sensitive data such as credentials, API keys, and secrets directly in Git repositories poses security risks.
10+
11+
PipeCD's secret management feature allows you to store encrypted secrets in your Git repository alongside application manifests. The encrypted secrets are decrypted by `piped` during deployment operations.
12+
13+
## Prerequisites
14+
15+
Before using this feature, `piped` needs to be started with a key pair for secret encryption.
16+
17+
You can use the following command to generate a key pair:
18+
19+
``` console
20+
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out private-key
21+
openssl pkey -in private-key -pubout -out public-key
22+
```
23+
24+
Then specify them while [installing](../../../installation/install-piped/installing-on-kubernetes) `piped` with these options:
25+
26+
``` console
27+
--set-file secret.data.secret-public-key=PATH_TO_PUBLIC_KEY_FILE \
28+
--set-file secret.data.secret-private-key=PATH_TO_PRIVATE_KEY_FILE
29+
```
30+
31+
Finally, enable this feature in the Piped configuration file with the `secretManagement` field as below:
32+
33+
``` yaml
34+
apiVersion: pipecd.dev/v1beta1
35+
kind: Piped
36+
spec:
37+
pipedID: your-piped-id
38+
...
39+
secretManagement:
40+
type: KEY_PAIR
41+
config:
42+
privateKeyFile: /etc/piped-secret/secret-private-key
43+
publicKeyFile: /etc/piped-secret/secret-public-key
44+
```
45+
46+
## How it works
47+
48+
The secret management workflow is as follows:
49+
50+
- Encrypt secret data using PipeCD's Web UI and store the encrypted data in Git
51+
- `piped` automatically decrypts the encrypted secrets before performing deployment tasks
52+
53+
## Encrypting secret data
54+
55+
To encrypt secret data, navigate to the Applications page and click the "Encrypt Secret" button located in the top-left corner. Then, select a piped from the dropdown list, enter your secret data, and click the "ENCRYPT" button.
56+
Copy the encrypted data to store in Git.
57+
58+
![Sealed Secret Button](/images/sealed-secret-button.png)
59+
<p style="text-align: center;">
60+
Applications page
61+
</p>
62+
63+
<br>
64+
65+
![Sealed Secret Encrypting Drawer Form](/images/sealed-secret-encrypting-drawer-form.png)
66+
<p style="text-align: center;">
67+
The form for encrypting secret data
68+
</p>
69+
70+
## Storing encrypted secrets in Git
71+
72+
To make encrypted secrets available to an application, specify them in the application configuration file.
73+
74+
- `encryptedSecrets` contains a list of the encrypted secrets.
75+
- `decryptionTargets` contains a list of files that use one of the encrypted secrets and should be decrypted by `piped`.
76+
77+
``` yaml
78+
apiVersion: pipecd.dev/v1beta1
79+
# One of Piped defined app, for example: using the Kubernetes plugin
80+
kind: Application
81+
spec:
82+
encryption:
83+
encryptedSecrets:
84+
password: encrypted-data
85+
decryptionTargets:
86+
- secret.yaml
87+
```
88+
89+
## Accessing encrypted secrets
90+
91+
Any file in the application directory can use the `.encryptedSecrets` context to access secrets you have encrypted and stored in the application configuration.
92+
93+
For example:
94+
95+
- Accessing by a Kubernetes Secret manifest
96+
97+
``` yaml
98+
apiVersion: v1
99+
kind: Secret
100+
metadata:
101+
name: simple-sealed-secret
102+
data:
103+
password: "{{ .encryptedSecrets.password }}"
104+
```
105+
106+
In all cases, `piped` decrypts the encrypted secrets and renders the decryption target files before using them to handle any deployment tasks.
107+
108+
<!-- ## Examples
109+
110+
- [examples/kubernetes/secret-management](https://github.com/pipe-cd/examples/tree/master/kubernetes/secret-management)
111+
- [examples/cloudrun/secret-management](https://github.com/pipe-cd/examples/tree/master/cloudrun/secret-management)
112+
- [examples/terraform/secret-management](https://github.com/pipe-cd/examples/tree/master/terraform/secret-management)
113+
- [examples/ecs/secret-management](https://github.com/pipe-cd/examples/tree/master/ecs/secret-management) -->
114+

0 commit comments

Comments
 (0)