You can manage multiple clusters by creating separate connection objects using K8s.Conn. Common methods include:
K8s.Conn.from_file/1: Load configuration from a kubeconfig file (e.g., ~/.kube/config).K8s.Conn.from_service_account/0: Use the service account credentials available within a pod.
To move workloads between clusters, you can list resources from one connection and use K8s.Client.async/2 to create them on another connection.
# 1. Register staging cluster
{:ok, staging_conn} = K8s.Conn.from_file("~/.kube/config")
# 2. Register prod cluster
{:ok, prod_conn} = K8s.Conn.from_service_account()
# 3. Get deployments from prod
operation = K8s.Client.list("apps/v1", :deployment, namespace: "default")
{:ok, deployments} = K8s.Client.run(prod_conn, operation)
# 4. Map deployments to create operations for staging
operations = Enum.map(deployments, fn(deployment) -> K8s.Client.create(deployment) end)
# 5. Execute creation asynchronously on staging
K8s.Client.async(staging_conn, operations)