Implementing Chart Security
1. Signing Chart Packages
Example: Sign + verify
helm package ./chart --sign --key 'release-bot' --keyring secring.gpg
# Produces chart-1.4.2.tgz + chart-1.4.2.tgz.prov
helm verify chart-1.4.2.tgz --keyring pubring.gpg
2. Verifying Chart Signatures
| Command | Effect |
|---|---|
helm verify chart.tgz | Validates provenance against keyring |
helm install ... --verify | Verify before installing |
helm pull ... --verify | Verify on download |
3. Using GPG Keys
| Step | Command |
|---|---|
| Generate key | gpg --full-generate-key |
| Export public | gpg --export -a 'name' > pub.asc |
| Export secret (classic) | gpg --export-secret-keys >~/.gnupg/secring.gpg |
| Distribute pub | Publish via keyserver or static URL |
Note: Helm requires classic (binary) keyring format. GPG 2.1+ uses keybox by default; export to
secring.gpg for compatibility.4. Creating Provenance File
| File | Contents |
|---|---|
chart-1.4.2.tgz.prov | YAML metadata + SHA256 + PGP-clearsigned signature |
5. Validating Chart Integrity
Example: Verify before install
helm install api oci://ghcr.io/acme/charts/api \
--version 1.4.2 --verify --keyring pubring.gpg
6. Implementing RBAC in Charts
Example: Least-privilege Role
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "myapp.fullname" . }}
rules:
- apiGroups: [""]
resources: ["configmaps"]
resourceNames: ["{{ include "myapp.fullname" . }}-config"]
verbs: ["get", "watch"]
7. Setting Security Context
Example: Restricted pod
spec:
securityContext:
runAsNonRoot: true
runAsUser: 10001
fsGroup: 10001
seccompProfile: { type: RuntimeDefault }
containers:
- name: app
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities: { drop: ["ALL"] }
8. Using Network Policies
Example: Default-deny + allow ingress
{{- if .Values.networkPolicy.enabled }}
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ include "myapp.fullname" . }}
spec:
podSelector:
matchLabels: {{- include "myapp.selectorLabels" . | nindent 6 }}
policyTypes: [Ingress]
ingress:
- from:
- namespaceSelector:
matchLabels: { name: web }
ports:
- port: {{ .Values.service.port }}
{{- end }}
9. Scanning Charts for Vulnerabilities
| Tool | Scope |
|---|---|
trivy config ./chart | Misconfig + IaC scan |
checkov -d ./chart | Policy-as-code checks |
kube-linter lint ./chart | Kubernetes best practices |
polaris audit --helm-chart ./chart | Production-readiness scoring |
snyk iac test ./chart | Commercial vulnerability scanning |
10. Following Security Best Practices
11. Validating Image Sources
| Control | Tool |
|---|---|
| Allowed registries | Kyverno / OPA Gatekeeper policies |
| Signed images only | Cosign + admission policy (sigstore-policy-controller) |
| Digest pinning | Use image.digest override; verify in CI |