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

fix(kuma-cp): support GC service account #4483

Merged
merged 2 commits into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pkg/plugins/runtime/k8s/webhooks/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ func (h *validatingHandler) decode(req admission.Request) (core_model.Resource,

// Note that this func does not validate ConfigMap and Secret since this webhook does not support those
func (h *validatingHandler) isOperationAllowed(resType core_model.ResourceType, userInfo authenticationv1.UserInfo) admission.Response {
if userInfo.Username == h.cpServiceAccountName {
// Assume this means sync from another zone. Not security; protecting user from self.
if userInfo.Username == h.cpServiceAccountName ||
userInfo.Username == "system:serviceaccount:kube-system:generic-garbage-collector" {
// Assume this means sync from another zone or GC cleanup resources due to OwnerRef.
// Not security; protecting user from self.
return admission.Allowed("")
}

Expand Down
15 changes: 15 additions & 0 deletions pkg/plugins/runtime/k8s/webhooks/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -656,5 +656,20 @@ var _ = Describe("Validation", func() {
},
operation: admissionv1.Delete,
}),
Entry("should pass validation on DELETE in Global CP by GC", testCase{
mode: core.Global,
objTemplate: &mesh_proto.Dataplane{},
username: "system:serviceaccount:kube-system:generic-garbage-collector",
resp: kube_admission.Response{
AdmissionResponse: admissionv1.AdmissionResponse{
UID: "12345",
Allowed: true,
Result: &kube_meta.Status{
Code: 200,
},
},
},
operation: admissionv1.Delete,
}),
)
})