Skip to content

Backport of Add support for setting the namespace that the CNI plugin is installed into release/1.0.x#1757

Merged
kschoche merged 2 commits intorelease/1.0.xfrom
backport/allow_cni_namespacing/gratefully-fond-fly
Nov 30, 2022
Merged

Backport of Add support for setting the namespace that the CNI plugin is installed into release/1.0.x#1757
kschoche merged 2 commits intorelease/1.0.xfrom
backport/allow_cni_namespacing/gratefully-fond-fly

Conversation

@hc-github-team-consul-ecosystem
Copy link
Copy Markdown
Contributor

Backport

This PR is auto-generated from #1756 to be assessed for backporting due to the inclusion of the label backport/1.0.x.

WARNING automatic cherry-pick of commits failed. Commits will require human attention.

merge conflict error: POST https://api.github.com/repos/hashicorp/consul-k8s/merges: 409 Merge conflict []

The below text is copied from the body of the original PR.


Kubernetes 1.25 uses the PSA system which controls pod security standards at the namespace level.
The CNI plugin requires elevated permissions which would otherwise interfere with setting the rest of the consul-k8s resources compliant with restricted modes of the PSA.
By allowing the CNI plugin to be installed into another namespace, like kube-system or consul-system we can still run the rest of Consul in restricted mode while the CNI plugin runs in another elevated namespace.
This is a common workflow for other CNI plugins:

demo $ k get pods -A
NAMESPACE            NAME                                        READY   STATUS    RESTARTS      AGE
calico-apiserver     calico-apiserver-db5d9d654-hlf62            1/1     Running   0             19h
calico-apiserver     calico-apiserver-db5d9d654-w5ljk            1/1     Running   0             19h
calico-system        calico-kube-controllers-5d95c5d5fb-7vm9h    1/1     Running   0             19h
calico-system        calico-node-9tglm                           1/1     Running   0             19h
calico-system        calico-typha-664b86ccfd-bs65l               1/1     Running   0             19h
calico-system        csi-node-driver-tftld                       2/2     Running   0             19h

Changes proposed in this PR:

  • Introduces a new field namespace into the connectInject.cni stanza which controls which namespace CNI related resources are installed in.

How I've tested this PR:
Unit tests + manually test by installing the plugin:

$ cat x.yaml
connectInject:
  enabled: true
  cni:
    enabled: true
    namespace: kube-system

$ helm install consul /Users/kyle/go/src/github.com/hashicorp/consul-k8s/charts/consul -f x.yaml
<snip>

$ k get pods -A
NAMESPACE            NAME                                        READY   STATUS    RESTARTS      AGE
calico-apiserver     calico-apiserver-db5d9d654-hlf62            1/1     Running   0             20h
calico-apiserver     calico-apiserver-db5d9d654-w5ljk            1/1     Running   0             20h
calico-system        calico-kube-controllers-5d95c5d5fb-7vm9h    1/1     Running   0             20h
calico-system        calico-node-9tglm                           1/1     Running   0             20h
calico-system        calico-typha-664b86ccfd-bs65l               1/1     Running   0             20h
calico-system        csi-node-driver-tftld                       2/2     Running   0             20h
kube-system          consul-consul-cni-94n62                     1/1     Running   0             13s

Note to Reviewers:

  • Is there anything in the consul-k8s cli that might need to change for this?

How I expect reviewers to test this PR:
👀

Checklist:

  • Tests added
  • CHANGELOG entry added

    HashiCorp engineers only, community PRs should not add a changelog entry.
    Entries should use present tense (e.g. Add support for...)


Overview of commits

@hc-github-team-consul-ecosystem hc-github-team-consul-ecosystem force-pushed the backport/allow_cni_namespacing/gratefully-fond-fly branch from 9d1b8dc to 2ac0ae2 Compare November 30, 2022 20:04
@kschoche kschoche requested a review from david-yu November 30, 2022 20:05
@kschoche kschoche self-assigned this Nov 30, 2022
@kschoche kschoche marked this pull request as ready for review November 30, 2022 20:06
Copy link
Copy Markdown
Contributor

@david-yu david-yu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In favor of the backport here to allow us to support PSA in 1.0.x for k8s 1.25.x

@kschoche kschoche merged commit 509b63b into release/1.0.x Nov 30, 2022
@kschoche kschoche deleted the backport/allow_cni_namespacing/gratefully-fond-fly branch November 30, 2022 20:33
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

Successfully merging this pull request may close these issues.

3 participants