Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support /status and /scale subresources #27

Closed
coryodaniel opened this issue Jan 14, 2019 · 2 comments
Closed

Support /status and /scale subresources #27

coryodaniel opened this issue Jan 14, 2019 · 2 comments

Comments

@coryodaniel
Copy link
Owner

coryodaniel commented Jan 14, 2019

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

@coryodaniel
Copy link
Owner Author

coryodaniel commented Jan 14, 2019

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])

@coryodaniel coryodaniel added this to the 0.4 milestone Jun 25, 2019
@coryodaniel coryodaniel removed this from the 0.4 milestone Aug 12, 2019
@mruoss
Copy link
Collaborator

mruoss commented Sep 15, 2022

status and scale resources are supported with Bonny.ControllerV2 (using the customize_crd/1 callback to define subresources and schemas)

@mruoss mruoss closed this as completed Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants