Skip to main content

Utility for decoding Kubernetes secret resources

Project description

Easily Read Kubernetes Secrets

Read base64 encoded Kubernetes secrets without getting in your way.

Kubernetes secrets resources base64 encode the secret values. It is often useful to view the decoded values for those secrets in place. This tool offers a useful means to do that.

Features

  • allows you to read one or more Secrets
  • works with individual secrets, lists of secrets, and multiple yaml docs
  • simple auditable Python source code

Install

Install with pip

pip install ksd

Install with pipx

pipx install ksd

Quick Example

$ kubectl get secret -n mynamespace -o yaml mysecret | ksd
apiVersion: v1
data:
  password: my-decoded-password-secret
  username: my-decoded-username-secret
kind: Secret
metadata:
  creationTimestamp: '2024-01-01T00:00:0Z'
  labels:
    name: mynamespace
  name: mysecret
  namespace: mynamespace
  resourceVersion: '1234'
  uid: c4f4c4db-bdba-47d0-9a17-1e307e1448c7
type: Opaque

Detailed Usage

Get help

ksd --help

Get single secret as YAML and decode as YAML

kubectl get secret -o yaml mysecret | ksd 

Get single secret as YAML and decode as JSON

kubectl get secret -o yaml mysecret | ksd -f json

Get multiple secrets as YAML and decode as YAML

kubectl get secret -o yaml  | ksd

Get multiple secrets as YAML and decode as JSON

kubectl get secret -o yaml  | ksd -f json

Get secrets as JSON and decode as YAML

kubectl  get secret -o json | ksd

Get secrets as JSON and decode as JSON

kubectl  get secret -o json | ksd -f json

Use k8s flags as normal

kubectl  get secret -n my_namespace -l label_key=label_value -o json | ksd

I don't know why you would do this, but the output is idempotent

kubectl get secret -o yaml  | ksd | ksd

Read Secrets from a file

cat secrets.yaml | ksd

Suppoert multi-document yaml input (separated with the yaml '---')

kubectl get secret -o yaml mysecret > secrets.yaml
echo "---" >> secrets.yaml
kubectl get secret -o yaml ohter_secret >> secrets.yaml
cat secrets.yaml | ksd

Inspired by

There are several projects with a similar name and purpose. However, they are written in Go and distribute compiled binaries. I prefer to use a version of this tool written in Python, for which the source code is auditable.

Tests

pip install -e .[tests]
pytest -vvv tests/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ksd-0.1.3.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ksd-0.1.3-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file ksd-0.1.3.tar.gz.

File metadata

  • Download URL: ksd-0.1.3.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.10

File hashes

Hashes for ksd-0.1.3.tar.gz
Algorithm Hash digest
SHA256 25b9dc833fc1a48a9d3f56505527ec92e4543f729f7c0bee939a9397e46ee49b
MD5 133f2303de781f4144df3e0cca2e45d5
BLAKE2b-256 39dbaad403d5ef00602e8ba88ae8d8142f71a0ddb6f96f3f0acdbb96bb091cd0

See more details on using hashes here.

File details

Details for the file ksd-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: ksd-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.10

File hashes

Hashes for ksd-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 05c7156ed18a8bebec559dfc2d06f6087b114fcd6e0455ab750fdfbb6b6923f0
MD5 449818ee520929c226813e1eb0df66af
BLAKE2b-256 f22bd84a627f70aa4dee1ee35600b63db3941018a593caf846bb23ab341f7a29

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page