Skip to content

Conversation

phosae
Copy link
Owner

@phosae phosae commented Jul 21, 2023

implements subresource for our Foo

  • get/update foos/config <-> hello.zeng.dev Config
  • get/update foos/status <-> hello.zeng.dev Foo
  • create foos/base64 <-> return base64 formatted content of foo base64 String Obj

@phosae
Copy link
Owner Author

phosae commented Jul 24, 2023

k apply -f ../api/artifacts/samples/hello-foo.yml
kubectl patch fo myfoo --subresource status --patch '{"spec": {"config": {"msg1": "👻"}}, "status": {"phase": "Running"}}'

only the field status will be updated

note: controller with permission foos/status can update object labels, annotations...

@phosae
Copy link
Owner Author

phosae commented Jul 25, 2023

request a base64 from a foo resource returns a transformation.zeng.dev/v1beta1 Base64

base64 subresource is like the token subresource in kube-apiserver, it only supports POST, and return a different kind differ from the main resource

curl -s -X POST -H "Content-Type: application/json" localhost:8001/apis/hello.zeng.dev/v1/namespaces/default/foos/myfoo/base64 -d '{
"apiVersion": "transformation.zeng.dev/v1beta1",
"kind": "Base64",
"spec": {"fieldPath": "spec"}
}' | jq -r .status.output | base64 -d 

@phosae
Copy link
Owner Author

phosae commented Jul 25, 2023

foos/status ↔️ pod/status
foos/config ↔️ deployments/scale
foos/base64 ↔️ serviceaccounts/token

@phosae phosae merged commit eed9312 into master Jul 25, 2023
@phosae phosae deleted the subresource branch July 25, 2023 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant