Deploying into your own cloud is easy; deploying into a customer's Kubernetes cluster that you do not own, with their registry, their policies, their ingress, their secrets and their security team watching, is a skill. This lesson covers building container images that pass enterprise scanners and admission policies, writing a Helm chart that adapts to any reasonable cluster through values instead of edits, the install and upgrade workflow customers expect, and the cluster quirks, such as restricted pod security and OpenShift's random user IDs, that break naive deployments.
- Build small, non-root, pinned, multi-architecture images with an SBOM
- Design a Helm chart whose values cover registries, secrets, ingress and scheduling
- Meet restricted pod security and least-privilege RBAC requirements
- Validate, install, upgrade and roll back with Helm safely
- Write installation docs and preflight checks customers can follow without you
Images enterprises will accept
Customer platforms scan every image and often enforce admission policies. Images that run as root, carry hundreds of known vulnerabilities, or float on a latest tag get rejected or flagged. Build images as if a security reviewer will read the Dockerfile, because one will.
FROM python:3.12-slim AS build
WORKDIR /app
COPY pyproject.toml uv.lock ./
RUN pip install --no-cache-dir uv && uv export --frozen --no-dev -o requirements.txt \
&& pip install --no-cache-dir --prefix=/install -r requirements.txt
FROM python:3.12-slim
RUN useradd --uid 10001 --create-home app
COPY --from=build /install /usr/local
COPY --chown=10001:0 src/ /app/src/
WORKDIR /app
USER 10001
EXPOSE 8000
CMD ["python", "-m", "uvicorn", "src.app:app", "--host", "0.0.0.0", "--port", "8000"]- Non-root user with a fixed numeric UID, and files group-owned by 0 so platforms that assign random UIDs (OpenShift) still work.
- Minimal base and multi-stage builds: build tools stay out of the runtime image.
- Pinned versions and release tags (and digests in the chart) so what was tested is what runs.
- Multi-architecture builds (amd64 and arm64) with
docker buildx, because customer fleets increasingly include ARM nodes. - SBOM and signature: publish a software bill of materials and sign images (for example with cosign) so the customer can verify provenance.
A Helm chart that adapts instead of being edited
If a customer has to edit your templates to install your product, every upgrade becomes a merge conflict. Expose everything that legitimately differs between clusters as values with sensible defaults, and keep templates generic.
image:
registry: registry.yourproduct.example # customers override with their mirror
repository: assistant/api
tag: "1.8.2"
pullPolicy: IfNotPresent
imagePullSecrets: [] # e.g. [{name: corp-registry}]
replicaCount: 2
resources:
requests: {cpu: 250m, memory: 512Mi}
limits: {memory: 1Gi}
existingSecret: "" # use the customer's secret instead of creating one
env:
LOG_LEVEL: info
ingress:
enabled: false
className: "" # nginx, openshift-default, alb ...
host: assistant.corp.example
tlsSecretName: ""
nodeSelector: {}
tolerations: []
affinity: {}
podSecurityContext:
runAsNonRoot: true
seccompProfile: {type: RuntimeDefault}
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities: {drop: ["ALL"]}
proxy:
httpsProxy: ""
noProxy: ".svc,.cluster.local"
caBundleConfigMap: "" # customer CA mounted into the podSupport existing secrets (the customer creates and rotates them, often from their vault) rather than requiring secret values in values.yaml. Make registry, ingress class, storage class, proxy settings and CA bundle configurable. Ship a values.schema.json so typos fail at install time instead of producing a silently wrong deployment.
Security posture: pod security and RBAC
Many clusters enforce the Kubernetes restricted Pod Security Standard: non-root, no privilege escalation, all capabilities dropped, a seccomp profile. The values above satisfy it; test your chart in a namespace labelled pod-security.kubernetes.io/enforce: restricted before any customer does.
- Request namespaced RBAC only: a Role and RoleBinding for what the app needs, never cluster-admin.
- If you truly need cluster-scoped resources (CRDs, webhooks), separate them into an optional install step that the platform team runs and reviews.
- Use a read-only root filesystem and mount writable
emptyDirvolumes only where needed (/tmp, caches). - Define readiness and liveness probes, resource requests and limits, and a PodDisruptionBudget so platform maintenance does not take you down.
- Expect network policies: document every connection your pods make so the customer can allow them.
Install, upgrade and roll back
helm lint ./assistant -f customer-values.yaml
# render and review before applying
helm template assistant ./assistant -f customer-values.yaml > rendered.yaml
helm upgrade --install assistant ./assistant -n assistant --create-namespace \
-f customer-values.yaml --atomic --timeout 10m
helm history assistant -n assistant
helm rollback assistant 3 -n assistant # back to revision 3 if the upgrade misbehaveshelm templatelets the customer's platform team review exactly what will be applied; many require it.--atomicrolls back automatically if the release does not become healthy within the timeout.- Keep the customer's values file in their version control; upgrades become a chart version bump plus a diff review.
- Document breaking changes and migration steps in release notes for every chart version.
Docs and preflight checks
The installation guide is part of the product. It should list prerequisites (Kubernetes version range, storage class, ingress controller, GPU nodes if needed, outbound destinations), a minimal values file for a typical install, the commands above, how to verify the install, and how to uninstall cleanly. Add a preflight script or Helm test that checks the environment before installing: can pods pull the image, resolve and reach the database, trust the CA, get through the proxy? Failing early with a clear message saves days of remote debugging.