Kubernetes Setup
Section titled “Kubernetes Setup”Required RBAC permissions
Section titled “Required RBAC permissions”The identity used by the plugin (your kubeconfig user, an in-cluster service account, or an explicit token) needs read access to Secrets and/or ConfigMaps in the target namespace.
The minimum permissions are get on secrets and configmaps:
apiVersion: rbac.authorization.k8s.io/v1kind: Rolemetadata: name: varlock-reader namespace: defaultrules: - apiGroups: [""] resources: ["secrets", "configmaps"] verbs: ["get"]Apply it with:
kubectl apply -f varlock-rbac.yamlService account for in-cluster use
Section titled “Service account for in-cluster use”When running inside a pod, the plugin uses the pod’s mounted service account. Create a dedicated service account and bind it to the role above:
-
Create a service account
Terminal window kubectl create serviceaccount varlock-reader -n default -
Bind the role to the service account
varlock-rolebinding.yaml apiVersion: rbac.authorization.k8s.io/v1kind: RoleBindingmetadata:name: varlock-reader-bindingnamespace: defaultsubjects:- kind: ServiceAccountname: varlock-readernamespace: defaultroleRef:kind: Rolename: varlock-readerapiGroup: rbac.authorization.k8s.ioTerminal window kubectl apply -f varlock-rolebinding.yaml -
Use the service account in your pod spec
deployment.yaml spec:serviceAccountName: varlock-readercontainers:- name: appimage: my-app:latest
Generate a bearer token for explicit auth
Section titled “Generate a bearer token for explicit auth”For CI/CD or other external use cases that need an explicit token, create a long-lived service account token:
# Create a token secret bound to the service accountkubectl apply -f - <<EOFapiVersion: v1kind: Secretmetadata: name: varlock-reader-token namespace: default annotations: kubernetes.io/service-account.name: varlock-readertype: kubernetes.io/service-account-tokenEOF
# Read the tokenkubectl get secret varlock-reader-token -n default -o jsonpath='{.data.token}' | base64 -dInject the resulting token into your deployment environment as KUBERNETES_TOKEN (or whatever name you wire up in @initKubernetes()).
Verify access
Section titled “Verify access”You can test that the configured identity can read the resources you expect:
# As your current kubeconfig userkubectl auth can-i get secrets -n defaultkubectl auth can-i get configmaps -n default
# As a specific service accountkubectl auth can-i get secrets -n default --as=system:serviceaccount:default:varlock-reader