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

Calico 3.29.1: OwnerReferences don't work for NetworkPolicies #9574

Open
alexarefev opened this issue Dec 9, 2024 · 0 comments
Open

Calico 3.29.1: OwnerReferences don't work for NetworkPolicies #9574

alexarefev opened this issue Dec 9, 2024 · 0 comments
Assignees

Comments

@alexarefev
Copy link

The OwnerReferences don't work for Calico NetworkPolicies. The Kubernetes cascading deletion doesn't work

Expected Behavior

ownerReferences option could be set in Calico NetworkPolicies to use cascading deletion for Kubernetes resources

Current Behavior

NetworkPolicies with ownerReferences are not deleted after the owner resource deletion

Possible Solution

Steps to Reproduce:

  1. Create Calico NetworkPolicy eg:
apiVersion: projectcalico.org/v3
kind: NetworkPolicy
metadata:
  name: allow-test
  labels:
    purpose: test
spec:
  ingress:
  - action: Allow
    destination:
      ports:
      - 5432
    protocol: TCP
    source:
      namespaceSelector: kubernetes.io/metadata.name in {'test-2','test-1'}
      selector: all()
  selector: all()
  types:
  - Ingress
  1. Get the UID of the NetworkPolicy above and put it into the following policy:
apiVersion: projectcalico.org/v3
kind: NetworkPolicy
metadata:
  name: default-deny
  labels:
    purpose: test
  ownerReferences:
  - apiVersion: projectcalico.org/v3
    blockOwnerDeletion: true
    controller: true
    kind: NetworkPolicy
    name: default.allow-test
    uid: b7a4ad0b-d25f-4ce3-89f7-ee825b565429
spec:
  selector: all()
  types:
    - Ingress
  1. Apply the second NetworkPolicy in the same Namespace
  2. Delete the allow-test NetworkPolicy
  3. Check if the default-deny policy has been deleted

Context

NetworkPolicies could not be included in logical chains with themself and other Kubernetes resources, which makes impossible to use one of the essential Kubernetes feature

Your Environment

  • Calico version 3.29.1
  • Calico dataplane (iptables, windows etc.)
  • Orchestrator version (e.g. kubernetes, mesos, rkt): Kubernetes 1.30.3
  • Operating System and version: Ubuntu 22.04
  • Link to your project (optional):
@caseydavenport caseydavenport self-assigned this Dec 11, 2024
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