Files
k8s-ds-secret-injection/cmd/secret-manager

Secret Manager

A simple CLI tool to manage Kubernetes Secrets from your local machine. It handles Base64 encoding/decoding automatically, allowing you to work with plain text values.

Features

  • List: View all keys and values in a secret (decoded).
  • Add/Update: Add a new key-value pair or update an existing one using plain text.
  • Delete: Remove a specific key from a secret.

Prerequisites

  • Local kubeconfig file (usually at ~/.kube/config).
  • cluster-admin or sufficient RBAC permissions to manage secrets in the target namespace.

Build

From the root of the repository:

make build
# The binary will be located at bin/secret-manager

Usage

./bin/secret-manager --secret <name> [options]

Options

  • --namespace: Namespace of the secret (default: default).
  • --secret: (Required) Name of the Kubernetes secret.
  • --op: Operation to perform: list, add, or delete (default: list).
  • --key: The key to add or delete.
  • --value: The plain text value to add (required for add operation).
  • --kubeconfig: Path to a custom kubeconfig file.

Examples

1. List keys and values:

./bin/secret-manager --namespace gps-system --secret test-daemonset-7v1v1 --op list

2. Add or update a key:

./bin/secret-manager --namespace gps-system --secret test-daemonset-7v1v1 --op add --key my-key --value "my-value"

3. Delete a key:

./bin/secret-manager --namespace gps-system --secret test-daemonset-7v1v1 --op delete --key my-key