push-to-k8s
A Kubernetes controller that automatically synchronizes labeled secrets from a source namespace to all other namespaces in the cluster
About this chart
Push-to-K8s Helm Chart
A Kubernetes controller that automatically synchronizes labeled secrets from a source namespace to all other namespaces in the cluster.
Overview
Push-to-K8s is a lightweight Go-based controller that watches for secrets labeled with push-to-k8s=source in a designated namespace and automatically syncs them to all other namespaces (excluding system namespaces and those with exclusion labels). This is ideal for distributing common secrets like registry credentials, API keys, and TLS certificates across your entire cluster.
Features
- Automatic Secret Synchronization: Syncs labeled secrets to all namespaces
- Real-time Namespace Watching: Automatically syncs secrets to newly created namespaces
- Smart Update Detection: Only updates secrets when data changes
- Namespace Exclusion: Label namespaces to exclude them from receiving secrets
- Prometheus Metrics: Built-in metrics for monitoring controller health
- Health Endpoints:
/healthzand/readyzendpoints for Kubernetes probes - Graceful Shutdown: Proper signal handling and cleanup
Prerequisites
- Kubernetes 1.19+
- Helm 3.0+
Installation
Add the Helm Repository (if available)
helm repo add push-to-k8s https://supporttools.github.io/push-to-k8s
helm repo update
Install from Local Chart
# From the repository root
helm install push-to-k8s ./charts/push-to-k8s --namespace push-to-k8s --create-namespace
Install with Custom Values
helm install push-to-k8s ./charts/push-to-k8s \
--namespace push-to-k8s \
--create-namespace \
--set settings.debug=true \
--set settings.SyncInterval=10
Configuration
Key Parameters
| Parameter | Description | Default |
|---|---|---|
settings.debug | Enable debug logging | false |
settings.metrics.enabled | Enable Prometheus metrics | true |
settings.metrics.port | Metrics server port | 9090 |
settings.ExcludeNamespaceLabel | Label to exclude namespaces | "" |
settings.SyncInterval | Sync interval in minutes | 15 |
replicaCount | Number of controller replicas | 1 |
image.repository | Container image repository | cube8021/push-to-k8s |
image.tag | Container image tag | latest |
image.pullPolicy | Image pull policy | Always |
resources.requests.cpu | CPU request | 100m |
resources.requests.memory | Memory request | 128Mi |
resources.limits.cpu | CPU limit | 200m |
resources.limits.memory | Memory limit | 256Mi |
Example values.yaml
settings:
debug: false
metrics:
enabled: true
port: 9090
ExcludeNamespaceLabel: "push-to-k8s-exclude"
SyncInterval: 15
image:
repository: cube8021/push-to-k8s
tag: "v1.0.0"
pullPolicy: IfNotPresent
resources:
limits:
cpu: 200m
memory: 256Mi
requests:
cpu: 100m
memory: 128Mi
nodeSelector:
kubernetes.io/os: linux
Usage
1. Label Secrets for Synchronization
Label any secret in the controller's namespace with push-to-k8s=source:
kubectl create secret generic my-registry-credentials \
--from-literal=username=myuser \
--from-literal=password=mypass \
--namespace push-to-k8s
kubectl label secret my-registry-credentials push-to-k8s=source -n push-to-k8s
2. Verify Secret Synchronization
# Check the source secret
kubectl get secret my-registry-credentials -n push-to-k8s --show-labels
# Verify it was synced to other namespaces
kubectl get secret my-registry-credentials -n default
kubectl get secret my-registry-credentials -n production
3. Exclude Namespaces (Optional)
Set the ExcludeNamespaceLabel value and label namespaces to exclude:
helm upgrade push-to-k8s ./charts/push-to-k8s \
--set settings.ExcludeNamespaceLabel=push-to-k8s-exclude \
--reuse-values
kubectl label namespace kube-system push-to-k8s-exclude=true
kubectl label namespace kube-public push-to-k8s-exclude=true
Monitoring
Accessing Metrics
Port-forward to the controller and access Prometheus metrics:
kubectl port-forward -n push-to-k8s deployment/push-to-k8s 9090:9090
# View all metrics
curl http://localhost:9090/metrics
# View controller-specific metrics
curl http://localhost:9090/metrics | grep k8s_
Available Metrics
k8s_namespace_total- Total number of namespaces in the clusterk8s_namespace_synced_total- Number of namespaces receiving synced secretsk8s_namespace_not_synced_total- Number of excluded namespacesk8s_source_secrets_total- Number of source secrets being syncedk8s_managed_secrets_total- Total number of managed secrets across all namespacesk8s_connection_success_total- Kubernetes connection status
Health Checks
# Liveness probe
curl http://localhost:9090/healthz
# Readiness probe
curl http://localhost:9090/readyz
Troubleshooting
Secrets Not Syncing
-
Verify the controller is running:
kubectl get pods -n push-to-k8s kubectl logs -n push-to-k8s deployment/push-to-k8s -
Check that secrets have the correct label:
kubectl get secrets -n push-to-k8s --show-labels | grep push-to-k8s -
Verify RBAC permissions:
kubectl auth can-i create secrets --as=system:serviceaccount:push-to-k8s:push-to-k8s -n default
Controller Not Starting
-
Check deployment status:
kubectl describe deployment -n push-to-k8s push-to-k8s -
Verify service account exists:
kubectl get serviceaccount -n push-to-k8s -
Check RBAC resources:
kubectl get clusterrole,clusterrolebinding | grep push-to-k8s
Upgrading
# Update chart values
helm upgrade push-to-k8s ./charts/push-to-k8s \
--namespace push-to-k8s \
--reuse-values \
--set image.tag=v1.1.0
Uninstalling
helm uninstall push-to-k8s --namespace push-to-k8s
Note: This will not automatically remove synced secrets from other namespaces. You can manually clean them up if needed.
Contributing
See CONTRIBUTING.md for details on contributing to this project.
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Support
- GitHub Issues: https://github.com/supporttools/push-to-k8s/issues
- Documentation: https://github.com/supporttools/push-to-k8s
- Maintainer: mattmattox ([email protected])
Deploy push-to-k8s with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has push-to-k8s on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartpush-to-k8s is pinned at v1.2.4 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply