To add k8-tools as subtree to k8s directory:
git subtree add --prefix=k8s/k8s-tools git@github.com:cubesystems/k8s-tools.git master
cd k8s
./k8s-tools/symlink-commandsand commit symlinked commands
To updated to latest script version from project root:
git subtree pull --prefix=k8s/k8s-tools/ git@github.com:cubesystems/k8s-tools.git master --squashThe deployments.yaml file defines your deployment environments and their configurations.
Example configuration:
release: my-application
repo: https://cubesystems.github.io/charts
chart: laravel
version: 1.3.9
defaults:
keyFile: main.key # Default encryption key file for all environments
environments:
test:
namespace: my-app-test
kubeconfig: test.kubeconfig.yml # Optional: local kubeconfig file
values:
- groups/all.yaml
- environments/test.yaml
production:
namespace: my-app-production
kubeconfig: production.kubeconfig.yml
keyFile: production.key # Override default key for production
values:
- groups/all.yaml
- environments/production.yamlConfiguration options:
release: Helm release namerepo: Helm chart repository URL (optional if using local chart)chart: Chart name or path to local chart directoryversion: Chart version (optional)
defaults section (all optional):
keyFile: Default encryption key file (relative tok8s/keys/directory)namespace: Default namespace for all environmentskubeconfig: Default kubeconfig filecreateNamespace: Whether to create namespace if it doesn't exist (default: true)
Per-environment options:
namespace: Kubernetes namespace (required unless set in defaults)kubeconfig: Path to kubeconfig file relative to k8s directory (optional)keyFile: Override default encryption key file for this environment (optional)values: Array of values files to apply (order matters - later files override earlier ones)createNamespace: Override default namespace creation behavior (optional)repo: Override chart repository URL (optional)chart: Override chart name or path (optional)version: Override chart version (optional)
Important notes:
- The
defaultssection is entirely optional - you can configure everything per-environment - Values files are applied in order - later files override values from earlier files
kubeconfigis optional - if not specified, uses your default kubectl contextkeyFileis optional - only needed if you're using encrypted secrets- Environment-specific settings override
defaultssection - For production, it's recommended to use a separate
keyFilefor enhanced security
CI/CD Environment:
- Set
DEPLOY_ENCRYPTION_KEYas a CI/CD variable with your encryption key value
Local Development:
Option 1 (Recommended for temporary use):
# Store key in k8s/keys/main.key (already in .gitignore)
echo "your-encryption-key-here" > k8s/keys/main.keyOption 2 (Shell environment - more secure):
# Prefix with space to prevent shell history storage
DEPLOY_ENCRYPTION_KEY=your-encryption-key-here- Add plaintext value to your values file (e.g.,
k8s/values/environments/test.yaml):
secrets:
app-config:
data:
DB_PASSWORD: HELM_SECRET:JRNdJceLHO5TMtXMKOHqfGSJKMwfc91f/kpPyXo5/ZQ=
FOO: BAR # New plaintext value to encrypt- Generate encrypted value:
./k8s/secrets encrypt test k8s/values/environments/test.yamlOutput example:
---
# Source: helm-encyption/templates/encrypt.yaml
secrets:
app-config:
data:
FOO: HELM_SECRET:LO0eAR2SqudvIA10vGKLoXfJquii5GSS7yCGcEt0YCA=- Replace plaintext with encrypted value in your values file:
secrets:
app-config:
data:
DB_PASSWORD: HELM_SECRET:JRNdJceLHO5TMtXMKOHqfGSJKMwfc91f/kpPyXo5/ZQ=
FOO: HELM_SECRET:LO0eAR2SqudvIA10vGKLoXfJquii5GSS7yCGcEt0YCA=- Commit, push, and deploy
To verify encrypted values locally:
./k8s/secrets decrypt test k8s/values/environments/test.yaml✅ DO:
- Use different encryption keys for each environment (dev, staging, production)
- Rotate encryption keys periodically
- Store keys securely in CI/CD secret management
- Use the space-prefix method when setting keys in shell to avoid history
- Remove local key files (
k8s/keys/*.key) when not actively developing - Ensure
k8s/keys/is in.gitignore
❌ DON'T:
- Commit encryption keys to version control
- Share encryption keys via insecure channels
- Use the same key across multiple environments
- Keep production keys on local development machines