Ignore validation for network policy creation

This commit helps the cases where targeting application pods in a
namespace using pod-selector to create an outage fails because of
not being able to validate the selector.

Error message for reference:
error validating data: ValidationError(NetworkPolicy.spec.podSelector):
unknown field "app=dittybopper" in io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector
This commit is contained in:
Naga Ravi Chaitanya Elluri
2021-10-14 19:31:38 -04:00
parent 10e9b09819
commit 2674e09407
+3 -1
View File
@@ -38,7 +38,9 @@ spec:
f.write(rendered_spec)
# Block the traffic by creating network policy
logging.info("Creating the network policy")
runcommand.invoke("kubectl create -f %s -n %s" % ("kraken_network_policy.yaml", namespace))
runcommand.invoke(
"kubectl create -f %s -n %s --validate=false" % ("kraken_network_policy.yaml", namespace)
)
# wait for the specified duration
logging.info("Waiting for the specified duration in the config: %s" % (duration))