Smarter AWS EKS Helper

class smarter.apps.infrastructure.providers.aws.helpers.eks.AWSEks(aws_access_key_id=None, aws_secret_access_key=None, aws_region=None, aws_profile=None, shared_resource_identifier=None, environment=None, environment_domain=None, root_domain=None, debug_mode=False, init_info=None)[source]

Bases: AWSBase

The AWS EKS helper: the platform’s cluster, smarter_settings.aws_eks_cluster_name.

The cluster is optional. Without its name, the platform runs, but nothing is deployed to Kubernetes, and the first attempt to reach the cluster logs how to set it.

cluster_name_is_set()[source]

Return True if smarter_settings.aws_eks_cluster_name is set.

If it is not, log how to set it, once per process.

Return type:

bool

get_cluster_resources()[source]

Describe the cloud resources of the platform’s EKS cluster: the cluster, its add-ons and its node groups.

Return type:

dict[str, list[dict[str, str]]]

Returns:

The name and arn of each, by cluster, addons and nodegroups.

Raises:

AWSNotReadyError – If AWS is not ready, or the cluster’s name is not set.

get_kubernetes_info()[source]

Describe the platform’s EKS cluster.

Return type:

dict[str, Any]

Returns:

The cluster’s health, platformVersion, status and Kubernetes version.

get_token()[source]

Create a bearer token for the platform’s EKS cluster, as aws eks get-token does.

The token is an STS GetCallerIdentity url, presigned with the session’s credentials and the cluster’s name, which EKS calls to identify the caller. Creating it makes no request, so it takes milliseconds rather than the seconds that the aws cli takes to start.

Return type:

tuple[str, float]

Returns:

The token, and when it should no longer be used, as a time.time().

Raises:

AWSNotReadyError – If AWS is not ready, or the cluster’s name or region is not set.

update_kubeconfig()[source]

Write the kubeconfig of the platform’s EKS cluster, with aws eks update-kubeconfig.

Return type:

bool

Returns:

True if it was written.