projectcalico / calico

Cloud native networking and network security
https://docs.tigera.io/calico/latest/about/
Apache License 2.0
6.04k stars 1.35k forks source link

Add missing permission for 'tiers' resources #9482

Closed sebhoss closed 6 days ago

sebhoss commented 1 week ago

Description

Allows calico-apiserver to handle tier resources.

Related issues/PRs

fixes #9481

Todos

Release Note

Add permission to Calico API server to create tier resources.

Reminder for the reviewer

Make sure that this PR has the correct labels and milestone set.

Every PR needs one docs-* label.

Every PR needs one release-note-* label.

Other optional labels:

sebhoss commented 1 week ago

wrt. testing: We are using conftest in our team to verify that k8s manifests have certain properties, e.g. in order to verify this change here, I've added the following to our internal test:

package main

import rego.v1

deny contains msg if {
    some resource in input

    role := resource.contents
    role.apiVersion == "rbac.authorization.k8s.io/v1"
    role.kind == "ClusterRole"
    role.metadata.name == "calico-crds"

    rules := [rule |
        some rule in role.rules
        rule.apiGroups == ["crd.projectcalico.org"]
        rule.resources[_] == "tiers"
        rule.verbs[_] == "create"
    ]

    count(rules) == 0

    msg := sprintf("ClusterRole '%v' does not allow to create tiers", [role.metadata.name])
}

This test is executed every time someone changes our internal copy of the calico-apiserver manifests and ensures that the missing permission is not missing :sweat_smile:

mazdakn commented 6 days ago

/sem-approve