View Source Usage

tl;dr Examples

Creating a deployment

{:ok, conn} = K8s.Conn.from_file("path/to/kubeconfig.yaml")

opts = [namespace: "default", name: "nginx", image: "nginx:nginx:1.7.9"]
{:ok, resource} = K8s.Resource.from_file("priv/deployment.yaml", opts)

{:ok, deployment} =
    resource
    |> K8s.Client.create()
    |> K8s.Client.put_conn(conn)
    |> K8s.Client.run()

Listing deployments

In a namespace:

{:ok, conn} = K8s.Conn.from_file("path/to/kubeconfig.yaml")

{:ok, deployments} =
    K8s.Client.list("apps/v1", "Deployment", namespace: "prod")
    |> K8s.Client.put_conn(conn)
    |> K8s.Client.run()

Across all namespaces:

{:ok, conn} = K8s.Conn.from_file("path/to/kubeconfig.yaml")

{:ok, deployments} =
    K8s.Client.list("apps/v1", "Deployment", namespace: :all)
    |> K8s.Client.put_conn(conn)
    |> K8s.Client.run()

Getting a deployment

{:ok, conn} = K8s.Conn.from_file("path/to/kubeconfig.yaml")

{:ok, deployment} =
    K8s.Client.get("apps/v1", :deployment, [namespace: "default", name: "nginx-deployment"])
    |> K8s.Client.put_conn(conn)
    |> K8s.Client.run(conn, operation)