|
| 1 | +# setup_ksops |
| 2 | + |
| 3 | +Installs and sets up the KSOPS Kustomize plugin on the OpenShift GitOps Operator. |
| 4 | + |
| 5 | +## Variables |
| 6 | + |
| 7 | +| Variable | Default | Required | Description |
| 8 | +| ---------------- | ------- | -------- | ----------- |
| 9 | +| sk_age_key | | yes | A literal age generated (age-keygen) key. If kept in a version control service, it's recommeneded to vault-encrypt it. |
| 10 | + |
| 11 | +## Example of age key |
| 12 | + |
| 13 | +``` |
| 14 | +# created: 2025-04-16T11:28:48Z |
| 15 | +# public key: age1j24rsa89nhv86dstnl696pfhxlngktjl5gcvya6y6ykg8t5jkqgsv0ua36 |
| 16 | +AGE-SECRET-KEY-16NSYF9LSS3QZKLXFEYS5K36FPQC62QLZPNA02H7YWV0SFFVXF2PQNRZPNQ |
| 17 | +``` |
| 18 | + |
| 19 | +## Usage examples |
| 20 | + |
| 21 | +``` |
| 22 | +- name: Setup the KSOPS Kustomize plugin |
| 23 | + ansible.builtin.include_role: |
| 24 | + name: redhatci.ocp.acm.setup_ksops |
| 25 | + vars: |
| 26 | + sk_age_key: | |
| 27 | + # created: 2025-04-16T11:28:48Z |
| 28 | + # public key: age1j24rsa89nhv86dstnl696pfhxlngktjl5gcvya6y6ykg8t5jkqgsv0ua36 |
| 29 | + AGE-SECRET-KEY-16NSYF9LSS3QZKLXFEYS5K36FPQC62QLZPNA02H7YWV0SFFVXF2PQNRZPNQ |
| 30 | +``` |
| 31 | + |
| 32 | +## How to encrypt the gitops data |
| 33 | + |
| 34 | +Install first the required binaries (age and [sops](https://github.com/getsops/sops/releases)): |
| 35 | + |
| 36 | +``` |
| 37 | +dnf install age |
| 38 | +
|
| 39 | +# Download the sops binary |
| 40 | +curl -LO https://github.com/getsops/sops/releases/download/v3.10.2/sops-v3.10.2.linux.amd64 |
| 41 | +
|
| 42 | +# Move the binary in to your PATH |
| 43 | +mv sops-v3.10.2.linux.amd64 /usr/local/bin/sops |
| 44 | +
|
| 45 | +# Make the binary executable |
| 46 | +chmod +x /usr/local/bin/sops |
| 47 | +
|
| 48 | +``` |
| 49 | + |
| 50 | +Create a working directory: |
| 51 | + |
| 52 | +``` |
| 53 | +mkdir sops |
| 54 | +cd sops |
| 55 | +``` |
| 56 | + |
| 57 | +Create an age key: |
| 58 | + |
| 59 | +``` |
| 60 | +age-keygen -o age.key |
| 61 | +``` |
| 62 | + |
| 63 | +Define the SOPS creation rules. The age public key is available in the age.key file: |
| 64 | + |
| 65 | +``` |
| 66 | +cat <<EOF > .sops.yaml |
| 67 | +creation_rules: |
| 68 | + - encrypted_regex: "^(data|stringData)$" |
| 69 | + age: age1...< your age public key> |
| 70 | +EOF |
| 71 | +``` |
| 72 | + |
| 73 | +Encrypt your secret files in your local copy of the GitOps repository: |
| 74 | + |
| 75 | +``` |
| 76 | +sops --encrypt --in-place /path/to/gitops/secret.yaml |
| 77 | +``` |
| 78 | + |
| 79 | +Add a KSOPS generator to your repository: |
| 80 | + |
| 81 | +``` |
| 82 | +cat <<EOF > secret-generator.yaml |
| 83 | +apiVersion: viaduct.ai/v1 |
| 84 | +kind: ksops |
| 85 | +metadata: |
| 86 | + # Specify a name |
| 87 | + name: secret-generator |
| 88 | +files: |
| 89 | + - ./secret.yaml |
| 90 | +EOF |
| 91 | +``` |
| 92 | + |
| 93 | +Include the KSOPS generator in your kustomization file: |
| 94 | + |
| 95 | +``` |
| 96 | +cat <<EOF > kustomization.yaml |
| 97 | +generators: |
| 98 | + - ./secret-generator.yaml |
| 99 | +EOF |
| 100 | +``` |
| 101 | + |
| 102 | +Add the new files to your git repository and commit the changes. |
0 commit comments