Service Accounts

A service account is an identity for processes to run inside a pod. These are generally created for Cron Jobs and outside agents such as Jenkins to perform operations on the cluster.

The service account is simply a named entity within a namespace and it can be granted roles and/or cluster roles so it can perform functions against the cluster or specific namespace.

k9.core.list_service_accounts(namespace: Optional[str] = None)[source]

Lists service accounts in a namespace.

Parameters

namespace – The namespace to list accounts from. If None, we use the default namespace.

Returns

A list of every service account in the namespace.

Example Output:

[
  {
    'name': 'elastic-sa',
    'age': 123456789
  },
  {
    'name': 'fluent-sa',
    'age': 123456999
  }
]
k9.core.create_service_account(name: str, namespace: Optional[str] = None)[source]

Create a service account.

Parameters
  • name – Name of service account.

  • namespace – namespace to create service account in. If None, create service account in default namespace

Returns

V1ServiceAccount

k9.core.get_service_account(name: str, namespace: Optional[str] = None)[source]

Get details of specified service account

Parameters
  • name – Name of service account to retrieve.

  • namespace – Namespace to retrieve service account from. If None, retrieve from default namespace.

Returns

V1ServiceAccount

k9.core.service_account_exists(name: str, namespace: Optional[str] = None)[source]

Checks for existence of service account

Parameters
  • name – Name of service account to look for.

  • namespace – Namespace to look in. If None, look in default namespace.

Returns

True if specified account exists.

k9.core.delete_service_account(name: str, namespace: Optional[str] = None)[source]

Delete specified service account.

Parameters
  • name – Name of service account to delete.

  • namespace – Namespace to delete from. If None, delete from default namespace.

Returns

None if service account doesn’t exists, otherwise returns V1Status