Merge pull request #2197 from zheng1/cluster_network
Add option to enable network policy or not
This commit is contained in:
@@ -50,7 +50,6 @@ import (
|
||||
devopsv1alpha3 "kubesphere.io/kubesphere/pkg/kapis/devops/v1alpha3"
|
||||
iamapi "kubesphere.io/kubesphere/pkg/kapis/iam/v1alpha2"
|
||||
monitoringv1alpha3 "kubesphere.io/kubesphere/pkg/kapis/monitoring/v1alpha3"
|
||||
networkv1alpha2 "kubesphere.io/kubesphere/pkg/kapis/network/v1alpha2"
|
||||
notificationv1 "kubesphere.io/kubesphere/pkg/kapis/notification/v1"
|
||||
"kubesphere.io/kubesphere/pkg/kapis/oauth"
|
||||
openpitrixv1 "kubesphere.io/kubesphere/pkg/kapis/openpitrix/v1"
|
||||
@@ -170,7 +169,6 @@ func (s *APIServer) installKubeSphereAPIs() {
|
||||
urlruntime.Must(resourcev1alpha3.AddToContainer(s.container, s.InformerFactory))
|
||||
urlruntime.Must(monitoringv1alpha3.AddToContainer(s.container, s.KubernetesClient.Kubernetes(), s.MonitoringClient, s.InformerFactory, s.OpenpitrixClient))
|
||||
urlruntime.Must(openpitrixv1.AddToContainer(s.container, s.InformerFactory, s.OpenpitrixClient))
|
||||
urlruntime.Must(networkv1alpha2.AddToContainer(s.container, s.Config.NetworkOptions.WeaveScopeHost))
|
||||
urlruntime.Must(operationsv1alpha2.AddToContainer(s.container, s.KubernetesClient.Kubernetes()))
|
||||
urlruntime.Must(resourcesv1alpha2.AddToContainer(s.container, s.KubernetesClient.Kubernetes(), s.InformerFactory,
|
||||
s.KubernetesClient.Master()))
|
||||
|
||||
@@ -203,7 +203,7 @@ func (conf *Config) stripEmptyOptions() {
|
||||
conf.OpenPitrixOptions = nil
|
||||
}
|
||||
|
||||
if conf.NetworkOptions != nil && conf.NetworkOptions.WeaveScopeHost == "" {
|
||||
if conf.NetworkOptions != nil && conf.NetworkOptions.EnableNetworkPolicy == false {
|
||||
conf.NetworkOptions = nil
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ func newTestConfig() (*Config, error) {
|
||||
AttachmentManagerEndpoint: "openpitrix-hyperpitrix.openpitrix-system.svc:9122",
|
||||
},
|
||||
NetworkOptions: &network.Options{
|
||||
WeaveScopeHost: "weave-scope-app.weave.svc",
|
||||
EnableNetworkPolicy: true,
|
||||
},
|
||||
MonitoringOptions: &prometheus.Options{
|
||||
Endpoint: "http://prometheus.kubesphere-monitoring-system.svc",
|
||||
|
||||
@@ -3,15 +3,13 @@ package network
|
||||
import "github.com/spf13/pflag"
|
||||
|
||||
type Options struct {
|
||||
|
||||
// weave scope service host
|
||||
WeaveScopeHost string `json:"weaveScopeHost,omitempty" yaml:"weaveScopeHost"`
|
||||
EnableNetworkPolicy bool `json:"enableNetworkPolicy,omitempty" yaml:"enableNetworkPolicy"`
|
||||
}
|
||||
|
||||
// NewNetworkOptions returns a `zero` instance
|
||||
func NewNetworkOptions() *Options {
|
||||
return &Options{
|
||||
WeaveScopeHost: "weave-scope-app.weave.svc",
|
||||
EnableNetworkPolicy: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,12 +19,10 @@ func (s *Options) Validate() []error {
|
||||
}
|
||||
|
||||
func (s *Options) ApplyTo(options *Options) {
|
||||
if s.WeaveScopeHost != "" {
|
||||
options.WeaveScopeHost = s.WeaveScopeHost
|
||||
}
|
||||
options.EnableNetworkPolicy = s.EnableNetworkPolicy
|
||||
}
|
||||
|
||||
func (s *Options) AddFlags(fs *pflag.FlagSet, c *Options) {
|
||||
fs.StringVar(&s.WeaveScopeHost, "weave-scope-host", c.WeaveScopeHost, ""+
|
||||
"weave scope service host")
|
||||
fs.BoolVar(&s.EnableNetworkPolicy, "enable-network-policy", c.EnableNetworkPolicy,
|
||||
"This field instructs KubeSphere to enable network policy or not.")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user