From eb43ba75d2399d8ae0461cb85b9ce9a6a367cc2c Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 3 Sep 2019 13:44:30 +0100 Subject: [PATCH 1/5] chore(gcp): Remove monorepo repository The repository is now public on Github. --- infra/gcp/default.tf | 5 ----- 1 file changed, 5 deletions(-) diff --git a/infra/gcp/default.tf b/infra/gcp/default.tf index 677e737a2..18096bf2b 100644 --- a/infra/gcp/default.tf +++ b/infra/gcp/default.tf @@ -81,8 +81,3 @@ resource "google_service_account" "nixery" { account_id = "nixery" display_name = "Nixery service account" } - -# Configure a git repository in which to store my monorepo -resource "google_sourcerepo_repository" "monorepo" { - name = "monorepo" -} From abd5d7538c727e1aca7712455a799cf034d0fbaf Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 3 Sep 2019 15:13:34 +0100 Subject: [PATCH 2/5] feat(gcp): Create Cloud KMS resources for encrypting secrets The idea here is to use Cloud KMS and a shell script that mimics 'pass' to trick kontemplate into using Cloud KMS to decrypt secrets. --- infra/gcp/default.tf | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/infra/gcp/default.tf b/infra/gcp/default.tf index 18096bf2b..d13345393 100644 --- a/infra/gcp/default.tf +++ b/infra/gcp/default.tf @@ -27,24 +27,25 @@ resource "google_project_services" "primary" { "bigquerystorage.googleapis.com", "cloudapis.googleapis.com", "clouddebugger.googleapis.com", + "cloudkms.googleapis.com", "cloudtrace.googleapis.com", + "compute.googleapis.com", + "container.googleapis.com", + "containerregistry.googleapis.com", "datastore.googleapis.com", "dns.googleapis.com", + "iam.googleapis.com", + "iamcredentials.googleapis.com", "logging.googleapis.com", "monitoring.googleapis.com", + "oslogin.googleapis.com", + "pubsub.googleapis.com", "servicemanagement.googleapis.com", "serviceusage.googleapis.com", + "sourcerepo.googleapis.com", "sql-component.googleapis.com", "storage-api.googleapis.com", "storage-component.googleapis.com", - "container.googleapis.com", - "iam.googleapis.com", - "compute.googleapis.com", - "iamcredentials.googleapis.com", - "oslogin.googleapis.com", - "pubsub.googleapis.com", - "containerregistry.googleapis.com", - "sourcerepo.googleapis.com", ] } @@ -81,3 +82,22 @@ resource "google_service_account" "nixery" { account_id = "nixery" display_name = "Nixery service account" } + +# Configure Cloud KMS for secret encryption +resource "google_kms_key_ring" "tazjins_keys" { + name = "tazjins-keys" + location = "europe-north1" + + lifecycle { + prevent_destroy = true + } +} + +resource "google_kms_crypto_key" "kontemplate_key" { + name = "kontemplate-key" + key_ring = google_kms_key_ring.tazjins_keys.id + + lifecycle { + prevent_destroy = true + } +} From bcd7710be565a4711a43d56122b37c7b38514b81 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 3 Sep 2019 15:56:31 +0100 Subject: [PATCH 3/5] feat(tools): Introduce pass-compatible wrapper using Cloud KMS Adds a shell script that supports a subset of the 'pass' interface for compatibility with kontemplate, and wraps kontemplate in a script that places this version on the PATH. This makes it possible to use Cloud KMS encrypted secrets with kontemplate. --- .envrc | 1 + default.nix | 13 +++++++++ tools/bin/__dispatch.sh | 3 ++ tools/bin/pass | 1 + tools/kms_pass/default.nix | 60 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 78 insertions(+) create mode 120000 tools/bin/pass create mode 100644 tools/kms_pass/default.nix diff --git a/.envrc b/.envrc index d89bcd9d6..6b3ce7ebb 100644 --- a/.envrc +++ b/.envrc @@ -4,3 +4,4 @@ export PATH="${PWD}/tools/bin:${PATH}" export NIX_PATH="nixpkgs=${PWD}/default.nix" export REPO_ROOT="${PWD}" +export SECRETS_DIR="${PWD}/secrets" diff --git a/default.nix b/default.nix index ed6258108..3b5736a19 100644 --- a/default.nix +++ b/default.nix @@ -28,6 +28,13 @@ let blog = self.callPackage ./services/tazblog {}; blog_cli = self.callPackage ./tools/blog_cli {}; gemma = self.callPackage ./services/gemma {}; + + kms_pass = self.callPackage ./tools/kms_pass { + project = "tazjins-infrastructure"; + region = "europe-north1"; + keyring = "tazjins-keys"; + key = "kontemplate-key"; + }; }; # Third-party projects (either vendored or modified from nixpkgs) go here: @@ -49,6 +56,12 @@ let sha256 = "1wn7nmb1cqfk2j91l3rwc6yhimfkzxprb8wknw5wi57yhq9m6lv1"; }) {}).elmPackages; + # Wrap kontemplate to inject the Cloud KMS version of 'pass' + kontemplate = self.writeShellScriptBin "kontemplate" '' + export PATH="${self.tazjin.kms_pass}/bin:$PATH" + exec ${super.kontemplate}/bin/kontemplate $@ + ''; + # One of Gemma's dependencies is missing in nixpkgs' Quicklisp # package set, it is overlaid locally here. lispPackages = import ./third_party/common_lisp/quicklisp.nix { diff --git a/tools/bin/__dispatch.sh b/tools/bin/__dispatch.sh index 09b404f3b..20848bd51 100755 --- a/tools/bin/__dispatch.sh +++ b/tools/bin/__dispatch.sh @@ -22,6 +22,9 @@ case "${TARGET_TOOL}" in stern) attr="stern" ;; + pass) + attr="tazjin.kms_pass" + ;; *) echo "The tool '${TARGET_TOOL}' is currently not installed in this repository." exit 1 diff --git a/tools/bin/pass b/tools/bin/pass new file mode 120000 index 000000000..8390ec9c9 --- /dev/null +++ b/tools/bin/pass @@ -0,0 +1 @@ +__dispatch.sh \ No newline at end of file diff --git a/tools/kms_pass/default.nix b/tools/kms_pass/default.nix new file mode 100644 index 000000000..fbc17650a --- /dev/null +++ b/tools/kms_pass/default.nix @@ -0,0 +1,60 @@ +# This tool mimics a subset of the interface of 'pass', but uses +# Google Cloud KMS for encryption. +# +# It is intended to be compatible with how 'kontemplate' invokes +# 'pass.' +# +# Only the 'show' and 'insert' commands are supported. + +{ google-cloud-sdk, tree, writeShellScriptBin +, project, region, keyring, key }: + +writeShellScriptBin "pass" '' + set -eo pipefail + + CMD="$1" + readonly SECRET=$2 + readonly SECRET_PATH="$SECRETS_DIR/$SECRET" + + function secret_check { + if [[ -z $SECRET ]]; then + echo 'Secret must be specified' + exit 1 + fi + } + + if [[ -z $CMD ]]; then + CMD="ls" + fi + + case "$CMD" in + ls) + ${tree}/bin/tree $SECRETS_DIR + ;; + show) + secret_check + ${google-cloud-sdk}/bin/gcloud kms decrypt \ + --project ${project} \ + --location ${region} \ + --keyring ${keyring} \ + --key ${key} \ + --ciphertext-file $SECRET_PATH \ + --plaintext-file - + ;; + insert) + secret_check + ${google-cloud-sdk}/bin/gcloud kms encrypt \ + --project ${project} \ + --location ${region} \ + --keyring ${keyring} \ + --key ${key} \ + --ciphertext-file $SECRET_PATH \ + --plaintext-file - + echo "Inserted secret '$SECRET'" + ;; + *) + echo "Usage: pass show/insert " + exit 1 + ;; + esac +'' From 0bc548e75e7e06ee4ad172449f818d7e4b861b1d Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 3 Sep 2019 16:10:14 +0100 Subject: [PATCH 4/5] feat(secrets): Check in secrets required by Nixery --- secrets/nixery-gcs-json | Bin 0 -> 2416 bytes secrets/nixery-gcs-pem | Bin 0 -> 3214 bytes secrets/nixery-ssh-private | Bin 0 -> 1906 bytes 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 secrets/nixery-gcs-json create mode 100644 secrets/nixery-gcs-pem create mode 100644 secrets/nixery-ssh-private diff --git a/secrets/nixery-gcs-json b/secrets/nixery-gcs-json new file mode 100644 index 0000000000000000000000000000000000000000..b8b5445116856fe6dfc4db28d080a6ae4be42e72 GIT binary patch literal 2416 zcmd;5VYnFl=38ozvXT4Qiprkn?-QQqcdhjCX-^8cm@)CX;hx9eB3}s|7h-7Ze{PcJ z_cTk;#z&mZF(Enfx{{Qx_WOdXM+IFzZTmVy)UAK_3-`X|&mUMdjrCu`+w{MFlQ~!U zR7SA6?0?l{m1x$|;?(E&_f6~h|I58j@LX?XnEQYEtZbpghwjTVOtb9;-WOd>yz2gp zpWR|g+DV;vvMm2*eOwftv+T>-y(jLP-?x45B)j@<)Zx4D@7{gOCSA|9oQbcFpS6C| zSJByuygw~UwtktV^+fCC9m9o8%WRH5)K3@vW^=P%Hg>00d&LULuY#9X@8E67KWSlF zTKPg*Rgra-c>lAD3kr7bTytl|CMO%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LG*Q&+*^VtHQ6)qDg;W)L6WqPg^qtcn})2H%H z>itmpHR-dxcR-xzjqr@}9i0o#^WUDnDczwa<<+y7Gb?ZIVh%ido5^R7+C!!1CoDOh zmDfJsdfUE8FKy-x&xg$J7wTMJZj%b$y3;f|Up{}e`28o}!kg~%3FO$u)*D_doc@>V zyl?Q^qRqebwJVGsi>2)ReEabCBXbQ-UNLAanDasIf7F!d-h}7L0+$~M`0ma6)_wD} z((377S3mFnTFtR;VoRz8LtXHl<`vD)8wyKyWlfE5wNShAY}VuY+S#f9mEtbAcFm2- z*}t_fC`7&&!LtE^kY}x4i2e>to;Fv)23wxZHA$V|((Sn>nVZnYDgIbca1kR+iqq zm_1%H`rh6xW>2;1Vt;<`mwi9!gl3*{?+>X6sjj@t-wpSs)Z4aRnjP`9 zdA{udpLQ{`Gbb<2G4A57e4enLXSu=LC)#Is{L%gL_yfy@`ZNgvyIsCD`xd(~+w~X9 zZB&ruzIrh3Zq~xI8($9^w(-ZDTNagcQgv$u4|GiKy&<9=LpsmG(??S|%z#RZJY FM*%YHxv>BM literal 0 HcmV?d00001 diff --git a/secrets/nixery-gcs-pem b/secrets/nixery-gcs-pem new file mode 100644 index 0000000000000000000000000000000000000000..798a1e5a66f823a90804a48a7252f798831cefbf GIT binary patch literal 3214 zcmd;5VYnFl=3C)`t!rFWD&%kIKXBOo+(~$=qW@|Cev#8WOC9ewY%3RfD#6g!|J-Ej zYPGlv^RwTqG1+$bzE7aU{3ni&?f;5p@mD^d;%gFH&zyR`aaY;$l_{zro|ZiOE^pTR^5785 zuKO9x$*g~PqYHDZk^+LvUa;OXoNpadm}kV2qrv|~@@ zc3G=cRq;Cn7H{NUyXKm~-NZsOdFjYb--Eq1^1VGBjpu5O_TN8obE4t30*P?TeQudEjy^dw zO^|QL;w-<6DGZmN=a=4?*YsMwAZ3wuP3-cF7nx!&_ey2lQ{k~F<#;~t9kalhZ@i0d zOPZ#IPD;2?tsSdO%7H?5pov=)7+cD>ECe~sj(;@@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FeiB*`n6A;O_Iwks*PL14^D~` zW}lUI?o?p*`wf{Hh4=QlD$mmsc*pd6%It4fO=j4pC#)W$|xQTKV0(7;>q2F!W{9Kb^eAA^EBn}a!EL_P0W!zxBHJLb>Epd9VSdGZRy@S*HLTZ z&IwKTpH^R7W&H4TLj0=44ojsEpQQG%UCLKn(Dvf5SV83-k;h@TJ1)QS|98*&O5XpN z;2CeeTvvU;cuKEnQz+ZF4UQk~3I6%|+nnYBB@<5;i$mq`sX z4Oz`YD^6|FR}~JpSL1p1cJBAWtKTfo6#2_$JqYJ1-!E}p>_VBMDA)I2uZ@rHiepMH zjI#e`C-Yz~`@NVAoM9D4-RyP!ej;5=CZC^gKjNq{PydUCseYZyJwS<}jt7+~GE*VAr8SJk*`Hwp8 z-q*B~%V3$`xBD9&y*_#3a!gLkTK35seLrVQ#k2nDUGUc7Oz4!;>9cx+oQ_VgY6@mD zQ7fta6UzAT{q!lv_0paS9`0G`Zhs>B<3!ftCXWiXnssjeHhIV2?4Bf>*X}giFtA~s ziHFNkV@8?GPseJP=8CMZ-OhjLT$f~i*bQOVrytY|CBBLOI;nO${%H@>`t;v-_Q?Gc nzH|OaU&yL`d-@9QKFAF6iBY>}mGJrUg06=l57kP4FO&fQ_b{jp literal 0 HcmV?d00001 From 283951388c96e871c9c4a835eee6594fc27e08c0 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 3 Sep 2019 16:10:42 +0100 Subject: [PATCH 5/5] feat(k8s): Insert Nixery's secrets via kontemplate Instead of having a manually prepared secret, use Cloud KMS (as per the previous commits) to decrypt the in-repo secrets and template them into the Secret resource in Kubernetes. Not all of the values are actually secret, it has thus become a bit easier to edit the known hosts, SSH config and such now. --- infra/kubernetes/nixery/config.yaml | 4 ---- infra/kubernetes/nixery/id_nixery.pub | 1 + infra/kubernetes/nixery/known_hosts | 1 + infra/kubernetes/nixery/secrets.yaml | 19 +++++++++++++++++++ infra/kubernetes/nixery/ssh_config | 4 ++++ 5 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 infra/kubernetes/nixery/id_nixery.pub create mode 100644 infra/kubernetes/nixery/known_hosts create mode 100644 infra/kubernetes/nixery/secrets.yaml create mode 100644 infra/kubernetes/nixery/ssh_config diff --git a/infra/kubernetes/nixery/config.yaml b/infra/kubernetes/nixery/config.yaml index 1bd95536a..796e21a72 100644 --- a/infra/kubernetes/nixery/config.yaml +++ b/infra/kubernetes/nixery/config.yaml @@ -3,10 +3,6 @@ # The service via which Nixery is exposed has a private DNS entry # pointing to it, which makes it possible to resolve `nixery.local` # in-cluster without things getting nasty. -# -# The 'nixery-keys' secret was configured manually using a created -# service account key. This does not use metadata-based authentication -# due to the requirement for having an actual PEM-key to sign with. --- apiVersion: apps/v1 kind: Deployment diff --git a/infra/kubernetes/nixery/id_nixery.pub b/infra/kubernetes/nixery/id_nixery.pub new file mode 100644 index 000000000..dc3fd617d --- /dev/null +++ b/infra/kubernetes/nixery/id_nixery.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCzBM6ydst77jDHNcTFWKD9Fw4SReqyNEEp2MtQBk2wt94U4yLp8MQIuNeOEn1GaDEX4RGCxqai/2UVF1w9ZNdU+v2fXcKWfkKuGQH2XcNfXor2cVNObd40H78++iZiv3nmM/NaEdkTbTBbi925cRy9u5FgItDgsJlyKNRglCb0fr6KlgpvWjL20dp/eeZ8a/gLniHK8PnEsgERQSvJnsyFpxxVhxtoUiyLWpXDl4npf/rQr0eRDf4Q5sN/nbTwksapPHfze8dKcaoA7A2NqT3bJ6DPGrwVCzGRtGw/SXJwFwmmtAl9O6BklpeReyiknSxc+KOtrjDW6O0r6yvymD5Z nixery diff --git a/infra/kubernetes/nixery/known_hosts b/infra/kubernetes/nixery/known_hosts new file mode 100644 index 000000000..1bae52b89 --- /dev/null +++ b/infra/kubernetes/nixery/known_hosts @@ -0,0 +1 @@ +github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ== diff --git a/infra/kubernetes/nixery/secrets.yaml b/infra/kubernetes/nixery/secrets.yaml new file mode 100644 index 000000000..ec97a29d3 --- /dev/null +++ b/infra/kubernetes/nixery/secrets.yaml @@ -0,0 +1,19 @@ +# The secrets below are encrypted using keys stored in Cloud KMS and +# templated in by kontemplate when deploying. +# +# Not all of the values are actually secret (see the matching) +--- +apiVersion: v1 +data: + gcs-key.json: {{ passLookup "nixery-gcs-json" | b64enc }} + gcs-key.pem: {{ passLookup "nixery-gcs-pem" | b64enc }} + id_nixery: {{ passLookup "nixery-ssh-private" | b64enc }} + id_nixery.pub: {{ insertFile "id_nixery.pub" | b64enc }} + known_hosts: {{ insertFile "known_hosts" | b64enc }} + ssh_config: {{ insertFile "ssh_config" | b64enc }} +kind: Secret +metadata: + creationTimestamp: null + name: nixery-secrets + selfLink: /api/v1/namespaces/kube-public/secrets/nixery-secrets +type: Opaque diff --git a/infra/kubernetes/nixery/ssh_config b/infra/kubernetes/nixery/ssh_config new file mode 100644 index 000000000..78afbb0b0 --- /dev/null +++ b/infra/kubernetes/nixery/ssh_config @@ -0,0 +1,4 @@ +Match host * + User tazjin@google.com + IdentityFile /var/nixery/id_nixery + UserKnownHostsFile /var/nixery/known_hosts