Skip to content

Commit

Permalink
Re-add network policies back to helm chart and fix node egress (#11771)
Browse files Browse the repository at this point in the history
* Re-add helm network policies from prev commit:

48002f2^1

* Fix chainlink node networkpolicy egress ports

* Test removing network policies

* Revert "Test removing network policies"

This reverts commit 8260e0f.

* Use proper syntax

* Fix syntax

* Delete egress rules on node np

* Create network policy for runner template

* Set default np to ingress only

* Fix EOF

* Fix indent

* Include default egress rules

* Rename network policy

* Avoid hardcode

* test load and chaos, fix reorg

---------

Co-authored-by: skudasov <[email protected]>
  • Loading branch information
chainchad and skudasov authored Jan 18, 2024
1 parent 3e91b24 commit 286c8c0
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 2 deletions.
4 changes: 2 additions & 2 deletions charts/chainlink-cluster/devspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ pipelines:
run_dependencies --all
ensure_pull_secrets --all
build_images ---var DOCKER_DEFAULT_PLATFORM=linux/amd64 --all -t $(git rev-parse --short HEAD)
kubectl annotate namespace ${DEVSPACE_NAMESPACE} janitor/ttl=${NS_TTL}
kubectl label namespace/${DEVSPACE_NAMESPACE} network=crib
kubectl annotate namespace ${DEVSPACE_NAMESPACE} janitor/ttl=${NS_TTL} || true
kubectl label namespace/${DEVSPACE_NAMESPACE} network=crib || true
create_deployments --all
echo "Namespace ${DEVSPACE_NAMESPACE} will be deleted in ${NS_TTL}"
purge:
Expand Down
23 changes: 23 additions & 0 deletions charts/chainlink-cluster/templates/chainlink-db-networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ $.Release.Name }}-db
spec:
podSelector:
matchLabels:
app: {{ $.Release.Name }}-db
policyTypes:
- Ingress
ingress:
- from:
# Allow all node pods to access the database pods.
- podSelector:
matchLabels:
app: {{ $.Release.Name }}
# Allow all runner pods to access the database pods.
- podSelector:
matchLabels:
app: runner
ports:
- protocol: TCP
port: 5432
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ $.Release.Name }}-node
spec:
podSelector:
matchLabels:
app: {{ $.Release.Name }}
policyTypes:
- Ingress
ingress:
# Allow all ingress traffic between the node pods and from runner pod.
- from:
- podSelector:
matchLabels:
app: {{ $.Release.Name }}
- podSelector:
matchLabels:
app: runner
2 changes: 2 additions & 0 deletions charts/chainlink-cluster/templates/geth-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ spec:
- '--miner.etherbase'
- '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
- '--ipcdisable'
- '--http.api'
- 'admin,debug,web3,eth,txpool,personal,miner,net'
- '--http'
- '--http.vhosts'
- '*'
Expand Down
25 changes: 25 additions & 0 deletions charts/chainlink-cluster/templates/geth-networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ $.Release.Name }}-geth
spec:
podSelector:
matchLabels:
app: geth
policyTypes:
- Ingress
ingress:
- from:
# Allow http and websocket connections from the node pods.
- podSelector:
matchLabels:
app: {{ $.Release.Name }}
# Allow http and websocket connections from the runner pods.
- podSelector:
matchLabels:
app: runner
ports:
- protocol: TCP
port: 8544
- protocol: TCP
port: 8546
23 changes: 23 additions & 0 deletions charts/chainlink-cluster/templates/mockserver-networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ $.Release.Name }}-mockserver
spec:
podSelector:
matchLabels:
app: mockserver
policyTypes:
- Ingress
ingress:
- from:
# Allow http traffic from the node pods.
- podSelector:
matchLabels:
app: {{ $.Release.Name }}
# Allow http traffic from the runner pods.
- podSelector:
matchLabels:
app: runner
ports:
- protocol: TCP
port: 1080
27 changes: 27 additions & 0 deletions charts/chainlink-cluster/templates/networkpolicy-default-deny.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny
spec:
podSelector:
matchLabels: {}
policyTypes:
- Ingress
- Egress
egress:
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: "{{ $.Release.Namespace }}"
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: kube-system
podSelector:
matchLabels:
k8s-app: kube-dns
ports:
- protocol: TCP
port: 53
- protocol: UDP
port: 53
19 changes: 19 additions & 0 deletions charts/chainlink-cluster/templates/runner-networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ $.Release.Name }}-runner
spec:
podSelector:
matchLabels:
app: runner
policyTypes:
- Ingress
ingress:
# Allow all ingress traffic between the node pods and from runner pod.
- from:
- podSelector:
matchLabels:
app: {{ $.Release.Name }}
- podSelector:
matchLabels:
app: runner

0 comments on commit 286c8c0

Please sign in to comment.