feat: disable network policies generation by default (#1629)
* feat: disable network policies default generation Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com> * docs: add the generate-network-policies flag to user guide Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com> * test: add unit tests of the network policies generation Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com> --------- Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>
This commit is contained in:
@@ -267,3 +267,8 @@ os_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/vols-
|
||||
os_output="$KOMPOSE_ROOT/script/test/fixtures/vols-subpath/output-os.yaml"
|
||||
convert::expect_success_and_warning "$k8s_cmd" "$k8s_output"
|
||||
convert::expect_success "$os_cmd" "$os_output"
|
||||
|
||||
# Test support for network policies generation
|
||||
k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/network-policies/docker-compose.yaml convert --generate-network-policies --stdout --with-kompose-annotation=false"
|
||||
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/network-policies/output-k8s.yaml"
|
||||
convert::expect_success "$os_cmd" "$os_output"
|
||||
|
||||
@@ -27,6 +27,7 @@ $KOMPOSE_ROOT/kompose -f $KOMPOSE_ROOT/script/test/fixtures/single-file-output/d
|
||||
$KOMPOSE_ROOT/kompose -f $KOMPOSE_ROOT/script/test/fixtures/host-port-protocol/docker-compose.yaml convert --stdout --with-kompose-annotation=false > $KOMPOSE_ROOT/script/test/fixtures/host-port-protocol/output-k8s.yaml
|
||||
$KOMPOSE_ROOT/kompose -f $KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/docker-compose-v1.yaml convert --stdout --with-kompose-annotation=false > $KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/output-k8s-v1.yaml
|
||||
$KOMPOSE_ROOT/kompose -f $KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/docker-compose-v2.yaml convert --stdout --with-kompose-annotation=false > $KOMPOSE_ROOT/script/test/fixtures/external-traffic-policy/output-k8s-v2.yaml
|
||||
$KOMPOSE_ROOT/kompose -f $KOMPOSE_ROOT/script/test/fixtures/compose-file-support/compose.yaml convert --stdout --with-kompose-annotation=false > $KOMPOSE_ROOT/script/test/fixtures/compose-file-support/output-k8s.yaml
|
||||
fi
|
||||
|
||||
if $UPDATE_OS ; then
|
||||
|
||||
@@ -69,22 +69,6 @@ spec:
|
||||
restartPolicy: Always
|
||||
status: {}
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: change-in-volume-default
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/change-in-volume-default: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/change-in-volume-default: "true"
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
|
||||
+2
-16
@@ -69,22 +69,6 @@ spec:
|
||||
restartPolicy: Always
|
||||
status: {}
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: change-in-volume-default
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/change-in-volume-default: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/change-in-volume-default: "true"
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -115,6 +99,8 @@ spec:
|
||||
name: web
|
||||
ports:
|
||||
- containerPort: 5000
|
||||
hostPort: 5000
|
||||
protocol: TCP
|
||||
resources: {}
|
||||
volumeMounts:
|
||||
- mountPath: /code
|
||||
|
||||
+1
-26
@@ -2,9 +2,6 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
annotations:
|
||||
kompose.cmd: ./kompose convert --stdout
|
||||
kompose.version: 1.28.0 (4d1ce961)
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.service: web
|
||||
@@ -23,9 +20,6 @@ status:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
annotations:
|
||||
kompose.cmd: ./kompose convert --stdout
|
||||
kompose.version: 1.28.0 (4d1ce961)
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.service: web
|
||||
@@ -38,12 +32,9 @@ spec:
|
||||
strategy: {}
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
kompose.cmd: ./kompose convert --stdout
|
||||
kompose.version: 1.28.0 (4d1ce961)
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.network/kompose-default: "true"
|
||||
io.kompose.network/compose-file-support-default: "true"
|
||||
io.kompose.service: web
|
||||
spec:
|
||||
containers:
|
||||
@@ -57,19 +48,3 @@ spec:
|
||||
restartPolicy: Always
|
||||
status: {}
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: kompose-default
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/kompose-default: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/kompose-default: "true"
|
||||
|
||||
|
||||
@@ -55,22 +55,6 @@ metadata:
|
||||
io.kompose.service: db
|
||||
name: db-cm0
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: configmap-volume-default
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/configmap-volume-default: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/configmap-volume-default: "true"
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
|
||||
@@ -51,22 +51,6 @@ metadata:
|
||||
io.kompose.service: db
|
||||
name: db-cm0
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: configmap-volume-default
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/configmap-volume-default: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/configmap-volume-default: "true"
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
|
||||
@@ -77,19 +77,3 @@ spec:
|
||||
whenUnsatisfiable: ScheduleAnyway
|
||||
status: {}
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: placement-default
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/placement-default: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/placement-default: "true"
|
||||
|
||||
|
||||
@@ -34,19 +34,3 @@ spec:
|
||||
restartPolicy: Always
|
||||
status: {}
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: envvars-interpolation-default
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/envvars-interpolation-default: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/envvars-interpolation-default: "true"
|
||||
|
||||
|
||||
-16
@@ -69,22 +69,6 @@ spec:
|
||||
restartPolicy: Always
|
||||
status: {}
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: expose-default
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/expose-default: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/expose-default: "true"
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
|
||||
@@ -68,18 +68,3 @@ spec:
|
||||
restartPolicy: Always
|
||||
status: {}
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: external-traffic-policy-default
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/external-traffic-policy-default: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/external-traffic-policy-default: "true"
|
||||
|
||||
@@ -97,19 +97,3 @@ spec:
|
||||
status:
|
||||
loadBalancer: {}
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: external-traffic-policy-default
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/external-traffic-policy-default: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/external-traffic-policy-default: "true"
|
||||
|
||||
|
||||
@@ -172,22 +172,6 @@ spec:
|
||||
restartPolicy: Always
|
||||
status: {}
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: healthcheck-default
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/healthcheck-default: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/healthcheck-default: "true"
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
|
||||
@@ -48,19 +48,3 @@ spec:
|
||||
restartPolicy: Always
|
||||
status: {}
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: host-port-protocol-default
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/host-port-protocol-default: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/host-port-protocol-default: "true"
|
||||
|
||||
|
||||
@@ -26,22 +26,6 @@ spec:
|
||||
restartPolicy: Always
|
||||
status: {}
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: multiple-files-default
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/multiple-files-default: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/multiple-files-default: "true"
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
|
||||
@@ -54,22 +54,6 @@ spec:
|
||||
storage: 100Mi
|
||||
status: {}
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: multiple-type-volumes-default
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/multiple-type-volumes-default: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/multiple-type-volumes-default: "true"
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
version: '3.8'
|
||||
|
||||
networks:
|
||||
web:
|
||||
|
||||
services:
|
||||
nginx:
|
||||
image: nginx
|
||||
networks:
|
||||
- web
|
||||
@@ -0,0 +1,44 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.service: nginx
|
||||
name: nginx
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
io.kompose.service: nginx
|
||||
strategy: {}
|
||||
template:
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
io.kompose.network/network-policies-web: "true"
|
||||
io.kompose.service: nginx
|
||||
spec:
|
||||
containers:
|
||||
- image: nginx
|
||||
name: nginx
|
||||
resources: {}
|
||||
restartPolicy: Always
|
||||
status: {}
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: network-policies-web
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/network-policies-web: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/network-policies-web: "true"
|
||||
|
||||
@@ -85,19 +85,3 @@ spec:
|
||||
storage: 100Mi
|
||||
status: {}
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: service-group-default
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/service-group-default: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/service-group-default: "true"
|
||||
|
||||
|
||||
@@ -87,19 +87,3 @@ spec:
|
||||
status:
|
||||
loadBalancer: {}
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: single-file-output-default
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/single-file-output-default: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/single-file-output-default: "true"
|
||||
|
||||
|
||||
@@ -97,22 +97,6 @@ spec:
|
||||
status:
|
||||
replicas: 0
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: statefulset-default
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/statefulset-default: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/statefulset-default: "true"
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
|
||||
-111
@@ -53,102 +53,6 @@ spec:
|
||||
restartPolicy: Always
|
||||
status: {}
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: normalized-network
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/normalized-network: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/normalized-network: "true"
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: v30-normalized-network
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/v30-normalized-network: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/v30-normalized-network: "true"
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: app-network
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/normalized-network: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/normalized-network: "true"
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: app-network
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/app-network: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/app-network: "true"
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: web-network
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/web-network: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/web-network: "true"
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: normalized-network
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/normalized-network: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/normalized-network: "true"
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -188,18 +92,3 @@ spec:
|
||||
restartPolicy: Always
|
||||
status: {}
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: v30-default
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/v30-default: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/v30-default: "true"
|
||||
|
||||
@@ -71,19 +71,3 @@ spec:
|
||||
storage: 100Mi
|
||||
status: {}
|
||||
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: windows-default
|
||||
spec:
|
||||
ingress:
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/windows-default: "true"
|
||||
podSelector:
|
||||
matchLabels:
|
||||
io.kompose.network/windows-default: "true"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user