Import a Kubernetes Cluster
In this guide, you will connect a Kubernetes cluster to Turbot Guardrails. Kubernetes clusters are imported by deploying a Guardrails agent into the cluster. The agent runs as a StatefulSet alongside your other workloads, uses osquery to discover and monitor resources, and reports data back to Guardrails. It always runs in a single pod.
Prerequisites
Turbot/OwnerorTurbot/Adminpermissions in the Guardrails workspace.- Helm installed locally.
- kubectl installed and configured for the target cluster.
Step 1: Install Required Mods
The following mods must be installed in your Guardrails workspace:
If using the ServiceNow integration to sync Kubernetes data into ServiceNow, also install:
For ServiceNow setup, see Connect a ServiceNow Instance.
Step 2: Configure Workspace Policies
After installing the osquery mod, verify the following workspace policy:
- Turbot > Workspace > osquery: Set to
Enabled(this is the default). This enables the osquery APIs that the agent uses to communicate with Guardrails.
The Turbot > Workspace > osquery > Enroll Secret Expiration policy controls how frequently the enrollment secret rotates. The default is hourly. If your agent deployment takes longer than expected, increase this interval to avoid the secret expiring mid-deployment.
Step 3: Set Kubernetes Context
Before running the install script, set your kubeconfig context to the correct cluster. The script uses your current kubectl context to deploy the agent.
For cloud-managed clusters:
- AWS EKS: Create a kubeconfig for Amazon EKS
- Azure AKS: Connect to the cluster
- GCP GKE: Configure cluster access for kubectl
Step 4: Configure Persistent Storage
By default, the Helm chart uses the cluster's default StorageClass to dynamically provision a PersistentVolumeClaim (PVC) for the agent StatefulSet. This persists the osquery database across restarts.
Many cloud-managed clusters do not include an in-tree storage provisioner by default. You may need to install a CSI driver:
- AWS: EBS CSI driver
- Azure: CSI driver
- GCP: GCE PD CSI driver
We recommend leaving persistence enabled to avoid disruptions to the osquery database. To disable it (not recommended for production), add the following to your guardrails-values.yaml before running helm install:
persistence:
enabled: false
For additional persistence options, see the Helm chart values.
Step 5: Open the Onboard Kubernetes Cluster Wizard
From the Dashboard, select the CONNECT button in the top right (or from Workspace > Accounts, select Import). Select Kubernetes from the provider grid.

The wizard opens to Step 1: Cluster Location.
Step 6: Choose the Destination Folder
Select where to place this cluster in your Guardrails resource hierarchy. Resources from the cluster will be automatically imported under this folder. You can select an existing folder or click Create Folder to create a new one.

Click Continue to proceed.
Step 7: Download and Run the Deploy Script
The wizard generates a deployment script that installs the Guardrails agent into your cluster using kubectl and Helm.

Click Download Deployment Script to save the script, or click the eye icon (View & explain script) to review it first. The script viewer shows the full script with annotated sections explaining what each part does.

The script performs these steps:
- Sets the enroll secret: A JWT token scoped to the destination folder you selected. The agent uses this to authenticate with your workspace.
- Sets the workspace hostname: The URL of your Guardrails workspace (without the
https://prefix). - Creates the
guardrailsnamespace: Isolates the agent from your other workloads. - Stores the enroll secret as a Kubernetes Secret, so the agent pod can read it securely at runtime.
- Generates
guardrails-values.yaml: Configuration for the Helm chart with your workspace hostname. - Installs the agent: Adds the Turbot Helm repository and installs the
guardrails-agent-kuberneteschart.
Run the script in your terminal:
bash kube_cluster_connect.sh
Or make it executable and run directly:
chmod +x kube_cluster_connect.sh
./kube_cluster_connect.sh
After the agent is deployed, the cluster will appear in your workspace automatically. The Turbot > osquery > Configuration calculated policy must finish calculating before resources appear. This typically takes a few minutes.
[!NOTE] If no resources appear after a few minutes, verify that the
Turbot > osquery > Configurationpolicy value is available for the cluster resource.
Updating the Agent
To update an installed agent to the latest Helm chart version:
helm repo update
helm upgrade guardrails-agent-kubernetes turbot/guardrails-agent-kubernetes \
--namespace guardrails --reuse-values
To update with new configuration values:
helm upgrade guardrails-agent-kubernetes turbot/guardrails-agent-kubernetes \
--namespace guardrails --reuse-values -f guardrails-values.yaml
Only values included in guardrails-values.yaml will be updated, with priority given to new values.
Customizing the Cluster Name
Guardrails attempts to derive a friendly cluster name from the cloud provider:
- AWS EKS: Uses the
aws:eks:cluster-nametag - GCP GKE: Uses
cluster-namefrom instance metadata
To override the default name, add an annotation to the StatefulSet in your guardrails-values.yaml:
statefulSet:
annotations:
guardrails.turbot.com/cluster-name: "my-kube-cluster"
Then upgrade the agent:
helm upgrade guardrails-agent-kubernetes turbot/guardrails-agent-kubernetes \
--namespace guardrails --reuse-values -f guardrails-values.yaml
Troubleshooting
| Issue | Solution |
|---|---|
| Agent not running | Check the StatefulSet status: kubectl get sts --namespace guardrails |
| Agent errors | View agent logs: kubectl logs sts/guardrails-agent-kubernetes -f --namespace guardrails |
| Expired enroll secret | The enroll secret rotates hourly by default. Query for the latest: |
{
osquery(
resource: "FOLDER_RESOURCE_ID"
resourceTypeUri: "tmod:@turbot/kubernetes#/resource/types/cluster"
) {
enrollSecret
}
}
| Issue | Solution |
|---|---|
| Old secret in cluster | Delete the existing secret and redeploy: kubectl delete secret guardrails-agent-kubernetes-secret --namespace guardrails |
| No resources discovered | Verify the Turbot > osquery > Configuration calculated policy value is available for the cluster. If it's still calculating, wait for it to complete. |
Next Steps
- Configure Queries, Customize which resources are monitored and how frequently.
- Decommission, Remove a cluster from Guardrails.
- Set up ServiceNow integration to sync Kubernetes resources into ServiceNow.