A GitLab-to-Kubernetes deployment should promote a verified image into a protected environment using a narrowly scoped identity. The pipeline must confirm rollout health and preserve enough evidence to identify exactly what was deployed, by whom, and from which commit.
Deployment prerequisites
- A tested image exists in an approved registry under an immutable digest.
- Kubernetes manifests or a packaging layer are version controlled.
- The deployment identity is limited to required namespaces and resources.
- Production environments and branches are protected.
- Readiness, liveness, startup, and resource settings are defined.
- Rollback and database compatibility have been planned.
Identity and cluster access
Prefer short-lived workload identity or an agent-based connection over long-lived administrative kubeconfig data. If a credential file is unavoidable, scope it tightly, protect the variable, restrict runner access, and rotate it regularly. Never grant cluster-admin to routine deployment jobs.
Safe deployment flow
- Resolve the approved image digest.
- Render and validate the intended manifests.
- Run policy and security checks.
- Record a diff against the current cluster state.
- Require approval for sensitive environments.
- Apply the change with the scoped identity.
- Wait for rollout status and health checks.
- Run a bounded smoke test.
- Record the release and notify owners.
GitLab environments
Environments provide deployment history and status. Use environment protection to control who can deploy, define clear staging and production boundaries, and avoid using a single credential across unrelated environments.
Rollout and rollback
| Signal | Response |
|---|---|
| Rollout completes and smoke tests pass | Mark release successful |
| Pods fail readiness | Inspect events, configuration, and dependencies |
| Error rate rises | Pause or roll back according to policy |
| Schema incompatibility | Use the application’s tested database recovery plan |
| Pipeline times out | Check actual cluster state before retrying |
Common mistakes
- Deploying a moving image tag without recording the digest.
- Giving the CI identity broad cluster permissions.
- Running production deployment on shared untrusted runners.
- Treating a successful apply command as proof of application health.
- Retrying after timeout without checking whether the first action succeeded.
- Changing application and irreversible schema behavior without coordinated rollback.
Join the discussion
0 CommentsAsk questions, add context, or share what worked.
More from Melochip Editorial
Learn what Playwright testing is, why modern QA teams use it, how testers can get started, and the major types...
7 min read · Sep 19, 2026
Learn how Kubernetes Deployments and ReplicaSets work with practical YAML, scaling, self-healing, rolling upda...
7 min read · Sep 17, 2026
Learn Kubernetes security best practices with RBAC, Secrets, ServiceAccounts, Pod securityContext, NetworkPoli...
6 min read · Sep 17, 2026Related articles
Learn how Kubernetes Deployments and ReplicaSets work with practical YAML, scaling, self-healing, rolling upda...
7 min read · Sep 17, 2026
Learn Kubernetes ConfigMaps and Secrets with YAML, environment variables, file mounts, update behavior, immuta...
8 min read · Sep 17, 2026
Learn Kubernetes security best practices with RBAC, Secrets, ServiceAccounts, Pod securityContext, NetworkPoli...
6 min read · Sep 17, 2026
Learn Kubernetes monitoring and logs with kubectl logs, events, metrics-server, top commands, Prometheus, Graf...
5 min read · Sep 17, 2026Stay in the loop. Get new Melochip articles
Receive Melochip article updates when new articles are available. Explicit opt-in only.
No comments yet. Start the discussion.