-
Notifications
You must be signed in to change notification settings - Fork 36
CM-576: Implementation of Network Policy for Cert Manager Operator #283
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
base: master
Are you sure you want to change the base?
CM-576: Implementation of Network Policy for Cert Manager Operator #283
Conversation
@PillaiManish: This pull request references CM-576 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.20.0" version, but no target version was set. In response to this: Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
6628d66
to
efb2f8d
Compare
dcaa292
to
9864f42
Compare
@PillaiManish: This pull request references CM-576 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.20.0" version, but no target version was set. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E0610 17:30:08.850137 1 reflector.go:166] "Unhandled Error" err="k8s.io/client-go/informers/factory.go:160: Failed to watch *v1.NetworkPolicy: failed to list *v1.NetworkPolicy: networkpolicies.networking.k8s.io is forbidden: User \"system:serviceaccount:cert-manager-operator:cert-manager-operator-controller-manager\" cannot list resource \"networkpolicies\" in API group \"networking.k8s.io\" in the namespace \"cert-manager-operator\""
W0610 17:30:58.441258 1 reflector.go:569] k8s.io/client-go/informers/factory.go:160: failed to list *v1.NetworkPolicy: networkpolicies.networking.k8s.io is forbidden: User "system:serviceaccount:cert-manager-operator:cert-manager-operator-controller-manager" cannot list resource "networkpolicies" in API group "networking.k8s.io" in the namespace "cert-manager-operator"
E0610 17:30:58.441294 1 reflector.go:166] "Unhandled Error" err="k8s.io/client-go/informers/factory.go:160: Failed to watch *v1.NetworkPolicy: failed to list *v1.NetworkPolicy: networkpolicies.networking.k8s.io is forbidden: User \"system:serviceaccount:cert-manager-operator:cert-manager-operator-controller-manager\" cannot list resource \"networkpolicies\" in API group \"networking.k8s.io\" in the namespace \"cert-manager-operator\""
from the e2e operator pod logs it seems that the NetworkPolicy we intend to apply are not getting added at all. One way for the e2e to observe this as a failure is to add a status condition check for the new static-resource-controller being added, refer #279 for details. However, for this to work would need to check if your controller can effectively apply a NetworkPolicy object via library-go first, and resolve that RBAC issue too.
bindata/cert-manager-deployment/network-policy/operator-allow-egress-to-api-server.yaml
Outdated
Show resolved
Hide resolved
bindata/cert-manager-deployment/network-policy/operator-allow-ingress-to-metrics.yaml
Outdated
Show resolved
Hide resolved
bindata/cert-manager-deployment/network-policy/operator-deny-all-pod-selector.yaml
Outdated
Show resolved
Hide resolved
egress: | ||
- ports: | ||
- protocol: TCP | ||
port: 6443 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows (operator pod to) egress ALL to any 6443 port to any pod on the cluster? Is my understanding correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, in the docs they have mentioned this way. They might tighten it later.
pkg/controller/deployment/cert_manager_operator_static_resource.go
Outdated
Show resolved
Hide resolved
@@ -433,7 +433,7 @@ func validateTolerationsConfig(tolerations []corev1.Toleration, fldPath *field.P | |||
func validateResourceRequirements(requirements corev1.ResourceRequirements, fldPath *field.Path) error { | |||
// convert corev1.ResourceRequirements to core.ResourceRequirements, required for validation. | |||
convRequirements := *(*core.ResourceRequirements)(unsafe.Pointer(&requirements)) | |||
return corevalidation.ValidateResourceRequirements(&convRequirements, nil, fldPath.Child("resources"), corevalidation.PodValidationOptions{}).ToAggregate() | |||
return corevalidation.ValidateContainerResourceRequirements(&convRequirements, nil, fldPath.Child("resources"), corevalidation.PodValidationOptions{}).ToAggregate() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coming in from upstream bump?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, in the upstream, that corevalidation
func validatePodResourceRequirements(requirements *core.ResourceRequirements, podClaimNames sets.Set[string], fldPath *field.Path, opts PodValidationOptions) field.ErrorList {
return validateResourceRequirements(requirements, validatePodResourceName, podClaimNames, fldPath, opts)
}
func ValidateContainerResourceRequirements(requirements *core.ResourceRequirements, podClaimNames sets.Set[string], fldPath *field.Path, opts PodValidationOptions) field.ErrorList {
return validateResourceRequirements(requirements, validateContainerResourceName, podClaimNames, fldPath, opts)
}
// Validates resource requirement spec.
func validateResourceRequirements(requirements *core.ResourceRequirements, resourceNameFn func(core.ResourceName, *field.Path) field.ErrorList, podClaimNames sets.Set[string], fldPath *field.Path, opts PodValidationOptions) field.ErrorList {
Two function have been added validatePodResourceRequirements, ValidateContainerResourceRequirements.
"fmt" | ||
"net/http" | ||
fmt "fmt" | ||
http "net/http" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what is changing the generated client-gen code.
Auto-generation update?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, maybe the bump? I will once take a look on it.
@@ -71,10 +71,13 @@ func RunOperator(ctx context.Context, cc *controllercmd.ControllerContext) error | |||
versionRecorder := status.NewVersionGetter() | |||
versionRecorder.SetVersion("operator", status.VersionForOperatorFromEnv()) | |||
|
|||
operatorclient.OperatorNamespace = cc.OperatorNamespace | |||
|
|||
kubeInformersForNamespaces := v1helpers.NewKubeInformersForNamespaces(kubeClient, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's check library-go implementation for the Static Resources Controller (especially informers),
my guess is that there is no informer/client for NetworkPolicy yet.
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: PillaiManish The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
k8s.io/client-go v0.31.7 | ||
k8s.io/code-generator v0.31.1 | ||
k8s.io/component-base v0.31.7 | ||
golang.org/x/tools v0.26.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these bumps to kube 32, can go in as a separate PR (ideally with the upstream bump, but not a must)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean with the PR ?
pkg/controller/deployment/cert_manager_operator_static_resource.go
Outdated
Show resolved
Hide resolved
looks like apply-ing NetworkPolicy via Static Resource Controller was already added in openshift/library-go#1961: which suffices, so fixing the RBAC should fix your issue. So additionally, we would need e2e to check that Status.Conditions is: |
9864f42
to
42d6de6
Compare
42d6de6
to
6cbef25
Compare
6cbef25
to
bd6195f
Compare
/retest |
1 similar comment
/retest |
/hold |
@PillaiManish: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
This PR adds the NetworkPolicy for the operator:
Steps followed:
make generate