This guide explains how to access a Kubernetes cluster through Hoop using a Kubernetes Service Account token, with full SSO enforcement, Just-In-Time access, and complete auditability.
You can use this method with the Kubernetes API or with kubectl.
1. Create a Service Account
kubectl create serviceaccount my-sa -n my-namespace
2. Generate a Service Account Token
Create a Kubernetes Secret that holds the token:
apiVersion: v1
kind: Secret
metadata:
name: my-sa-token
namespace: my-namespace
annotations:
kubernetes.io/service-account.name: my-sa
type: kubernetes.io/service-account-tokenApply the Secret:
kubectl apply -f sa-token.yaml
Extract the token:
kubectl -n my-namespace get secret my-sa-token \
-o jsonpath='{.data.token}' | base64 -dYou will use this token inside the Hoop HTTP connection.
3. Assign RBAC Permissions
The following example grants read-only access to pods:
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: my-namespace
name: my-sa-role
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: my-sa-binding
namespace: my-namespace
subjects:
- kind: ServiceAccount
name: my-sa
namespace: my-namespace
roleRef:
kind: Role
name: my-sa-role
apiGroup: rbac.authorization.k8s.ioApply the RBAC rules:
kubectl apply -f rbac.yaml
4. Configure the Hoop HTTP Connection
In Hoop, create an HTTP connection pointing to your Kubernetes API server.
Example connection configuration:
- URL:
https://<your-kubernetes-api-endpoint> - Allow insecure SSL:
✔ Enable if your cluster uses self-signed certificates. - Header injection:
Authorization: Bearer <SERVICE_ACCOUNT_TOKEN>
Hoop will automatically inject this header into every request, ensuring consistent Kubernetes authentication.