Kubernetes
Link a Kubernetes cluster to Rocketgraph with a read-only service account.
Connect a cluster with a service account that has Kubernetes' built-in view role. It can't read Secrets or change anything.
Connect
- Open Connect and click Kubernetes under Hosting and deploys.
- Create a read-only account: run this with kubectl against the cluster. It makes the service account and prints the three values the form asks for.
bash
kubectl create namespace rocketgraph
kubectl -n rocketgraph create serviceaccount rocketgraph-reader
kubectl create clusterrolebinding rocketgraph-reader \
--clusterrole=view --serviceaccount=rocketgraph:rocketgraph-reader
kubectl -n rocketgraph apply -f - <<'YAML'
apiVersion: v1
kind: Secret
metadata:
name: rocketgraph-reader
annotations:
kubernetes.io/service-account.name: rocketgraph-reader
type: kubernetes.io/service-account-token
YAML
sleep 2
echo "server: $(kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}')"
echo "token: $(kubectl -n rocketgraph get secret rocketgraph-reader -o jsonpath='{.data.token}' | base64 -d)"
echo "ca: $(kubectl -n rocketgraph get secret rocketgraph-reader -o jsonpath='{.data.ca\.crt}')"
The token comes from a Secret rather than kubectl create token, because those tokens expire after a day on many managed clusters.
- API server URL: the server line.
- Token: the token line.
- CA certificate (optional): the ca line. Leave blank only if the API server has a public certificate.
- Click Connect Kubernetes. Rocketgraph checks it can list deployments and shows the Kubernetes version.
What Rocketgraph reads
With the view role, through the Kubernetes API:
GET /versionGET /apis/apps/v1/deployments
Known limits
- The API server URL must start with
https://and be reachable from the internet. A cluster with a private-only endpoint can't be connected yet. - Today Rocketgraph uses this connection to check access and list the cluster on your Overview.
Disconnect
Open Kubernetes on the Connect page and click Disconnect Kubernetes. Then remove the access in the cluster:
kubectl delete clusterrolebinding rocketgraph-reader
kubectl delete namespace rocketgraph