Kubernetes

Preview environments in your own cluster, one namespace per pull request.

Newer than the Docker support: the agent logic and the manifests are tested, but treat this as early. Preview environments only; service health reporting is not available on Kubernetes yet.

Install the agent as a Deployment with its own ServiceAccount. For every pull request it creates a namespace named sc-pr-<number>, labelled stratacore.dev/managed=true, and binds a namespaced role only into that namespace. Before it changes or deletes anything it checks the label, so it will not touch kube-system or your own namespaces. On Kubernetes 1.30 or newer, the included admission policy enforces the same rule in the cluster itself.

Install

  1. Download deploy/kubernetes/stratacore-agent.yaml from the StrataCore repository and set the API URL.
  2. Choose how a preview is deployed in the ConfigMap: STRATACORE_K8S_MANIFESTS (a directory of manifests; placeholders PR_NUMBER, NAMESPACE, SHA, BRANCH, REPO and HOST in dollar-brace form) or STRATACORE_K8S_HELM_CHART.
  3. Create the token secret and apply the manifest.
kubectl -n stratacore-system create secret generic stratacore-agent --from-literal=token=sc_xxx
kubectl apply -f stratacore-agent.yaml

Helm

With STRATACORE_K8S_HELM_CHART the agent runs helm upgrade --install into the preview namespace and sets image.tag to the commit and ingress.host to the preview host. Change the keys with STRATACORE_K8S_HELM_TAG_KEY and STRATACORE_K8S_HELM_HOST_KEY. Your CI must push an image tagged with the commit SHA.

Sleep, wake and removal

Sleep scales deployments and statefulsets to zero and remembers the replica count; wake restores it. Closing the pull request deletes the namespace. If you use a HorizontalPodAutoscaler, it may scale a sleeping workload back up.