Skip to content

Commit

Permalink
Merge pull request #435 from ishankhare07/fix-workload-namespace-isol…
Browse files Browse the repository at this point in the history
…ation

introduce isolation.targetNamespace in k0s, k3s, k8s chart values
  • Loading branch information
FabianKramm authored Apr 19, 2022
2 parents b17990c + 5719ee8 commit 3241bc7
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 27 deletions.
2 changes: 1 addition & 1 deletion charts/k0s/templates/limitrange.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v1
kind: LimitRange
metadata:
name: {{ .Release.Name }}-limit-range
namespace: {{ .Release.Namespace }}
namespace: {{ .Values.isolation.namespace | default .Release.Namespace }}
spec:
limits:
- default:
Expand Down
12 changes: 5 additions & 7 deletions charts/k0s/templates/networkpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ .Release.Name }}-workloads
namespace: {{ .Release.Namespace }}
namespace: {{ .Values.isolation.namespace | default .Release.Namespace }}
spec:
podSelector:
matchLabels:
Expand All @@ -30,13 +30,11 @@ spec:
matchLabels:
vcluster.loft.sh/managed-by: {{ .Release.Name }}
- ipBlock:
cidr: 0.0.0.0/0
cidr: {{ .Values.isolation.networkPolicy.outgoingConnections.ipBlock.cidr }}
except:
- 100.64.0.0/10
- 127.0.0.0/8
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
{{- range .Values.isolation.networkPolicy.outgoingConnections.ipBlock.except }}
- {{ . }}
{{- end }}
policyTypes:
- Egress
---
Expand Down
2 changes: 1 addition & 1 deletion charts/k0s/templates/resourcequota.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v1
kind: ResourceQuota
metadata:
name: {{ .Release.Name }}-quota
namespace: {{ .Release.Namespace }}
namespace: {{ .Values.isolation.namespace | default .Release.Namespace }}
spec:
hard:
{{- range $key, $val := .Values.isolation.resourceQuota.quota }}
Expand Down
10 changes: 10 additions & 0 deletions charts/k0s/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ coredns:
# standards, limit ranges and resource quotas
isolation:
enabled: false
namespace: null

podSecurityStandard: baseline

Expand Down Expand Up @@ -280,3 +281,12 @@ isolation:

networkPolicy:
enabled: true
outgoingConnections:
ipBlock:
cidr: 0.0.0.0/0
except:
- 100.64.0.0/10
- 127.0.0.0/8
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
2 changes: 1 addition & 1 deletion charts/k3s/templates/limitrange.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v1
kind: LimitRange
metadata:
name: {{ .Release.Name }}-limit-range
namespace: {{ .Release.Namespace }}
namespace: {{ .Values.isolation.namespace | default .Release.Namespace }}
spec:
limits:
- default:
Expand Down
12 changes: 5 additions & 7 deletions charts/k3s/templates/networkpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ .Release.Name }}-workloads
namespace: {{ .Release.Namespace }}
namespace: {{ .Values.isolation.namespace | default .Release.Namespace }}
spec:
podSelector:
matchLabels:
Expand All @@ -30,13 +30,11 @@ spec:
matchLabels:
vcluster.loft.sh/managed-by: {{ .Release.Name }}
- ipBlock:
cidr: 0.0.0.0/0
cidr: {{ .Values.isolation.networkPolicy.outgoingConnections.ipBlock.cidr }}
except:
- 100.64.0.0/10
- 127.0.0.0/8
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
{{- range .Values.isolation.networkPolicy.outgoingConnections.ipBlock.except }}
- {{ . }}
{{- end }}
policyTypes:
- Egress
---
Expand Down
2 changes: 1 addition & 1 deletion charts/k3s/templates/resourcequota.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v1
kind: ResourceQuota
metadata:
name: {{ .Release.Name }}-quota
namespace: {{ .Release.Namespace }}
namespace: {{ .Values.isolation.namespace | default .Release.Namespace }}
spec:
hard:
{{- range $key, $val := .Values.isolation.resourceQuota.quota }}
Expand Down
10 changes: 10 additions & 0 deletions charts/k3s/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ coredns:
# standards, limit ranges and resource quotas
isolation:
enabled: false
namespace: null

podSecurityStandard: baseline

Expand Down Expand Up @@ -282,3 +283,12 @@ isolation:

networkPolicy:
enabled: true
outgoingConnections:
ipBlock:
cidr: 0.0.0.0/0
except:
- 100.64.0.0/10
- 127.0.0.0/8
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
2 changes: 1 addition & 1 deletion charts/k8s/templates/limitrange.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v1
kind: LimitRange
metadata:
name: {{ .Release.Name }}-limit-range
namespace: {{ .Release.Namespace }}
namespace: {{ .Values.isolation.namespace | default .Release.Namespace }}
spec:
limits:
- default:
Expand Down
12 changes: 5 additions & 7 deletions charts/k8s/templates/networkpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ .Release.Name }}-workloads
namespace: {{ .Release.Namespace }}
namespace: {{ .Values.isolation.namespace | default .Release.Namespace }}
spec:
podSelector:
matchLabels:
Expand All @@ -30,13 +30,11 @@ spec:
matchLabels:
vcluster.loft.sh/managed-by: {{ .Release.Name }}
- ipBlock:
cidr: 0.0.0.0/0
cidr: {{ .Values.isolation.networkPolicy.outgoingConnections.ipBlock.cidr }}
except:
- 100.64.0.0/10
- 127.0.0.0/8
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
{{- range .Values.isolation.networkPolicy.outgoingConnections.ipBlock.except }}
- {{ . }}
{{- end }}
policyTypes:
- Egress
---
Expand Down
2 changes: 1 addition & 1 deletion charts/k8s/templates/resourcequota.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v1
kind: ResourceQuota
metadata:
name: {{ .Release.Name }}-quota
namespace: {{ .Release.Namespace }}
namespace: {{ .Values.isolation.namespace | default .Release.Namespace }}
spec:
hard:
{{- range $key, $val := .Values.isolation.resourceQuota.quota }}
Expand Down
10 changes: 10 additions & 0 deletions charts/k8s/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ coredns:
# standards, limit ranges and resource quotas
isolation:
enabled: false
namespace: null

podSecurityStandard: baseline

Expand Down Expand Up @@ -311,3 +312,12 @@ isolation:

networkPolicy:
enabled: true
outgoingConnections:
ipBlock:
cidr: 0.0.0.0/0
except:
- 100.64.0.0/10
- 127.0.0.0/8
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16

0 comments on commit 3241bc7

Please sign in to comment.