Skip to content

Commit 9b99c28

Browse files
committed
Merge remote-tracking branch 'upstream/main' into 2025/add/fluentd
2 parents 9100654 + 6e2267b commit 9b99c28

File tree

23 files changed

+378
-77
lines changed

23 files changed

+378
-77
lines changed

charts/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ values.yaml
22
values.*.yaml
33
k8s_hosts.ini
44
helmfile.y?ml
5+
6+
*.tgz

charts/adminer/templates/deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ spec:
1313
{{- include "adminer.selectorLabels" . | nindent 6 }}
1414
template:
1515
metadata:
16-
{{- with .Values.podAnnotations }}
16+
{{- if .Values.podAnnotations }}
1717
annotations:
18-
{{- toYaml . | nindent 8 }}
18+
{{- tpl (toYaml .Values.podAnnotations) . | nindent 8 }}
1919
{{- end }}
2020
labels:
2121
{{- include "adminer.labels" . | nindent 8 }}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: projectcalico.org/v3
2+
kind: NetworkPolicy
3+
metadata:
4+
name: adminer-network-policy
5+
labels:
6+
{{- include "adminer.labels" . | nindent 4 }}
7+
spec:
8+
selector: app.kubernetes.io/instance == "{{ .Release.Name }}"
9+
ingress:
10+
- action: Allow
11+
protocol: TCP
12+
destination:
13+
ports:
14+
- {{ .Values.service.port }}
15+
egress:
16+
- action: Allow
17+
protocol: TCP
18+
destination:
19+
ports:
20+
- 5432

charts/adminer/values.yaml.gotmpl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ serviceAccount:
2525
# If not set and create is true, a name is generated using the fullname template
2626
name: ""
2727

28-
podAnnotations: {}
28+
podAnnotations:
29+
# automatically restart pod on network policy change (to be sure new rules are applied)
30+
checksum/networkpolicy: '{{`{{ include (print $.Template.BasePath "/networkpolicy.yaml") . | sha256sum }}`}}'
2931
podLabels: {}
3032

3133
podSecurityContext:
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: calico-configuration
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.0.1
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "3.26.4"
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
## How to add network policy (local deployment)
2+
3+
How to discover ports / networks that are used by application
4+
* observe existing traffic (see `Debug network policies` below)
5+
* add staged policies to make sure all cases are included https://docs.tigera.io/calico/3.30/network-policy/staged-network-policies
6+
- make sure deployed calico version supports it
7+
* based on observations, create a needed network policy
8+
9+
## Debug network policies
10+
11+
if calico version 3.30+ is installed
12+
* observe traffic and check `policies` field in whisker logs
13+
- https://docs.tigera.io/calico/3.30/observability/enable-whisker
14+
- https://docs.tigera.io/calico/3.30/observability/view-flow-logs
15+
16+
if calico version <= 3.29
17+
* create network policy with action log (read more https://docs.tigera.io/calico/latest/network-policy/policy-rules/log-rules)
18+
```yaml
19+
apiVersion: projectcalico.org/v3
20+
kind: NetworkPolicy
21+
metadata:
22+
name: log ingress requests
23+
spec:
24+
selector: app == 'db'
25+
ingress:
26+
- action: Log
27+
```
28+
* apply policy and see logs via journalctl (you can grep with `calico-packet` on the node where the pod is running)
29+
* Note: one may implement policy step by step (allowing all traffic that is known and making last rule `Log` to see what traffic is still missing)
30+
31+
## Known issues
32+
33+
If network policy is created after pod, pod **MUST** be restarted for policy to take effect. Read more https://github.com/projectcalico/calico/issues/10753#issuecomment-3140717418
34+
* To automate this, we can add annotations with network policy checksum to pods (see https://stackoverflow.com/questions/58602311/will-helm-upgrade-restart-pods-even-if-they-are-not-affected-by-upgrade)
35+
36+
## How to view existing policies
37+
38+
via kubectl:
39+
* `kubectl get networkpolicies.crd.projectcalico.org -n adminer`
40+
* `kubectl describe networkpolicies.crd.projectcalico.org -n adminer default.adminer-network-policy`
41+
42+
via calicoctl:
43+
* `calicoctl get networkpolicy -n adminer -o yaml`
44+
45+
Note:
46+
* global network policies and network policies are separate resources for calico
47+
* To see all calico resources execute `kubectl get crd | grep calico` or `calicoctl get --help`
48+
49+
Warning:
50+
* Network policies update are only applied to "new connections". To make them act, one may need to restart affected applications (pods)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This chart configures Calico but does not deploy Calico itself. Calico is deployed during the Kubernetes cluster creation.
2+
3+
Note: to make sure network policies are applied correctly, you may need to restart targeted application pods.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Source: https://docs.tigera.io/calico/3.30/network-policy/get-started/kubernetes-default-deny
2+
apiVersion: projectcalico.org/v3
3+
kind: GlobalNetworkPolicy
4+
metadata:
5+
name: default-global-deny-network-policy
6+
spec:
7+
# "kube-public", "kube-system", "kube-node-lease" -- system namespaces
8+
# "calico-system", "calico-apiserver", "tigera-operator" -- calico namespaces (when installed via scripts [local deployment])
9+
# TODO: other namespaces are to be removed from this list (once appropriate network policies are created)
10+
namespaceSelector:
11+
kubernetes.io/metadata.name not in {"kube-public", "kube-system", "kube-node-lease", "calico-system", "calico-apiserver", "tigera-operator", "cert-manager", "reflector", "traefik", "victoria-logs", "csi-s3", "portainer", "topolvm", "local-path-storage", "longhorn"}
12+
types:
13+
- Ingress
14+
- Egress
15+
egress:
16+
# allow all namespaces to communicate to DNS pods
17+
# this will also apply to pods that have network policy defined
18+
# so that we don't need to define DNS policy for each pod
19+
- action: Allow
20+
protocol: UDP
21+
destination:
22+
selector: 'k8s-app == "kube-dns"'
23+
ports:
24+
- 53
25+
# nodelocaldns: https://github.com/kubernetes/kubernetes/blob/master/cluster/addons/dns/nodelocaldns/README.md#nodelocal-dns-cache
26+
# IP from https://github.com/kubernetes-sigs/kubespray/blob/v2.24.1/roles/kubespray-defaults/defaults/main/main.yml#L108
27+
- action: Allow
28+
protocol: UDP
29+
nets:
30+
- 169.254.25.10/32
31+
ports:
32+
- 53
33+
- action: Allow
34+
protocol: TCP
35+
destination:
36+
selector: 'k8s-app == "kube-dns"'
37+
ports:
38+
- 53
39+
- action: Allow
40+
protocol: TCP
41+
nets:
42+
- 169.254.25.10/32
43+
ports:
44+
- 53

charts/portainer/Chart.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dependencies:
2+
- name: portainer
3+
repository: https://portainer.github.io/k8s/
4+
version: 1.0.54
5+
digest: sha256:bafe4182881aee8c6df3d3c6f8c523a1bd7577bed04942ad3d9b857a5437d96f
6+
generated: "2025-07-29T11:07:15.39037387+02:00"

0 commit comments

Comments
 (0)