This repository has been archived by the owner on May 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for NetworkPolicy. (#498)
- Loading branch information
1 parent
ae7526c
commit ae168fd
Showing
6 changed files
with
262 additions
and
1 deletion.
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
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,13 @@ | ||
default: test | ||
include ../../../helpers/examples.mk | ||
|
||
RELEASE := helm-es-networkpolicy | ||
|
||
install: | ||
helm upgrade --wait --timeout=600s --install $(RELEASE) --values ./values.yaml ../../ ; \ | ||
|
||
restart: | ||
helm upgrade --set terminationGracePeriod=121 --wait --timeout=600s --install $(RELEASE) --values ./values.yaml ../../ ; \ | ||
|
||
purge: | ||
helm del --purge $(RELEASE) |
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,37 @@ | ||
networkPolicy: | ||
http: | ||
enabled: true | ||
explicitNamespacesSelector: | ||
# Accept from namespaces with all those different rules (from whitelisted Pods) | ||
matchLabels: | ||
role: frontend | ||
matchExpressions: | ||
- {key: role, operator: In, values: [frontend]} | ||
additionalRules: | ||
- podSelector: | ||
matchLabels: | ||
role: frontend | ||
- podSelector: | ||
matchExpressions: | ||
- key: role | ||
operator: In | ||
values: | ||
- frontend | ||
transport: | ||
enabled: true | ||
allowExternal: true | ||
explicitNamespacesSelector: | ||
matchLabels: | ||
role: frontend | ||
matchExpressions: | ||
- {key: role, operator: In, values: [frontend]} | ||
additionalRules: | ||
- podSelector: | ||
matchLabels: | ||
role: frontend | ||
- podSelector: | ||
matchExpressions: | ||
- key: role | ||
operator: In | ||
values: | ||
- frontend |
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,61 @@ | ||
{{- if (or .Values.networkPolicy.http.enabled .Values.networkPolicy.transport.enabled) }} | ||
kind: NetworkPolicy | ||
apiVersion: networking.k8s.io/v1 | ||
metadata: | ||
name: {{ template "elasticsearch.uname" . }} | ||
labels: | ||
heritage: {{ .Release.Service | quote }} | ||
release: {{ .Release.Name | quote }} | ||
chart: "{{ .Chart.Name }}" | ||
app: "{{ template "elasticsearch.uname" . }}" | ||
spec: | ||
podSelector: | ||
matchLabels: | ||
app: "{{ template "elasticsearch.uname" . }}" | ||
ingress: # Allow inbound connections | ||
|
||
{{- if .Values.networkPolicy.http.enabled }} | ||
# For HTTP access | ||
- ports: | ||
- port: {{ .Values.httpPort }} | ||
from: | ||
# From authorized Pods (having the correct label) | ||
- podSelector: | ||
matchLabels: | ||
{{ template "elasticsearch.uname" . }}-http-client: "true" | ||
{{- with .Values.networkPolicy.http.explicitNamespacesSelector }} | ||
# From authorized namespaces | ||
namespaceSelector: | ||
{{ toYaml . | indent 12 }} | ||
{{- end }} | ||
{{- with .Values.networkPolicy.transport.additionalRules }} | ||
# Or from custom additional rules | ||
{{ toYaml . | indent 8 }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{- if .Values.networkPolicy.transport.enabled }} | ||
# For transport access | ||
- ports: | ||
- port: {{ .Values.transportPort }} | ||
from: | ||
# From authorized Pods (having the correct label) | ||
- podSelector: | ||
matchLabels: | ||
{{ template "elasticsearch.uname" . }}-transport-client: "true" | ||
{{- with .Values.networkPolicy.transport.explicitNamespacesSelector }} | ||
# From authorized namespaces | ||
namespaceSelector: | ||
{{ toYaml . | indent 12 }} | ||
{{- end }} | ||
{{- with .Values.networkPolicy.transport.additionalRules }} | ||
# Or from custom additional rules | ||
{{ toYaml . | indent 8 }} | ||
{{- end }} | ||
# Or from other ElasticSearch Pods | ||
- podSelector: | ||
matchLabels: | ||
app: "{{ template "elasticsearch.uname" . }}" | ||
{{- end }} | ||
|
||
{{- 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
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