-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for network policy (#46)
- Loading branch information
Showing
6 changed files
with
148 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ jobs: | |
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.9' | ||
python-version: "3.9" | ||
check-latest: true | ||
|
||
# - name: Run helm lint | ||
|
@@ -47,15 +47,24 @@ jobs: | |
run: | | ||
changed=$(ct list-changed --config ct.yaml --target-branch ${{ github.event.repository.default_branch }}) | ||
if [[ -n "$changed" ]]; then | ||
echo "::set-output name=changed::true" | ||
echo "changed=true" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Run chart-testing (lint) | ||
run: ct lint --config ct.yaml --target-branch ${{ github.event.repository.default_branch }} --check-version-increment=false | ||
|
||
- name: Create kind cluster | ||
if: steps.list-changed.outputs.changed == 'true' | ||
uses: helm/[email protected] | ||
with: | ||
config: kind-cluster.yaml | ||
|
||
- name: Install Calico | ||
if: steps.list-changed.outputs.changed == 'true' | ||
run: | | ||
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.24.5/manifests/calico.yaml | ||
kubectl -n kube-system rollout status daemonset/calico-node --timeout=120s | ||
kubectl -n kube-system rollout status deployment calico-kube-controllers --timeout=120s | ||
- name: Fix CoreDNS upstream resolver | ||
if: steps.list-changed.outputs.changed == 'true' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
networking: | ||
disableDefaultCNI: true # disable kindnet | ||
podSubnet: 192.168.0.0/16 # set to Calico's default subnet | ||
nodes: | ||
- role: control-plane | ||
kubeadmConfigPatches: | ||
- | | ||
kind: InitConfiguration | ||
nodeRegistration: | ||
kubeletExtraArgs: | ||
node-labels: "ingress-ready=true" | ||
extraPortMappings: | ||
- containerPort: 80 | ||
hostPort: 80 | ||
protocol: TCP | ||
- containerPort: 443 | ||
hostPort: 443 | ||
protocol: TCP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
{{- if and .Values.networkPolicy.enabled }} | ||
--- | ||
apiVersion: {{ include "common.capabilities.networkPolicy.apiVersion" . }} | ||
kind: NetworkPolicy | ||
metadata: | ||
name: {{ printf "%s-default-deny" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: {{- include "common.labels.standard" . | nindent 4 }} | ||
{{- if .Values.commonLabels }} | ||
{{- include "common.tplvalues.render" (dict "value" .Values.commonLabels "context" $) | nindent 4 }} | ||
{{- end }} | ||
{{- if .Values.commonAnnotations }} | ||
annotations: {{- include "common.tplvalues.render" (dict "value" .Values.commonAnnotations "context" $) | nindent 4 }} | ||
{{- end }} | ||
spec: | ||
podSelector: | ||
matchLabels: | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
policyTypes: | ||
- Ingress | ||
- Egress | ||
--- | ||
apiVersion: {{ include "common.capabilities.networkPolicy.apiVersion" . }} | ||
kind: NetworkPolicy | ||
metadata: | ||
name: {{ printf "%s-allow-egress-all" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: {{- include "common.labels.standard" . | nindent 4 }} | ||
{{- if .Values.commonLabels }} | ||
{{- include "common.tplvalues.render" (dict "value" .Values.commonLabels "context" $) | nindent 4 }} | ||
{{- end }} | ||
{{- if .Values.commonAnnotations }} | ||
annotations: {{- include "common.tplvalues.render" (dict "value" .Values.commonAnnotations "context" $) | nindent 4 }} | ||
{{- end }} | ||
spec: | ||
podSelector: | ||
matchLabels: | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
policyTypes: | ||
- Egress | ||
egress: | ||
- {} | ||
--- | ||
--- | ||
apiVersion: {{ include "common.capabilities.networkPolicy.apiVersion" . }} | ||
kind: NetworkPolicy | ||
metadata: | ||
name: {{ printf "%s-allow-front" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: {{- include "common.labels.standard" . | nindent 4 }} | ||
{{- if .Values.commonLabels }} | ||
{{- include "common.tplvalues.render" (dict "value" .Values.commonLabels "context" $) | nindent 4 }} | ||
{{- end }} | ||
{{- if .Values.commonAnnotations }} | ||
annotations: {{- include "common.tplvalues.render" (dict "value" .Values.commonAnnotations "context" $) | nindent 4 }} | ||
{{- end }} | ||
spec: | ||
podSelector: | ||
matchLabels: | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
app.kubernetes.io/component: front | ||
ingress: | ||
# Allow ports 25/TCP, 80/TCP, 110/TCP, 143/TCP, 443/TCP, 465/TCP, 587/TCP, 995/TCP, 993/TCP | ||
- ports: | ||
- port: 25 | ||
protocol: TCP | ||
- port: 80 | ||
protocol: TCP | ||
- port: 110 | ||
protocol: TCP | ||
- port: 143 | ||
protocol: TCP | ||
- port: 443 | ||
protocol: TCP | ||
- port: 465 | ||
protocol: TCP | ||
- port: 587 | ||
protocol: TCP | ||
- port: 995 | ||
protocol: TCP | ||
- port: 993 | ||
protocol: TCP | ||
--- | ||
apiVersion: {{ include "common.capabilities.networkPolicy.apiVersion" . }} | ||
kind: NetworkPolicy | ||
metadata: | ||
name: {{ printf "%s-allow-internal" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: {{- include "common.labels.standard" . | nindent 4 }} | ||
{{- if .Values.commonLabels }} | ||
{{- include "common.tplvalues.render" (dict "value" .Values.commonLabels "context" $) | nindent 4 }} | ||
{{- end }} | ||
{{- if .Values.commonAnnotations }} | ||
annotations: {{- include "common.tplvalues.render" (dict "value" .Values.commonAnnotations "context" $) | nindent 4 }} | ||
{{- end }} | ||
spec: | ||
podSelector: | ||
matchLabels: | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
ingress: | ||
- from: | ||
- namespaceSelector: | ||
matchLabels: | ||
kubernetes.io/metadata.name: {{ .Release.Namespace }} | ||
podSelector: | ||
matchLabels: | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters