-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: kubeapi netpol initialization / support for ingress policies (#1097
) ## Description Fixes some issues with the netpol update logic to ensure we are accounting for ingress policies, as well as ensuring this only runs on watcher pods. Also adds jest test coverage of this function. ## Related Issue Fixes #1101 ## Steps to Validate The primary fix here has to do with Pepr crashing on startup when an `Ingress` kubeapi policy is present. The below section steps through testing this. <details> <summary>Validation Steps</summary> ```console # Deploy base layer (using unicorn flavor to avoid dockerhub rate limiting) uds run test-single-layer --set LAYER=base --set FLAVOR=unicorn # Create a namespace for our test package kubectl create ns test # Create a package CR with egress and ingress kubeapi policies cat <<EOF | kubectl apply -f - apiVersion: uds.dev/v1alpha1 kind: Package metadata: name: test namespace: test spec: network: allow: - direction: Egress selector: app.kubernetes.io/name: test remoteGenerated: KubeAPI - direction: Ingress selector: app.kubernetes.io/name: test remoteGenerated: KubeAPI EOF # Validate netpols show up as expected kubectl get networkpolicies -n test -o custom-columns="NAME:.metadata.name,INGRESS:.spec.ingress[].from[].ipBlock.cidr,EGRESS:.spec.egress[].to[].ipBlock.cidr" | grep kubeapi # Cycle the pepr watcher pod (this is where pepr previously would crash, on startup when an ingress kubeapi policy was present) kubectl delete po -n pepr-system -l app=pepr-uds-core-watcher # Make sure pepr starts up as expected # You could continue to stress test the logic by modifying the kubeapi netpols specs to be missing some fields, etc. # Also worth reviewing the jest tests which should provide coverage of almost all situations at this point ``` </details> ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Other (security config, docs update, etc) ## Checklist before merging - [x] Test, docs, adr added or updated as needed - [x] [Contributor Guide](https://github.com/defenseunicorns/uds-template-capability/blob/main/CONTRIBUTING.md) followed --------- Co-authored-by: Chance <[email protected]>
- Loading branch information
1 parent
f87a96d
commit 620e6b2
Showing
4 changed files
with
372 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.