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

admission.k8s.io/v1 AdmissionReview response requires uid #34

Open
mingfang opened this issue Mar 26, 2020 · 2 comments
Open

admission.k8s.io/v1 AdmissionReview response requires uid #34

mingfang opened this issue Mar 26, 2020 · 2 comments

Comments

@mingfang
Copy link

According to https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/ the response needs to look like this

{
  "apiVersion": "admission.k8s.io/v1",
  "kind": "AdmissionReview",
  "response": {
    "uid": "<value from request.uid>",
    "allowed": true
  }
}
@patrick-east
Copy link

@mingfang is there a specific example or policy in the library that is missing this? Any more details would be helpful.

@mingfang
Copy link
Author

mingfang commented Mar 26, 2020

So technically this library is not missing it because it's still on the older admission.k8s.io/v1beta1.
I have upgraded it locally by adding the uid like this

"patch": base64.encode(json.marshal(fullPatches)),

response = x {
    count(patch) > 0

    # if there are missing leaves e.g. trying to add a label to something that doesn't
    # yet have any, we need to create the leaf nodes as well

    fullPatches := ensureParentPathsExist(cast_array(patch))

    x := {
        "allowed": true,
        "patchType": "JSONPatch",
        "patch": base64.encode(json.marshal(fullPatches)),
        "uid": input.request.uid, <-needed in v1
    }
}

But the problem is I can't add uid to the default response here

default response = {"allowed": true}

because I get here saying default response can not use refs.
The workaround is to leave the uid out of the default response and Kubernetes prints out a warning.

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

No branches or pull requests

2 participants