Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions helm_sdkpy/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,32 @@ def __exit__(self, exc_type, exc_val, exc_tb):
self.__del__()
return False

@classmethod
def from_service_account(cls, namespace: str = "default") -> "Configuration":
"""Create configuration using in-cluster ServiceAccount.

This is for running inside a Kubernetes pod with a ServiceAccount.
The pod must have automountServiceAccountToken: true (the default).

When running in-cluster, the Go shim automatically uses:
- Token from /var/run/secrets/kubernetes.io/serviceaccount/token
- CA cert from /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
- API server from KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT env vars

Args:
namespace: Kubernetes namespace to operate in (default: "default")

Returns:
Configuration instance using ServiceAccount authentication

Example:
>>> # Inside a Kubernetes pod
>>> config = Configuration.from_service_account(namespace="my-namespace")
>>> install = Install(config)
>>> result = asyncio.run(install.run("my-release", "oci://ghcr.io/org/chart"))
"""
return cls(namespace=namespace, kubeconfig=None, kubecontext=None)


class Install:
"""Helm install action.
Expand Down
Loading