k8s v0.5.0-rc.2 K8s.Resource
Manifest attribute helpers
Link to this section Summary
Link to this section Functions
Link to this function
all_from_file!(path, assigns)
Create a list of resource Map
s from a YAML file with multi object annotation.
Raises File.Error
when the file does not exist.
Examples
iex> opts = [namespace: "default", name: "nginx", image: "nginx:nginx:1.7.9"]
...> K8s.Resource.all_from_file!("test/support/helm-chart.yaml", opts)
[
%{
"apiVersion" => "v1",
"kind" => "Namespace",
"metadata" => %{"name" => "default"}
},
%{
"apiVersion" => "apps/v1",
"kind" => "Deployment",
"metadata" => %{
"labels" => %{"app" => "nginx"},
"name" => "nginx-deployment",
"namespace" => "default"
},
"spec" => %{
"replicas" => 3,
"selector" => %{"matchLabels" => %{"app" => "nginx"}},
"template" => %{
"metadata" => %{"labels" => %{"app" => "nginx"}},
"spec" => %{
"containers" => [
%{
"image" => "nginx:nginx:1.7.9",
"name" => "nginx",
"ports" => [%{"containerPort" => 80}]
}
]
}
}
}
}
]
Link to this function
annotation(resource, name)
Link to this function
annotations(resource)
Link to this function
api_version(resource)
Helper for building a kubernetes' resource Map
Examples
iex> K8s.Resource.build("v1", "Pod")
%{"apiVersion" => "v1", "kind" => "Pod", "metadata" => %{}}
iex> K8s.Resource.build("v1", "Namespace", "foo")
%{"apiVersion" => "v1", "kind" => "Namespace", "metadata" => %{"name" => "foo"}}
iex> K8s.Resource.build("v1", "Pod", "default", "foo")
%{"apiVersion" => "v1", "kind" => "Pod", "metadata" => %{"namespace" => "default", "name" => "foo"}}
Link to this function
build(api_version, kind, namespace, name)
Link to this function
build(api_version, kind, namespace, name, labels)
Link to this function
cpu(value)
Link to this function
from_file!(path, assigns)
Create a resource Map
from a YAML file.
Raises File.Error
when the file does not exist.
Examples
iex> opts = [namespace: "default", name: "nginx", image: "nginx:nginx:1.7.9"]
...> K8s.Resource.from_file!("test/support/deployment.yaml", opts)
%{
"apiVersion" => "apps/v1",
"kind" => "Deployment",
"metadata" => %{
"labels" => %{"app" => "nginx"},
"name" => "nginx-deployment",
"namespace" => "default"
},
"spec" => %{
"replicas" => 3,
"selector" => %{"matchLabels" => %{"app" => "nginx"}},
"template" => %{
"metadata" => %{"labels" => %{"app" => "nginx"}},
"spec" => %{
"containers" => [
%{
"image" => "nginx:nginx:1.7.9",
"name" => "nginx",
"ports" => [%{"containerPort" => 80}]
}
]
}
}
}
}
Link to this function
has_annotation?(resource, name)
Link to this function
has_label?(resource, name)
Link to this function
kind(resource)
Link to this function
label(resource, name)
Link to this function
labels(resource)
Link to this function
memory(value)
Link to this function
metadata(resource)
Link to this function
name(resource)
Link to this function