Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

[elasticsearch] fix network policies http additional rules #1111

Merged
merged 2 commits into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions elasticsearch/examples/networkpolicy/Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
default: test

include ../../../helpers/examples.mk

RELEASE := helm-es-networkpolicy
TIMEOUT := 1200s

install:
helm upgrade --wait --timeout=600s --install $(RELEASE) --values ./values.yaml ../../ ; \
helm upgrade --wait --timeout=$(TIMEOUT) --install --values values.yaml $(RELEASE) ../../

restart:
helm upgrade --set terminationGracePeriod=121 --wait --timeout=600s --install $(RELEASE) --values ./values.yaml ../../ ; \
test: install goss

purge:
helm del --purge $(RELEASE)
helm del $(RELEASE)
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@ networkPolicy:
explicitNamespacesSelector:
# Accept from namespaces with all those different rules (from whitelisted Pods)
matchLabels:
role: frontend
role: frontend-http
matchExpressions:
- {key: role, operator: In, values: [frontend]}
- {key: role, operator: In, values: [frontend-http]}
additionalRules:
- podSelector:
matchLabels:
role: frontend
role: frontend-http
- podSelector:
matchExpressions:
- key: role
operator: In
values:
- frontend
- frontend-http
transport:
enabled: true
allowExternal: true
explicitNamespacesSelector:
matchLabels:
role: frontend
role: frontend-transport
matchExpressions:
- {key: role, operator: In, values: [frontend]}
- {key: role, operator: In, values: [frontend-transport]}
additionalRules:
- podSelector:
matchLabels:
role: frontend
role: frontend-transport
- podSelector:
matchExpressions:
- key: role
operator: In
values:
- frontend
- frontend-transport
2 changes: 1 addition & 1 deletion elasticsearch/templates/networkpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ spec:
namespaceSelector:
{{ toYaml . | indent 12 }}
{{- end }}
{{- with .Values.networkPolicy.transport.additionalRules }}
{{- with .Values.networkPolicy.http.additionalRules }}
# Or from custom additional rules
{{ toYaml . | indent 8 }}
{{- end }}
Expand Down
32 changes: 16 additions & 16 deletions elasticsearch/tests/elasticsearch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1367,37 +1367,37 @@ def test_network_policy():
explicitNamespacesSelector:
# Accept from namespaces with all those different rules (from whitelisted Pods)
matchLabels:
role: frontend
role: frontend-http
matchExpressions:
- {key: role, operator: In, values: [frontend]}
- {key: role, operator: In, values: [frontend-http]}
additionalRules:
- podSelector:
matchLabels:
role: frontend
role: frontend-http
- podSelector:
matchExpressions:
- key: role
operator: In
values:
- frontend
- frontend-http
transport:
enabled: true
allowExternal: true
explicitNamespacesSelector:
matchLabels:
role: frontend
role: frontend-transport
matchExpressions:
- {key: role, operator: In, values: [frontend]}
- {key: role, operator: In, values: [frontend-transport]}
additionalRules:
- podSelector:
matchLabels:
role: frontend
role: frontend-transport
- podSelector:
matchExpressions:
- key: role
operator: In
values:
- frontend
- frontend-transport

"""
r = helm_template(config)
Expand All @@ -1412,16 +1412,16 @@ def test_network_policy():
},
"namespaceSelector": {
"matchExpressions": [
{"key": "role", "operator": "In", "values": ["frontend"]}
{"key": "role", "operator": "In", "values": ["frontend-http"]}
],
"matchLabels": {"role": "frontend"},
"matchLabels": {"role": "frontend-http"},
},
},
{"podSelector": {"matchLabels": {"role": "frontend"}}},
{"podSelector": {"matchLabels": {"role": "frontend-http"}}},
{
"podSelector": {
"matchExpressions": [
{"key": "role", "operator": "In", "values": ["frontend"]}
{"key": "role", "operator": "In", "values": ["frontend-http"]}
]
}
},
Expand All @@ -1434,16 +1434,16 @@ def test_network_policy():
},
"namespaceSelector": {
"matchExpressions": [
{"key": "role", "operator": "In", "values": ["frontend"]}
{"key": "role", "operator": "In", "values": ["frontend-transport"]}
],
"matchLabels": {"role": "frontend"},
"matchLabels": {"role": "frontend-transport"},
},
},
{"podSelector": {"matchLabels": {"role": "frontend"}}},
{"podSelector": {"matchLabels": {"role": "frontend-transport"}}},
{
"podSelector": {
"matchExpressions": [
{"key": "role", "operator": "In", "values": ["frontend"]}
{"key": "role", "operator": "In", "values": ["frontend-transport"]}
]
}
},
Expand Down