{"id":26397306,"url":"https://github.com/thalesgroup/k8s-kms-plugin","last_synced_at":"2025-03-17T12:17:21.427Z","repository":{"id":44607047,"uuid":"280718298","full_name":"ThalesGroup/k8s-kms-plugin","owner":"ThalesGroup","description":"gRPC service that leverages a remote or local HSM/TPM to encrypt Kubernetes data at-rest.","archived":false,"fork":false,"pushed_at":"2025-02-28T19:07:44.000Z","size":16944,"stargazers_count":20,"open_issues_count":15,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-28T22:53:35.648Z","etag":null,"topics":["hsm","kubernetes","pkcs11","tpm"],"latest_commit_sha":null,"homepage":"https://github.com/ThalesGroup/k8s-kms-plugin","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ThalesGroup.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-18T18:45:56.000Z","updated_at":"2025-02-27T12:39:30.000Z","dependencies_parsed_at":"2024-04-16T00:06:42.899Z","dependency_job_id":"e8ca546f-9235-4709-82ba-7f73cfb4b3c3","html_url":"https://github.com/ThalesGroup/k8s-kms-plugin","commit_stats":null,"previous_names":["thalesgroup/k8s-kms-plugin","thalescpl-io/k8s-kms-plugin"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThalesGroup%2Fk8s-kms-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThalesGroup%2Fk8s-kms-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThalesGroup%2Fk8s-kms-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThalesGroup%2Fk8s-kms-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThalesGroup","download_url":"https://codeload.github.com/ThalesGroup/k8s-kms-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244031131,"owners_count":20386534,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hsm","kubernetes","pkcs11","tpm"],"created_at":"2025-03-17T12:17:20.798Z","updated_at":"2025-03-17T12:17:21.400Z","avatar_url":"https://github.com/ThalesGroup.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# K8S-KMS-Plugin\n\nThis microservice implements the Kubernetes KMS protocol as a gRPC service that leverages a remote or local HSM via PKCS11.\n\nThis plugin will also run in proxy mode which can connect to a remote plugin service running in a secure network device (Key Managers)\n\n## Requirements\n\nThis service is designed for kubernetes clusters that are using version 1.10.0 or higher and implements the KMS API:\n\nhttps://kubernetes.io/docs/tasks/administer-cluster/kms-provider/\n\nSo for development purposes, you'll want a cluster that can be configured to use a KMS gRPC endpoint on your APIServer nodes.\n\nTo serve the `k8s-kms-plugin` for encryption operations from Kubernetes, you will need at least one AES key in a PKCS11 provider.\n\n## Build `k8s-kms-plugin` locally with `goreleaser`\n\nThis allows you to test your `goreleaser` Github Action Recipe locally.\n\n### shell `bash`\n\nFollow these instruction to locally build the using the shell bash. I use\n`make get-ldflags` to create `LDFLAGS`.\n\n```bash\nexport LDFLAGS=$(make get-ldflags)\nexport WORKSPACE=/pwd\nexport GITHUB_REPOSITORY_OWNER=localfakegithubowner\n```\n\n```bash\npodman run -it --rm -v $PWD:/pwd   --workdir /pwd -e LDFLAGS=$LDFLAGS   -e WORKSPACE=$WORKSPACE -e GITHUB_REPOSITORY_OWNER=$GITHUB_REPOSITORY_OWNER  --platform \"linux/amd64\"  ghcr.io/thalesgroup/goreleaser-glibc-image:golang-1.23.6-bookworm release --clean --snapshot --skip sign,publish,validate,ko,sbom\n```\n\n### shell `fish`\n\n```bash\nset LDFLAGS $(make get-ldflags)\nset WORKSPACE /pwd\nset GITHUB_REPOSITORY_OWNER localfakegithubowner\n```\n\n```bash\npodman run -it --rm -v $PWD:/pwd   --workdir /pwd -e LDFLAGS=$LDFLAGS   -e WORKSPACE=$WORKSPACE -e GITHUB_REPOSITORY_OWNER=$GITHUB_REPOSITORY_OWNER  --platform \"linux/amd64\"  ghcr.io/thalesgroup/goreleaser-glibc-image:golang-1.23.6-bookworm release --clean --snapshot --skip sign,publish,validate,ko,sbom\n```\n\n## KMS provider for SoftHsm V2\n\nIn this mode, we recommend to run the `k8s-kms-plugin` with the GCM algorithm.  \nIt provides a better design for authenticated encryption operations :\n\n```sh\n# debian\nexport MODULE=\"/usr/lib/softhsm/libsofthsm2.so\"\n# redhat\nexport MODULE=\"/usr/lib64/pkcs11/libsofthsm2.so\"\n# serve\nk8s-kms-plugin serve \\\n  --provider p11 --p11-lib $MODULE --p11-key-label mykey --p11-label mylabel --p11-pin mypin --enable-server\n```\n\n## KMS provider for TPM2 PKCS11\n\nYou must know that AES GCM is not supported by the TPM v2 specifications.\nIn this mode, we recommend to run the `k8s-kms-plugin` with the CBC-then-HMAC algorithm. \nYou must provide an HMAC key alongside the AES key for encryption :\n\n```sh\n# debian\nexport MODULE=\"/usr/lib/x86_64-linux-gnu/libtpm2_pkcs11.so.1\"\n# redhat\nexport MODULE=\"/usr/lib64/pkcs11/libtpm2_pkcs11.so\"\n# serve\nk8s-kms-plugin serve \\\n  --provider p11 --p11-lib $MODULE --p11-key-label cbc0 --p11-hmac-label hmac0 --p11-label mylabel --p11-pin mypin --algorithm aes-cbc --enable-server\n```\n\n## Quick Start\n\nRead the [QUICKSTART.md](QUICKSTART.md).\n\n## Deployment scenarios\n\nThis plugin is designed to be deployed in 2 configurations\n\n- Client/Server - `k8s-kms-plugin` in `client` mode will `enroll` to an external `k8s-kms-plugin` running in `serve` mode\n- StandAlone(TODO) - Plugin and PKCS11 library deployed as StaticPod/HostContainer on APIServer nodes, this will require\ncoordination with k8s provisioning tools.\n\n## Development Environment\n\n`k8s` houses some sample client and server deployments for e2e testing until such time as this plugin is 100% network functional,\n and we can move it to a CICD pattern, as we'll have many actors to coordinate. \n\nAll apis are defined in the `/apis` dir, and as we iterate on the spec docs, one must then run `make gen` and refactor \nuntil the 2 stacks come up\n\nBoth EST and KMS-Plugin binaries are in the `/cmd` dir\n \nThe `Makefile` contains commands for easy execution:\n- `make gen` - generates all apis into gRPC or OpenAPI Servers and Clients\n- `make dev` - loads project into your kubernetes cluster (minikube or GKE will work just fine), and continuously builds and deploys as you develop.\n- `make build` - builds the standalone `k8s-kms-plugin` binary\n\nIf you need to build using `crypto11` and `gose` development branches :\n\n1. Push your dev modifications in a dedicated branch in the `crypto11` repo (ex: my-dev-branch)\n2. Go to the `gose` repo and update the *go.mod* file with `crytpo11` dev branch and push the update :\n\n```sh\n# In gose repo\n# in a dev branch\ngo switch -c my-dev-branch\nGOPROXY=direct go get -u github.com/ThalesGroup/crypto11@my-dev-branch\ngo mod tidy\ngit add go.mod\ngit commit -S -s -m \"dev: update gose with crytpo11 dev changes\"\ngit push\n```\n\n3. Go to the `k8s-kms-plugin` repo and update the *go.mod* file with `crytpo11` and `gose` dev branches, then build :\n\n```sh\ngo switch -c my-dev-branch\nGOPROXY=direct go get -u github.com/ThalesGroup/crypto11@my-dev-branch\nGOPROXY=direct go get -u github.com/ThalesGroup/gose@my-dev-branch\ngo mod tidy\nmake build\n```\n\n## Debug Environment\n\nFor a remote debug, build the plugin with debug mode :\n\n```sh\ngo get github.com/go-delve/delve/cmd/dlv\nmake build-debug\n```\n\nIt will generate a binary `k8s-kms-plugin` that can be used with Delve for debug purpose.  \nDo not use this binary in a production environment.\n\n## Vulnerability check\n\n```sh\n$ govulncheck ./...\nScanning your code and 288 packages across 34 dependent modules for known vulnerabilities...\n\nNo vulnerabilities found.\n```\n\n## Signing artifacts\n\nDuring the release workflow, certificates and signatures of artifacts are generated.\nThey are signed by a tool named cosign using a keyless mode.\nIt required an authentication by clicking in links present in logs.\n\n![Screenshot of one example of logs containing three authentication links generating tokens](docs/images/AuthLinksCosign.png)\n\nOnce you click on one, you can submit a verification code that will redirect you to three types of authentication. Then click on Github authentication.\n\n ![Screenshot of the interface for submitting a code](docs/images/CodeSubmit.png)\n\nDo these actions for every authentication links and the signatures and the certificates will be generated with the artifacts in the release.\n\n## Verifying the authenticity of an artifact\n\nYou need to downloads 3 files : [ _**[file.txt]**_, _**[file].pem**_, _**[file].sig**_]\n\nIf you don't have, install cosign by typing the commands below :\n\n  ```bash\n  curl -O -L \"https://github.com/sigstore/cosign/releases/latest/download/cosign-linux-amd64\"\n  sudo mv cosign-linux-amd64 /usr/local/bin/cosign\n  sudo chmod +x /usr/local/bin/cosign\n  ```\n\nFor a verification with cosign installed and pay attention to modify the name of the files :\n\n  ```bash\n  COSIGN_EXPERIMENTAL=1 cosign verify-blob --cert [file]-keyless.pem --signature [file]-keyless.sig --certificate-oidc-issuer \"https://github.com/login/oauth\" --certificate-identity [ Mail adress of the owner of the repo ] [file]\n  ```\n\nOr using Podman without installing cosign :\n\n```bash\npodman run --rm -it gcr.io/projectsigstore/cosign:v1.13.0 COSIGN_EXPERIMENTAL=1 cosign verify-blob --cert [file]-keyless.pem --signature [file]-keyless.sig --certificate-oidc-issuer \"https://github.com/login/oauth\" --certificate-identity [ Mail adress of the owner of the repo ] [file]\n```\n\n## Verifying the SLSA attestation of a container\n\nThe image's attestation of provenance has been issued by a specific oidc-issuer that is 'https://token.actions.githubusercontent.com' in this repository.\nIn the next command example, it is required to replace digest by the digest of the image that needs to be verified and the owner of the repo.\n\n```bash\ncosign verify-attestation --type slsaprovenance \\\n      --certificate-identity-regexp=\"https://github.com/slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@refs/tags/*\" \\\n      --certificate-oidc-issuer=\"https://token.actions.githubusercontent.com\" \\\n      ghcr.io/OWNER/k8s-kms-plugin@digest | jq .payload -r | base64 --decode | jq\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthalesgroup%2Fk8s-kms-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthalesgroup%2Fk8s-kms-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthalesgroup%2Fk8s-kms-plugin/lists"}