liveBook · Manning

Service account

As explained in Google Anthos in Action

A Kubernetes service account is a namespace-scoped Kubernetes identity that supplies credentials and permissions to workloads or users.

A Kubernetes service account (KSA) is a namespace-scoped identity used to authenticate cluster access and authorize operations through Kubernetes RBAC. It differs from a Google service account, which supplies Google Cloud permissions for cluster registration, connectivity, or operations data. section 2.7 section 17.3.5

Use distinct accounts and explicit bindings for these responsibilities:

  • Create a KSA in the target namespace for token-based cluster login. section 2.7
  • Bind the KSA to the view role for read-only access and to cloud-console-reader for console resource visibility. section 2.7
  • Assign separate Google service accounts to cluster registration, the Connect Agent, and logging and monitoring where required. section 17.3.5

Create a console-login identity

Set KSA_NAME, create the account, and bind the required ClusterRoles: kubectl create serviceaccount ${KSA_NAME}; kubectl create clusterrolebinding VIEW_BINDING --clusterrole view --serviceaccount default:${KSA_NAME}; kubectl create clusterrolebinding CONSOLE_BINDING --clusterrole cloud-console-reader --serviceaccount default:${KSA_NAME}. A token can then be read from the account's Secret for token authentication. section 2.7

apiVersion: v1
kind: Config
users:
- name: svcs-acct-dply
user:
 token: <replace this with token info>
clusters:
- cluster:
 certificate-authority-data: <replace this with certificate-authority-data info>
 server: <replace this with server info>
name: self-hosted-cluster
contexts:
- context:
 cluster: self-hosted-cluster
 user: svcs-acct-dply
name: svcs-acct-context
current-context: svcs-acct-context

Inspect a kubeconfig template that uses a service-account token, cluster certificate data, and server information to connect to an external cluster. section 5.3

How Google Anthos in Action covers it

How deep it goes
Demonstrates account creation, role bindings, token extraction, kubeconfig use, and separation of Google Cloud roles.
Examples
Uses kubectl account and binding commands, a token-extraction command, and an external-cluster kubeconfig template.
What it assumes
Assumes access to a cluster and Google Cloud administration; teaches the required account types, bindings, tokens, and roles.
What you can do after
Operate/configure token-based cluster login by creating a KSA, binding RBAC roles, and supplying its token through kubeconfig.
How it connects
Connects service accounts with Kubernetes RBAC, ClusterRoleBinding, kubeconfig, Anthos, Connect Agent, and IAM roles.

Also explained in

Compare how 10 books explain service account →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Google Anthos in Action. The section links point to the parts of the book it draws on.