Webhook icon
Schedule icon
Switch icon
Commands icon
Docker icon
Script icon
If icon
Exit icon
SlackIncomingWebhook icon
Pause icon
Parallel icon
Get icon
Fail icon
Set icon
GetKeys icon
Loop icon
Delete icon

Self-Service Kubernetes Namespace Provisioning with Policy Tiers, Approval, Verification and TTL Lifecycle

Self-service Kubernetes namespaces with Kestra. Policy tiers, approval, quota, RBAC and network policy applied and verified, plus approved teardown at expiry.

Categories
Infrastructure

Platform teams still spend hours on namespace tickets, and namespaces created by hand drift: one has no quota, another no network policy, nobody knows who owns the rest. This flow is the golden path: developers ask for a namespace, policy decides what needs a person, and every namespace gets the same guardrails, an owner and an expiry.

How it works

  1. portal_request (Webhook, from Backstage, Port or Jira) or the Execute form sends team, app, environment, tier and owner group. validate checks names, tiers and lifetimes, refuses names Kestra didn't create, and makes a repeated request a no-op.
  2. approve (Pause) asks the platform team when policy requires it (prod, or a tier outside auto_approve). It can grant a smaller tier or another lifetime.
  3. render writes the namespace (owner, tier, expiry and Pod Security labels), a ResourceQuota, a LimitRange, an edit RoleBinding for the owner group and a default-deny ingress NetworkPolicy. apply_namespace and apply_policies apply them with kubectl.
  4. read_back (Parallel of kubectl.Get) reads the objects back. If anything is missing, the namespace is deleted and the run fails, so no namespace exists without its guardrails.
  5. daily_lifecycle (Schedule) reminds owners before expiry and asks, per expired namespace, whether to delete or extend it.

What you get

  • Identical guardrails on every namespace, verified in the cluster, with owner, requester, approver and expiry recorded.
  • Approvals only where policy needs them, and namespaces that don't outlive their purpose.

Who it's for

  • Platform and DevOps teams running shared Kubernetes clusters.

Why orchestrate this with Kestra

Policy, approval, apply, verification and lifecycle are one audited flow with retries, instead of tickets and scripts.

Prerequisites

  • A ServiceAccount that can get, list, create, patch and delete namespaces, resourcequotas, limitranges, networkpolicies and rolebindings, and bind the edit ClusterRole. Nothing else is needed.
  • Workers that can run Docker containers (bitnami/kubectl). Namespaces are cluster-scoped, which the Kubernetes plugin's kubectl tasks can't create, so kubectl applies and deletes them.

Secrets

  • K8S_MASTER_URL, K8S_TOKEN, K8S_CA_CERT (base64 PEM): API server, ServiceAccount token, cluster CA.
  • NAMESPACE_REQUEST_WEBHOOK_KEY: key in the request webhook URL.
  • SLACK_WEBHOOK_URL: approvals, ready notices, lifecycle and failures.

Quick start

  1. Create the ServiceAccount and secrets, and set tiers, auto_approve and max_ttl_days.
  2. Execute with dry_run: true, then for real.
  3. Point your portal at /api/v1/main/executions/webhook/company.platform/kubernetes-namespace-self-service-provisioning/<NAMESPACE_REQUEST_WEBHOOK_KEY>.

Outputs: {{ outputs.namespace }} and {{ outputs.expires }}.

How to extend

  • Add an egress policy or a default service account to render.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.