Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure TODO item: add a flag to disable Network Policy #722

Merged
merged 3 commits into from
Feb 28, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions pkg/controllers/job/plugins/svc/svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type servicePlugin struct {

// flag parse args
publishNotReadyAddresses bool
disableNetworkPolicy bool
}

// New creates service plugin
Expand All @@ -63,6 +64,8 @@ func (sp *servicePlugin) addFlags() {
flagSet := flag.NewFlagSet(sp.Name(), flag.ContinueOnError)
flagSet.BoolVar(&sp.publishNotReadyAddresses, "publish-not-ready-addresses", sp.publishNotReadyAddresses,
"set publishNotReadyAddresses of svc to true")
flagSet.BoolVar(&sp.disableNetworkPolicy, "disable-network-policy", sp.disableNetworkPolicy,
"set disableNetworkPolicy of svc to true")

if err := flagSet.Parse(sp.pluginArguments); err != nil {
klog.Errorf("plugin %s flagset parse failed, err: %v", sp.Name(), err)
Expand Down Expand Up @@ -138,9 +141,10 @@ func (sp *servicePlugin) OnJobAdd(job *batch.Job) error {
return err
}

// TODO: maybe add a flag
if err := sp.createNetworkPolicyIfNotExist(job); err != nil {
return err
if !sp.disableNetworkPolicy {
if err := sp.createNetworkPolicyIfNotExist(job); err != nil {
return err
}
}

job.Status.ControlledResources["plugin-"+sp.Name()] = sp.Name()
Expand Down