Skip to content

Instantly share code, notes, and snippets.

@liggitt
Created December 20, 2019 16:12
Show Gist options
  • Save liggitt/7fff860915a899c240ffd493c5cf3be1 to your computer and use it in GitHub Desktop.
Save liggitt/7fff860915a899c240ffd493c5cf3be1 to your computer and use it in GitHub Desktop.
crd status patch
apiVersion: example.com/v1
kind: Scaler
metadata:
name: foo
spec:
replicas: 1
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: scalers.example.com
spec:
group: example.com
scope: Namespaced
preserveUnknownFields: false
versions:
- name: v1
storage: true
served: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
replicas:
type: integer
status:
type: object
properties:
selector:
type: string
replicas:
type: integer
subresources:
status: {}
scale:
statusReplicasPath: .status.replicas
specReplicasPath: .spec.replicas
labelSelectorPath: .status.selector
names:
singular: scaler
plural: scalers
kind: Scaler
listKind: ScalerList
$ kubectl create -f scaler-crd.yaml
customresourcedefinition.apiextensions.k8s.io/scalers.example.com created
$ kubectl create -f scaler-cr.yaml
scaler.example.com/foo created
$ curl -s -X PATCH \
-H "Content-Type: application/merge-patch+json" \
--data '{"status":{"selector":"foo"}}' \
http://localhost:8080/apis/example.com/v1/namespaces/default/scalers/foo/status | jq .
{
"apiVersion": "example.com/v1",
"kind": "Scaler",
"metadata": {
"creationTimestamp": "2019-12-20T16:10:32Z",
"generation": 1,
"name": "foo",
"namespace": "default",
"resourceVersion": "302",
"selfLink": "/apis/example.com/v1/namespaces/default/scalers/foo/status",
"uid": "b9e2f122-ffd3-4d73-9d51-7932994f8b82"
},
"spec": {
"replicas": 1
},
"status": {
"selector": "foo"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment