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

KEP 2527: Clarify meaning of status #2537

Conversation

thockin
Copy link
Member

@thockin thockin commented Feb 22, 2021

Since basically the beginning of Kubernetes, we've had this sort of "litmus
test" for status fields: "If I erased the whole status struct, would everything
in it be reconstructed (or at least be reconstructible) from observation?". The
goal was to ensure that the delineation between "what I asked for" and "what it
actually is" was clear and to encourage active reconciliation of state.

Many of our APIs pass this test (sometimes we fudge it and say yes "in
theory"), but not all of them do. This KEP proposes to clarify or remove this
guidance, especially as it pertains to state that is not derived from
observation.

One of the emergent uses of the spec/status split is access control. It is
assumed that, for most resources, users own (can write to) all of spec and
controllers own all of status, and not the reverse. This allows patterns like
Services which set spec.type: LoadBalancer, where the controller writes the
LB's IP address to status, and kube-proxy can trust that IP address (because it
came from a controller, not a user). Compare that with Services which use
spec.externalIPs. The behavior is kube-proxy is roughly the same, but
because non-trusted users can write to spec.externalIPs and that does not
require a trusted controller to ACK, that behavior was declared a CVE.

This KEP further proposes to add guidance for APIs that want to implement an
"allocation" or "binding" pattern which requires trusted ACK.

KEP: #2527

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 22, 2021
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Feb 22, 2021
@k8s-ci-robot k8s-ci-robot added kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. labels Feb 22, 2021
@dims
Copy link
Member

dims commented Mar 12, 2021

cc @palnabarun @nikhita

@embano1
Copy link
Member

embano1 commented Jun 3, 2021

Since I'm (currently) in the "option 1" camp I was wondering if we could use annotations to track non-observable state there instead of diluting status? Just throwing this out here as I did not see it mentioned in the KEP (but not sure if it was discussed already and I'm just missing context).

@thockin
Copy link
Member Author

thockin commented Jun 7, 2021

@embano1 In general we try avoid enshrining non-primitive APIs as annotations. It just offloads the problem of decoding onto users. In this case, I don't think it helps because annotations are not RBAC'ed individually. A user could set "sensitive" values.

@thockin thockin force-pushed the 2527-clarify-status-observations-vs-rbac branch from c34280c to d9eff94 Compare June 7, 2021 23:49
@thockin thockin changed the title KEP 2527 draft 1: Clarify meaning of status KEP 2527: Clarify meaning of status Jun 7, 2021
@thockin
Copy link
Member Author

thockin commented Jun 7, 2021

Hi all. I made some minor updates to this, but there has not been much feedback so far. Would love to hear more thoughts.

@thockin thockin force-pushed the 2527-clarify-status-observations-vs-rbac branch from d9eff94 to 59f9b7f Compare June 7, 2021 23:55
Copy link
Member

@liggitt liggitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense... I don't think this scuttles any future plans to routinely discard status subtrees of objects or anything.

I expect some people have been writing controllers that operate as one-way "take observed state and update status" because of this guidance will now feel free to branch out into more creative/complex paths (spec → status pre-write → other object → status post-write, etc).

As we relax this, it would be good to give pretty crisp examples/guidance/patterns for writing state to status to help those folks stay re-entrant and robust in the face of conflicts/errors.

@thockin thockin force-pushed the 2527-clarify-status-observations-vs-rbac branch from ac119ef to e4c2311 Compare October 22, 2021 00:29
@thockin
Copy link
Member Author

thockin commented Oct 22, 2021

I fixed the small nit. I think the text you want actually goes in the impl, not the KEP? As such, PTAL at this.

@liggitt
Copy link
Member

liggitt commented Oct 22, 2021

I'm happy with the direction, and the details can fall in the actual docs PR. I do think it's worth at least mentioning in this KEP the risks that working from status as a data source introduces, even if the detailed recommendations / best practices / examples are in the docs PR.

Since basically the beginning of Kubernetes, we've had this sort of "litmus
test" for status fields: "If I erased the whole status struct, would everything
in it be reconstructed (or at least be reconstructible) from observation?". The
goal was to ensure that the delineation between "what I asked for" and "what it
actually is" was clear and to encourage active reconciliation of state.

Many of our APIs pass this test (sometimes we fudge it and say yes "in
theory"), but not all of them do.  This KEP proposes to clarify or remove this
guidance, especially as it pertains to state that is not derived from
observation.

One of the emergent uses of the spec/status split is access control.  It is
assumed that, for most resources, users own (can write to) all of spec and
controllers own all of status, and not the reverse.  This allows patterns like
Services which set `spec.type: LoadBalancer`, where the controller writes the
LB's IP address to status, and kube-proxy can trust that IP address (because it
came from a controller, not a user).  Compare that with Services which use
`spec.externalIPs`.  The behavior is kube-proxy is roughly the same, but
because non-trusted users can write to `spec.externalIPs` and that does not
require a trusted controller to ACK, that behavior was declared a CVE.

This KEP further proposes to add guidance for APIs that want to implement an
"allocation" or "binding" pattern which requires trusted ACK.
@thockin thockin force-pushed the 2527-clarify-status-observations-vs-rbac branch from e4c2311 to 771e7ad Compare October 22, 2021 21:59
@thockin
Copy link
Member Author

thockin commented Oct 22, 2021

Added, stole some of your words.

@liggitt
Copy link
Member

liggitt commented Oct 22, 2021

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 22, 2021
@thockin
Copy link
Member Author

thockin commented Oct 22, 2021

@derekwaynecarr @johnbelamaric @dims - you all are listed as sig-arch leads - please approve?

@dims
Copy link
Member

dims commented Dec 9, 2021

/approve

thanks for doing this! +1 to tune our guidance based on what we are observing in the field.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dims, liggitt, thockin

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 9, 2021
@k8s-ci-robot k8s-ci-robot merged commit c149454 into kubernetes:master Dec 9, 2021
@k8s-ci-robot k8s-ci-robot modified the milestones: v1.23, v1.24 Dec 9, 2021
rikatz pushed a commit to rikatz/enhancements that referenced this pull request Feb 1, 2022
Since basically the beginning of Kubernetes, we've had this sort of "litmus
test" for status fields: "If I erased the whole status struct, would everything
in it be reconstructed (or at least be reconstructible) from observation?". The
goal was to ensure that the delineation between "what I asked for" and "what it
actually is" was clear and to encourage active reconciliation of state.

Many of our APIs pass this test (sometimes we fudge it and say yes "in
theory"), but not all of them do.  This KEP proposes to clarify or remove this
guidance, especially as it pertains to state that is not derived from
observation.

One of the emergent uses of the spec/status split is access control.  It is
assumed that, for most resources, users own (can write to) all of spec and
controllers own all of status, and not the reverse.  This allows patterns like
Services which set `spec.type: LoadBalancer`, where the controller writes the
LB's IP address to status, and kube-proxy can trust that IP address (because it
came from a controller, not a user).  Compare that with Services which use
`spec.externalIPs`.  The behavior is kube-proxy is roughly the same, but
because non-trusted users can write to `spec.externalIPs` and that does not
require a trusted controller to ACK, that behavior was declared a CVE.

This KEP further proposes to add guidance for APIs that want to implement an
"allocation" or "binding" pattern which requires trusted ACK.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.