-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sops 3.7.1 introduces a limited AGE support[1] Disabling gpg importing key debug by default (can be overridden) [1] https://github.com/mozilla/sops#encrypting-using-age
- Loading branch information
Showing
12 changed files
with
185 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# SOPS AGE example | ||
|
||
SOPS function introduces for AGE case an additional `SOPS_IMPORT_AGE` ENV variable | ||
that must contain the [SOPS age keys.txt file](https://github.com/mozilla/sops/blob/master/age/keys.txt). | ||
This file is needed for decryption. For encryption it's possible to use | ||
`SOPS_AGE_RECIPIENTS` ENV variable or parameter `age`. | ||
|
||
E.g. for decryption it's possible to run: | ||
|
||
```sh | ||
kpt fn run --env SOPS_IMPORT_AGE="$(cat <file with age keys>.txt)" <folder> | ||
``` | ||
|
||
or if AGE keys are already stored in the host system so SOPS binary works locally, it's possible to run: | ||
|
||
```sh | ||
kpt fn run --env SOPS_IMPORT_AGE="$(cat ~/.config/sops/age/keys.txt)" <folder> | ||
``` | ||
|
||
## Function invocation | ||
|
||
Get this example and try it out by running the following commands: | ||
|
||
```sh | ||
# download sops kpt-function example | ||
kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/contrib/sops/age . | ||
|
||
# copy example AGE key from sops project | ||
curl -fsSL -o age_keys.txt https://raw.githubusercontent.com/mozilla/sops/master/age/keys.txt | ||
|
||
# run the function to work with AGE | ||
kpt fn run --env SOPS_IMPORT_AGE="$(cat age_keys.txt)" age | ||
``` | ||
|
||
## Expected result | ||
|
||
Verify the updated configuration: | ||
|
||
```sh | ||
kpt cfg cat age | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: my-decrypt-config | ||
annotations: | ||
config.k8s.io/function: | | ||
container: | ||
image: gcr.io/kpt-fn-contrib/sops:unstable | ||
envs: | ||
- SOPS_IMPORT_AGE | ||
config.kubernetes.io/local-config: "true" | ||
data: | ||
cmd: 'decrypt' | ||
cmd-json-path-filter: '$[?(@.metadata.name=="toDecrypt")]' | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: my-encrypt-config | ||
annotations: | ||
config.k8s.io/function: | | ||
container: | ||
image: gcr.io/kpt-fn-contrib/sops:unstable | ||
config.kubernetes.io/local-config: "true" | ||
data: | ||
cmd: 'encrypt' | ||
cmd-json-path-filter: '$[?(@.metadata.name=="toEncrypt")]' | ||
age: 'age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw' | ||
unencrypted-regex: '^(kind|apiVersion|group|metadata)$' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apiVersion: v1 | ||
kind: somekind | ||
metadata: | ||
name: toDecrypt | ||
nnn-password: ENC[AES256_GCM,data:G2i53KNBoAEycMHD5w==,iv:PjywQXtBGZDgn5zNgI/0BsKiov7drduyyXSt8gNtdDs=,tag:slGGtNbvT01rtgDb1pCkFw==,type:str] | ||
user-password: ENC[AES256_GCM,data:iM5w/l6egeDlvkjc2tpk,iv:kBtgkTNuNuUL6FvYGa+NA0U0jkcmm0IIRZ8j5PicSMs=,tag:lACKq9kbf4n72xFmZb1Ymw==,type:str] | ||
k8s-password: ENC[AES256_GCM,data:uZb3qTvx3Ucq,iv:VQTP3fimb3uitY/0LuJMhvdjd2s9bq8xguWgTOkCqG4=,tag:4JT50F72xL5Gyy5mqGjkrg==,type:str] | ||
sops: | ||
kms: [] | ||
gcp_kms: [] | ||
azure_kv: [] | ||
hc_vault: [] | ||
age: | ||
- recipient: age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw | ||
enc: | | ||
-----BEGIN AGE ENCRYPTED FILE----- | ||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBsR2ZvT21Bd2NuWnBXaFZa | ||
OG9YUzg2b1g1VDQ3bHlaSGdMQW10UE9jYjEwCndSbWpDdis4S1IyOFdxL2U4eDVL | ||
cG00RUxpcE1IRnR3cVk0dDJtK3Zwc00KLS0tIHhuNlVTakF1a3dyZFF4ZWg3TXFE | ||
QzFjYmR1MVh3bVhydURmZ25ORmQxNGsKkcHUujLrlwycauIr1nJ9O9KG4T6NkmMv | ||
8szwCF4AuqHzhSKhqGzYUnRQB1Igfpw85XjdR5O1aCf0mux/+E6Ihg== | ||
-----END AGE ENCRYPTED FILE----- | ||
lastmodified: "2021-04-27T04:12:50Z" | ||
mac: ENC[AES256_GCM,data:darUiOLASNLXAMucmoQsaMvAk6KmMkb5owGfv38vsaF8JDXhxom0B6MTp2KRyiliv2KICEWv8BRofNXWQpgKGwvS8CPmZic7JgqdJhNpNVrt5NipisMcCigUVdk7WtQ73l7tTuqI5vBg9FnrnDgndnTr4CoqjxwThlbTtNy7+30=,iv:WmiLyZMMtsyL3KOTaki6EClKAyJ2KcVxanxcVJZGalo=,tag:ZJOBM+1NiyDN0a+OSndG6Q==,type:str] | ||
pgp: [] | ||
unencrypted_regex: ^(kind|apiVersion|group|metadata)$ | ||
version: 3.7.1 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# SOPS PGP example | ||
|
||
SOPS function introduces for PGP case an additional `SOPS_IMPORT_PGP` ENV variable | ||
that must contain the private key(s) needed to decrypt yamls and public key(s) to | ||
encrypt yamls. If you have a file with keys it's possible to run: | ||
|
||
```sh | ||
kpt fn run --env SOPS_IMPORT_PGP="$(cat <file with exported key>.asc)" <folder> | ||
``` | ||
|
||
or if your keys are already in stored in `gpg`-storage, it's possible to run: | ||
|
||
```sh | ||
kpt fn run --env SOPS_IMPORT_PGP="$(gpg --armor --export-secret-keys)" <folder> | ||
``` | ||
|
||
## Function invocation | ||
|
||
Get this example and try it out by running the following commands: | ||
|
||
```sh | ||
# download sops kpt-function example | ||
kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/contrib/sops/gpg . | ||
|
||
# copy example GPG key from sops project | ||
curl -fsSL -o gpg_keys.asc https://raw.githubusercontent.com/mozilla/sops/master/pgp/sops_functional_tests_key.asc | ||
|
||
# run the function to work with GPG | ||
kpt fn run --env SOPS_IMPORT_PGP="$(cat gpg_keys.asc)" gpg | ||
``` | ||
|
||
## Expected result | ||
|
||
Verify the updated configuration: | ||
|
||
```sh | ||
kpt cfg cat gpg | ||
``` |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: v1 | ||
kind: somekind | ||
metadata: | ||
name: toEncrypt | ||
nnn-password: password1 | ||
user-password: password2 | ||
k8s-password: password3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters