Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added
- `runtimeClassName` and `automountServiceAccountToken` on the pod spec
- `networkPolicy.egress`: egress rules; non-empty adds `Egress` to `policyTypes`
- `checksum/env` and `checksum/secret-env` pod template annotations, so changes to `env` or `secretEnv` roll the pods
- `checksum/cf-path-filter` pod template annotation, so changes to the Cloudflare Tunnel `pathFilter` nginx config roll the pods

Expand Down
4 changes: 2 additions & 2 deletions Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ keywords:
- infisical
- secrets
type: application
version: 1.10.1
appVersion: "1.10.1"
version: 1.11.0
appVersion: "1.11.0"
maintainers:
- name: Artem Yakimenko
email: helm@temik.me
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ All configuration is done through `values.yaml`. See the file for full documenta
| `autoscaling.enabled` | Enable HorizontalPodAutoscaler (`autoscaling/v2`) | `false` |
| `hostNetwork.enabled` | Enable host networking | `false` |
| `strategy` | Rollout strategy (`RollingUpdate`/`Recreate` for Deployment; `RollingUpdate`/`OnDelete` for StatefulSet) | `{}` |
| `networkPolicy.enabled` | Create a NetworkPolicy restricting ingress traffic | `false` |
| `networkPolicy.enabled` | Create a NetworkPolicy restricting ingress traffic (and egress, with `networkPolicy.egress`) | `false` |
| `runtimeClassName` | Pod RuntimeClass, e.g. `gvisor` | `""` |
| `automountServiceAccountToken` | Set `false` to keep the API token out of the pod; `null` keeps the Kubernetes default | `null` |
| `extraServices` | Additional multi-port Service resources alongside port-derived services | `[]` |
| `env` / `secretEnv` | Environment variables rendered into a ConfigMap / a Secret | `{}` |
| `envFrom` | Extra `secretRef`/`configMapRef` entries for the main container | `[]` |
Expand Down Expand Up @@ -253,6 +255,30 @@ networkPolicy:
kubernetes.io/metadata.name: monitoring
```

`egress` is empty by default, which leaves egress unrestricted. Any rule adds
`Egress` to `policyTypes`, so traffic it doesn't list is denied, DNS included.
For example, DNS plus the public internet only:

```yaml
networkPolicy:
enabled: true
egress:
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: kube-system
podSelector:
matchLabels:
k8s-app: kube-dns
ports:
- { port: 53, protocol: UDP }
- { port: 53, protocol: TCP }
- to:
- ipBlock:
cidr: 0.0.0.0/0
except: [10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 100.64.0.0/10, 169.254.0.0/16]
```

### Extra Services (`extraServices`)

Create additional Service resources with custom port mappings (e.g. for UDP discovery protocols or mixed-type services).
Expand Down
10 changes: 10 additions & 0 deletions ci/statefulset-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,13 @@ volumes:
type: File
containerPath:
path: /etc/localtime
runtimeClassName: gvisor
automountServiceAccountToken: false
networkPolicy:
enabled: true
egress:
- to:
- ipBlock:
cidr: 0.0.0.0/0
except:
- 10.0.0.0/8
8 changes: 7 additions & 1 deletion templates/_helpers/_network_policy.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{/*
NetworkPolicy template
Restricts ingress traffic to the pod based on configured rules.
Restricts ingress traffic to the pod based on configured rules, and egress
too when egress rules are given.
*/}}
{{- define "hwl.networkPolicy" -}}
{{- $np := .Values.networkPolicy -}}
Expand All @@ -16,6 +17,11 @@ spec:
{{- include "hwl.selectorLabels" . | nindent 6 }}
policyTypes:
- Ingress
{{- with $np.egress }}
- Egress
egress:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if $np.ingress }}
ingress:
{{- range $np.ingress }}
Expand Down
6 changes: 6 additions & 0 deletions templates/_helpers/_pod.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ imagePullSecrets:
{{- toYaml . | nindent 2 }}
{{- end -}}
serviceAccountName: {{ include "hwl.serviceAccountName" . }}
{{- if not (kindIs "invalid" .Values.automountServiceAccountToken) }}
automountServiceAccountToken: {{ .Values.automountServiceAccountToken }}
{{- end }}
{{- with .Values.runtimeClassName }}
runtimeClassName: {{ . }}
{{- end }}
{{- if (.Values.shareProcessNamespace) }}
shareProcessNamespace: true
{{- end }}
Expand Down
17 changes: 17 additions & 0 deletions tests/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,20 @@ tests:
- equal:
path: spec.template.spec.containers[0].volumeMounts[0].readOnly
value: true
- it: should leave runtimeClassName and automountServiceAccountToken unset by default
asserts:
- notExists:
path: spec.template.spec.runtimeClassName
- notExists:
path: spec.template.spec.automountServiceAccountToken
- it: should set runtimeClassName and disable the service account token
set:
runtimeClassName: gvisor
automountServiceAccountToken: false
asserts:
- equal:
path: spec.template.spec.runtimeClassName
value: gvisor
- equal:
path: spec.template.spec.automountServiceAccountToken
value: false
46 changes: 46 additions & 0 deletions tests/network_policy_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,49 @@ tests:
- equal:
path: spec.ingress[0].ports[0].port
value: 443

- it: should leave egress unrestricted by default
set:
networkPolicy:
enabled: true
asserts:
- equal:
path: spec.policyTypes
value:
- Ingress
- notExists:
path: spec.egress

- it: should restrict egress to the given rules
set:
networkPolicy:
enabled: true
allowPortsIngress: false
egress:
- to:
- ipBlock:
cidr: 0.0.0.0/0
except:
- 10.0.0.0/8
ports:
- port: 443
protocol: TCP
asserts:
- equal:
path: spec.policyTypes
value:
- Ingress
- Egress
- equal:
path: spec.egress
value:
- to:
- ipBlock:
cidr: 0.0.0.0/0
except:
- 10.0.0.0/8
ports:
- port: 443
protocol: TCP
- isEmpty:
path: spec.ingress
24 changes: 23 additions & 1 deletion values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,19 @@
}
}
},
"runtimeClassName": {
"type": "string",
"default": "",
"description": "Pod RuntimeClass, e.g. gvisor. Empty uses the node default."
},
"automountServiceAccountToken": {
"type": ["boolean", "null"],
"default": null,
"description": "Set false to keep the API token out of the pod. Null leaves the Kubernetes default."
},
"networkPolicy": {
"type": "object",
"description": "NetworkPolicy configuration for restricting ingress traffic to the pod",
"description": "NetworkPolicy configuration for restricting ingress and, optionally, egress traffic of the pod",
"properties": {
"enabled": {
"type": "boolean",
Expand Down Expand Up @@ -589,6 +599,18 @@
}
}
}
},
"egress": {
"type": "array",
"default": [],
"description": "Egress rules (NetworkPolicy spec.egress). Empty leaves egress unrestricted; non-empty adds Egress to policyTypes and denies everything else.",
"items": {
"type": "object",
"properties": {
"ports": { "type": "array", "items": { "type": "object" } },
"to": { "type": "array", "items": { "type": "object" } }
}
}
}
}
},
Expand Down
13 changes: 13 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ health:
hostNetwork:
enabled: false

# Pod RuntimeClass, e.g. "gvisor". Empty uses the node default.
runtimeClassName: ""

# Set false to keep the API token out of the pod. Null leaves the Kubernetes default.
automountServiceAccountToken: null

networkPolicy:
enabled: false
# Automatically allow ingress on all ports defined in .Values.ports from anywhere.
Expand All @@ -202,6 +208,13 @@ networkPolicy:
# - podSelector:
# matchLabels:
# app: frontend
# Egress rules, rendered as spec.egress. Empty leaves egress unrestricted;
# non-empty adds Egress to policyTypes, so anything not listed is denied.
egress: []
# - to:
# - ipBlock:
# cidr: 0.0.0.0/0
# except: [10.0.0.0/8]

addons:
init:
Expand Down
Loading