feat(network policy): add network policy into chart
ref: longhorn/longhor 5403 Signed-off-by: Jack Lin <jack.lin@suse.com>
This commit is contained in:
parent
77392d6ad8
commit
8364519d61
@ -843,3 +843,21 @@ Set the value to **0** to disable backup restore."
|
|||||||
label: Rancher Windows Cluster
|
label: Rancher Windows Cluster
|
||||||
type: boolean
|
type: boolean
|
||||||
group: "Other Settings"
|
group: "Other Settings"
|
||||||
|
- variable: networkPolicies.enabled
|
||||||
|
description: "Enable NetworkPolicies to limit access to the longhorn pods.
|
||||||
|
Warning: The Rancher Proxy will not work if this feature is enabled and a custom NetworkPolicy must be added."
|
||||||
|
group: "Other Settings"
|
||||||
|
label: Network Policies
|
||||||
|
default: "false"
|
||||||
|
type: boolean
|
||||||
|
subquestions:
|
||||||
|
- variable: networkPolicies.type
|
||||||
|
label: Network Policies for Ingress
|
||||||
|
description: "Create the policy to allow access for the ingress, select the distribution."
|
||||||
|
show_if: "networkPolicies.enabled=true&&ingress.enabled=true"
|
||||||
|
type: enum
|
||||||
|
default: "rke2"
|
||||||
|
options:
|
||||||
|
- "rke1"
|
||||||
|
- "rke2"
|
||||||
|
- "k3s"
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
{{- if .Values.networkPolicies.enabled }}
|
||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: NetworkPolicy
|
||||||
|
metadata:
|
||||||
|
name: backing-image-data-source
|
||||||
|
namespace: longhorn-system
|
||||||
|
spec:
|
||||||
|
podSelector:
|
||||||
|
matchLabels:
|
||||||
|
longhorn.io/component: backing-image-data-source
|
||||||
|
policyTypes:
|
||||||
|
- Ingress
|
||||||
|
ingress:
|
||||||
|
- from:
|
||||||
|
- podSelector:
|
||||||
|
matchLabels:
|
||||||
|
app: longhorn-manager
|
||||||
|
- podSelector:
|
||||||
|
matchLabels:
|
||||||
|
longhorn.io/component: instance-manager
|
||||||
|
- podSelector:
|
||||||
|
matchLabels:
|
||||||
|
longhorn.io/component: backing-image-manager
|
||||||
|
- podSelector:
|
||||||
|
matchLabels:
|
||||||
|
longhorn.io/component: backing-image-data-source
|
||||||
|
{{- end }}
|
@ -0,0 +1,27 @@
|
|||||||
|
{{- if .Values.networkPolicies.enabled }}
|
||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: NetworkPolicy
|
||||||
|
metadata:
|
||||||
|
name: backing-image-manager
|
||||||
|
namespace: longhorn-system
|
||||||
|
spec:
|
||||||
|
podSelector:
|
||||||
|
matchLabels:
|
||||||
|
longhorn.io/component: backing-image-manager
|
||||||
|
policyTypes:
|
||||||
|
- Ingress
|
||||||
|
ingress:
|
||||||
|
- from:
|
||||||
|
- podSelector:
|
||||||
|
matchLabels:
|
||||||
|
app: longhorn-manager
|
||||||
|
- podSelector:
|
||||||
|
matchLabels:
|
||||||
|
longhorn.io/component: instance-manager
|
||||||
|
- podSelector:
|
||||||
|
matchLabels:
|
||||||
|
longhorn.io/component: backing-image-manager
|
||||||
|
- podSelector:
|
||||||
|
matchLabels:
|
||||||
|
longhorn.io/component: backing-image-data-source
|
||||||
|
{{- end }}
|
@ -0,0 +1,27 @@
|
|||||||
|
{{- if .Values.networkPolicies.enabled }}
|
||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: NetworkPolicy
|
||||||
|
metadata:
|
||||||
|
name: instance-manager
|
||||||
|
namespace: longhorn-system
|
||||||
|
spec:
|
||||||
|
podSelector:
|
||||||
|
matchLabels:
|
||||||
|
longhorn.io/component: instance-manager
|
||||||
|
policyTypes:
|
||||||
|
- Ingress
|
||||||
|
ingress:
|
||||||
|
- from:
|
||||||
|
- podSelector:
|
||||||
|
matchLabels:
|
||||||
|
app: longhorn-manager
|
||||||
|
- podSelector:
|
||||||
|
matchLabels:
|
||||||
|
longhorn.io/component: instance-manager
|
||||||
|
- podSelector:
|
||||||
|
matchLabels:
|
||||||
|
longhorn.io/component: backing-image-manager
|
||||||
|
- podSelector:
|
||||||
|
matchLabels:
|
||||||
|
longhorn.io/component: backing-image-data-source
|
||||||
|
{{- end }}
|
35
chart/templates/network-policies/manager-network-policy.yaml
Normal file
35
chart/templates/network-policies/manager-network-policy.yaml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{{- if .Values.networkPolicies.enabled }}
|
||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: NetworkPolicy
|
||||||
|
metadata:
|
||||||
|
name: longhorn-manager
|
||||||
|
namespace: longhorn-system
|
||||||
|
spec:
|
||||||
|
podSelector:
|
||||||
|
matchLabels:
|
||||||
|
app: longhorn-manager
|
||||||
|
policyTypes:
|
||||||
|
- Ingress
|
||||||
|
ingress:
|
||||||
|
- from:
|
||||||
|
- podSelector:
|
||||||
|
matchLabels:
|
||||||
|
app: longhorn-manager
|
||||||
|
- podSelector:
|
||||||
|
matchLabels:
|
||||||
|
app: longhorn-ui
|
||||||
|
- podSelector:
|
||||||
|
matchLabels:
|
||||||
|
app: longhorn-csi-plugin
|
||||||
|
- podSelector:
|
||||||
|
matchLabels:
|
||||||
|
longhorn.io/managed-by: longhorn-manager
|
||||||
|
matchExpressions:
|
||||||
|
- { key: recurring-job.longhorn.io, operator: Exists }
|
||||||
|
- podSelector:
|
||||||
|
matchExpressions:
|
||||||
|
- { key: longhorn.io/job-task, operator: Exists }
|
||||||
|
- podSelector:
|
||||||
|
matchLabels:
|
||||||
|
app: longhorn-driver-deployer
|
||||||
|
{{- end }}
|
@ -0,0 +1,17 @@
|
|||||||
|
{{- if .Values.networkPolicies.enabled }}
|
||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: NetworkPolicy
|
||||||
|
metadata:
|
||||||
|
name: longhorn-recovery-backend
|
||||||
|
namespace: longhorn-system
|
||||||
|
spec:
|
||||||
|
podSelector:
|
||||||
|
matchLabels:
|
||||||
|
app: longhorn-manager
|
||||||
|
policyTypes:
|
||||||
|
- Ingress
|
||||||
|
ingress:
|
||||||
|
- ports:
|
||||||
|
- protocol: TCP
|
||||||
|
port: 9503
|
||||||
|
{{- end }}
|
@ -0,0 +1,46 @@
|
|||||||
|
{{- if and .Values.networkPolicies.enabled .Values.ingress.enabled (not (eq .Values.networkPolicies.type "")) }}
|
||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: NetworkPolicy
|
||||||
|
metadata:
|
||||||
|
name: longhorn-ui-frontend
|
||||||
|
namespace: longhorn-system
|
||||||
|
spec:
|
||||||
|
podSelector:
|
||||||
|
matchLabels:
|
||||||
|
app: longhorn-ui
|
||||||
|
policyTypes:
|
||||||
|
- Ingress
|
||||||
|
ingress:
|
||||||
|
- from:
|
||||||
|
{{- if eq .Values.networkPolicies.type "rke1"}}
|
||||||
|
- namespaceSelector:
|
||||||
|
matchLabels:
|
||||||
|
kubernetes.io/metadata.name: ingress-nginx
|
||||||
|
podSelector:
|
||||||
|
matchLabels:
|
||||||
|
app.kubernetes.io/component: controller
|
||||||
|
app.kubernetes.io/instance: ingress-nginx
|
||||||
|
app.kubernetes.io/name: ingress-nginx
|
||||||
|
{{- else if eq .Values.networkPolicies.type "rke2" }}
|
||||||
|
- namespaceSelector:
|
||||||
|
matchLabels:
|
||||||
|
kubernetes.io/metadata.name: kube-system
|
||||||
|
podSelector:
|
||||||
|
matchLabels:
|
||||||
|
app.kubernetes.io/component: controller
|
||||||
|
app.kubernetes.io/instance: rke2-ingress-nginx
|
||||||
|
app.kubernetes.io/name: rke2-ingress-nginx
|
||||||
|
{{- else if eq .Values.networkPolicies.type "k3s" }}
|
||||||
|
- namespaceSelector:
|
||||||
|
matchLabels:
|
||||||
|
kubernetes.io/metadata.name: kube-system
|
||||||
|
podSelector:
|
||||||
|
matchLabels:
|
||||||
|
app.kubernetes.io/name: traefik
|
||||||
|
ports:
|
||||||
|
- port: 8000
|
||||||
|
protocol: TCP
|
||||||
|
- port: 80
|
||||||
|
protocol: TCP
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
33
chart/templates/network-policies/webhook-network-policy.yaml
Normal file
33
chart/templates/network-policies/webhook-network-policy.yaml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{{- if .Values.networkPolicies.enabled }}
|
||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: NetworkPolicy
|
||||||
|
metadata:
|
||||||
|
name: longhorn-conversion-webhook
|
||||||
|
namespace: longhorn-system
|
||||||
|
spec:
|
||||||
|
podSelector:
|
||||||
|
matchLabels:
|
||||||
|
app: longhorn-manager
|
||||||
|
policyTypes:
|
||||||
|
- Ingress
|
||||||
|
ingress:
|
||||||
|
- ports:
|
||||||
|
- protocol: TCP
|
||||||
|
port: 9501
|
||||||
|
---
|
||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: NetworkPolicy
|
||||||
|
metadata:
|
||||||
|
name: longhorn-admission-webhook
|
||||||
|
namespace: longhorn-system
|
||||||
|
spec:
|
||||||
|
podSelector:
|
||||||
|
matchLabels:
|
||||||
|
app: longhorn-manager
|
||||||
|
policyTypes:
|
||||||
|
- Ingress
|
||||||
|
ingress:
|
||||||
|
- ports:
|
||||||
|
- protocol: TCP
|
||||||
|
port: 9502
|
||||||
|
{{- end }}
|
@ -21,6 +21,11 @@ global:
|
|||||||
taintToleration: cattle.io/os=linux:NoSchedule
|
taintToleration: cattle.io/os=linux:NoSchedule
|
||||||
systemManagedComponentsNodeSelector: kubernetes.io/os:linux
|
systemManagedComponentsNodeSelector: kubernetes.io/os:linux
|
||||||
|
|
||||||
|
networkPolicies:
|
||||||
|
enabled: false
|
||||||
|
# Available types: k3s, rke2, rke1
|
||||||
|
type: "k3s"
|
||||||
|
|
||||||
image:
|
image:
|
||||||
longhorn:
|
longhorn:
|
||||||
engine:
|
engine:
|
||||||
|
Loading…
Reference in New Issue
Block a user