Skip to content

Commit 2f820f7

Browse files
[Backport release-1.6] fix(tenant): skip Cilium policies on isp-hosted without Cilium (#5080)
## What this PR does Backport of #4710 to release-1.6. - The traces-central templates do not exist on release-1.6, so their hunks and the matching unit-test assertions are dropped, a test case that relied on a main-only cozy-lib change uses `_cluster: {}` instead. ### Screenshots Not a UI change. ### Downstream repositories - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: ### Release note ```release-note fix(tenant): the tenant chart no longer fails to install on the isp-hosted variants when the host has no Cilium. There, the Cilium network policies are created only if the host serves the Cilium policy API; otherwise tenants get no network isolation from Cozystack. Other variants are unchanged. ```
2 parents 86c6c4f + 4f8c0a6 commit 2f820f7

6 files changed

Lines changed: 87 additions & 0 deletions

File tree

‎docs/security/self-assessment.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ Actors are decomposed by **trust boundary**: two components are distinct actors
9393
- **Upstream-only vulnerabilities** not introduced or worsened by Cozystack packaging or defaults.
9494
- **Ingress-side isolation of tenant pods.** Tenant-pod ingress is open to `world` and `cluster`, so a tenant pod is reachable by any in-cluster peer whose own egress permits it (platform components) or by a workload not governed by Cozystack's tenant egress policies. Cross-tenant isolation is enforced on the *egress* side, not tenant-pod ingress.
9595
- **Blocking cross-tenant reachability through externally-exposed services.** If a tenant publishes a LoadBalancer external IP, another tenant can reach it via `world` egress.
96+
- **Network isolation between tenants on a hosted cluster without Cilium.** On the `isp-hosted` and `isp-hosted-slim` variants the CNI belongs to the host, and tenant Cilium policies are created only if the host serves the Cilium policy API. Without it, tenants get no network isolation from Cozystack, and isolating them is up to the host.
9697
- **Noisy-neighbour / side-channel** guarantees for co-located tenant pods beyond namespace scoping (and, for tenant Kubernetes/VMs, virtualization).
9798
- Acting as an **egress firewall**: tenant workloads may egress to `world` by default.
9899
- Supporting **pre-release builds and end-of-life versions**.

‎docs/security/threat-model.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ The following are explicitly out of scope for the platform's security guarantees
8383
- **Upstream-only vulnerabilities** that Cozystack packaging and defaults do not introduce or worsen.
8484
- **Ingress-side isolation of tenant pods.** Tenant-pod ingress is open to the `world` and `cluster` entities, so a tenant pod is reachable by any in-cluster peer whose own egress permits it (platform components) and by a workload not governed by Cozystack's tenant egress policies (e.g. a privileged or system pod). Cross-tenant isolation is enforced on the *egress* side, not on tenant-pod ingress.
8585
- **Blocking cross-tenant reachability through externally-exposed services.** If a tenant publishes a LoadBalancer with an external IP, another tenant can reach it via `world` egress.
86+
- **Network isolation between tenants on a hosted cluster without Cilium.** On the `isp-hosted` and `isp-hosted-slim` variants the CNI belongs to the host, and the tenant chart creates its Cilium policies only if the host serves the Cilium policy API (`packages/apps/tenant/templates/_helpers.tpl`, helper `tenant.ciliumPolicies`). Without it, tenants get no network isolation from Cozystack, and isolating them is up to the host.
8687
- **Noisy-neighbour and side-channel guarantees** for co-located tenant pods beyond namespace scoping (and, for tenant Kubernetes/VMs, virtualization). Co-located pods are not claimed to be side-channel isolated.
8788
- **Acting as an egress firewall.** Tenant workloads are allowed egress to `world` by default (`packages/apps/tenant/templates/networkpolicy.yaml`).
8889
- **Supporting pre-release builds and end-of-life versions** (`SECURITY.md`).

‎packages/apps/tenant/README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ tenant-u1
7070
└── postgres-db1
7171
```
7272

73+
### Network isolation
74+
75+
Tenant network isolation is enforced with Cilium network policies. On the `isp-hosted` and `isp-hosted-slim` platform variants the CNI belongs to the host, so these policies are created only if the host serves the Cilium policy API when the tenant is installed or updated. On a host without Cilium, tenants get no network isolation from Cozystack, and isolating them is up to the host. If Cilium appears on the host later, the policies are created on the tenant's next chart or values change, not automatically.
76+
7377
## Parameters
7478

7579
### Common parameters

‎packages/apps/tenant/templates/_helpers.tpl‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,16 @@ false
9292
{{- if .Values.gateway -}}true{{- else -}}false{{- end -}}
9393
{{- end -}}
9494
{{- end -}}
95+
96+
{{- /* Every variant but the isp-hosted ones installs Cilium itself, so the
97+
policies render unconditionally there: a CRD missing at render time
98+
must fail the install, not leave the tenant unisolated for good, since
99+
helm-controller does not re-render a release when discovery changes.
100+
isp-hosted runs on the host's CNI, which may or may not be Cilium. */ -}}
101+
{{- define "tenant.ciliumPolicies" -}}
102+
{{- if not (has (include "cozy-lib.bundle-name" .) (list "isp-hosted" "isp-hosted-slim")) -}}
103+
true
104+
{{- else if and (.Capabilities.APIVersions.Has "cilium.io/v2/CiliumNetworkPolicy") (.Capabilities.APIVersions.Has "cilium.io/v2/CiliumClusterwideNetworkPolicy") -}}
105+
true
106+
{{- end -}}
107+
{{- end -}}

‎packages/apps/tenant/templates/networkpolicy.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if include "tenant.ciliumPolicies" . }}
12
---
23
apiVersion: cilium.io/v2
34
kind: CiliumNetworkPolicy
@@ -274,3 +275,4 @@ spec:
274275
- toEndpoints:
275276
- matchLabels:
276277
cozystack.io/service: ingress
278+
{{- end }}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
suite: tenant Cilium policies follow the platform variant's CNI
2+
templates:
3+
- templates/networkpolicy.yaml
4+
release:
5+
name: tenant-ktj
6+
namespace: tenant-root
7+
tests:
8+
- it: renders no Cilium objects on isp-hosted without the cilium.io API
9+
set:
10+
_cluster:
11+
bundle-name: isp-hosted
12+
asserts:
13+
- hasDocuments:
14+
count: 0
15+
16+
- it: renders no Cilium objects on isp-hosted-slim without the cilium.io API
17+
set:
18+
_cluster:
19+
bundle-name: isp-hosted-slim
20+
asserts:
21+
- hasDocuments:
22+
count: 0
23+
24+
- it: renders no Cilium objects on isp-hosted when only one Cilium kind is served
25+
set:
26+
_cluster:
27+
bundle-name: isp-hosted
28+
capabilities:
29+
apiVersions:
30+
- cilium.io/v2/CiliumNetworkPolicy
31+
asserts:
32+
- hasDocuments:
33+
count: 0
34+
35+
- it: renders the Cilium policies on isp-hosted when the host runs Cilium
36+
set:
37+
_cluster:
38+
bundle-name: isp-hosted
39+
capabilities:
40+
apiVersions:
41+
- cilium.io/v2/CiliumNetworkPolicy
42+
- cilium.io/v2/CiliumClusterwideNetworkPolicy
43+
asserts: &policiesRendered
44+
- template: templates/networkpolicy.yaml
45+
documentSelector:
46+
path: metadata.name
47+
value: allow-internal-communication
48+
isKind:
49+
of: CiliumNetworkPolicy
50+
- template: templates/networkpolicy.yaml
51+
documentSelector:
52+
path: metadata.name
53+
value: tenant-ktj-ingress
54+
isKind:
55+
of: CiliumClusterwideNetworkPolicy
56+
57+
- it: renders the Cilium policies on a Cilium variant even when the API is not discoverable
58+
set:
59+
_cluster:
60+
bundle-name: isp-full
61+
asserts: *policiesRendered
62+
63+
- it: renders the Cilium policies when the platform injected no bundle-name
64+
set:
65+
_cluster: {}
66+
asserts: *policiesRendered

0 commit comments

Comments
 (0)