bonny
bonny copied to clipboard
Support /status and /scale subresources
Support status and scale subresources
Requires: k8s 1.13 beta
Expected behavior
CRD should generate w/ subresources:
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: crontabs.stable.example.com
spec:
group: stable.example.com
versions:
- name: v1
served: true
storage: true
scope: Namespaced
names:
plural: crontabs
singular: crontab
kind: CronTab
shortNames:
- ct
# subresources describes the subresources for custom resources.
subresources:
# status enables the status subresource.
status: {}
# scale enables the scale subresource.
scale:
# specReplicasPath defines the JSONPath inside of a custom resource that corresponds to Scale.Spec.Replicas.
specReplicasPath: .spec.replicas
# statusReplicasPath defines the JSONPath inside of a custom resource that corresponds to Scale.Status.Replicas.
statusReplicasPath: .status.replicas
# labelSelectorPath defines the JSONPath inside of a custom resource that corresponds to Scale.Status.Selector.
labelSelectorPath: .status.labelSelector
Will need to support add'l functions on the controller update_status/1
update_scale/1
script for patching status on the HelloOperator example greeting:
url = "https://localhost:6443/apis/hello-operator.example.com/v1/namespaces/default/greetings/hola-server"
conf = K8s.Conf.from_file("~/.kube/config")
request_options = K8s.Conf.RequestOptions.generate(conf)
http_headers = [{"Accept", "application/json"}, {"Content-Type", "application/json"}]
{:ok, %{body: resp}} = HTTPoison.get(url, http_headers, [ssl: request_options.ssl_options])
greeting = Jason.decode!(resp)
patch = %{
"metadata" => greeting["metadata"],
"status" => %{
"conditions" => [
%{
"lastTransitionTime" => "2019-01-14T20:13:49Z",
"lastUpdateTime" => "2019-01-14T20:13:49Z",
"message" => "Kewl",
"reason" => "Kewl",
"status" => "True",
"type" => "Available"
}
]
}
}
body = Jason.encode!(patch)
result = HTTPoison.put("#{url}/status", body, http_headers, [ssl: request_options.ssl_options])
status and scale resources are supported with Bonny.ControllerV2
(using the customize_crd/1
callback to define subresources and schemas)