Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Commit

Permalink
add FSS for antreaNsx
Browse files Browse the repository at this point in the history
Signed-off-by: Bin Liu <[email protected]>
  • Loading branch information
liu4480 committed Mar 28, 2023
1 parent 0b7ed46 commit 9a0d8d5
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 17 deletions.
6 changes: 6 additions & 0 deletions addons/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ type addonFlags struct {
pprofBindAddress string
tlsMinVersion string
tlsCipherSuites string
configFile string
}

func parseAddonFlags(addonFlags *addonFlags) {
Expand Down Expand Up @@ -164,6 +165,7 @@ func parseAddonFlags(addonFlags *addonFlags) {
flag.StringVar(&addonFlags.pprofBindAddress, "pprof-bind-addr", ":18318", "Bind address of pprof web server if enabled")
flag.StringVar(&addonFlags.tlsMinVersion, "tls-min-version", "1.2", "minimum TLS version in use by the webhook server. Recommended values are \"1.2\" and \"1.3\".")
flag.StringVar(&addonFlags.tlsCipherSuites, "tls-cipher-suites", "", "Comma-separated list of cipher suites for the server. If omitted, the default Go cipher suites will be used.\n"+fmt.Sprintf("Possible values are %s.", strings.Join(cliflag.TLSCipherPossibleValues(), ", ")))
flag.StringVar(&addonFlags.configFile, "config-file", "", "The path to set configuration file for addon manager")
flag.Parse()
}

Expand Down Expand Up @@ -237,6 +239,9 @@ func main() {
os.Exit(1)
}

opt := addonconfig.NewOptions(ctrl.Log.WithName("controllers").WithName("Addon"))
opt.Complete(flags.configFile)

addonReconciler := &controllers.AddonReconciler{
Client: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("Addon"),
Expand All @@ -251,6 +256,7 @@ func main() {
AddonImagePullPolicy: flags.addonImagePullPolicy,
CorePackageRepoName: flags.corePackageRepoName,
FeatureGateClusterBootstrap: flags.featureGateClusterBootstrap,
AntreaNsxEnabled: opt.Config.AntreaNsxEnabled,
},
}
if err = addonReconciler.SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: flags.clusterConcurrency}); err != nil {
Expand Down
1 change: 1 addition & 0 deletions addons/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type AddonControllerConfig struct {
AddonImagePullPolicy string
CorePackageRepoName string
FeatureGateClusterBootstrap bool
AntreaNsxEnabled bool
}

// ClusterBootstrapControllerConfig contains configuration information related to ClusterBootstrap
Expand Down
68 changes: 68 additions & 0 deletions addons/pkg/config/options.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package config

import (
"os"

"github.com/go-logr/logr"
"gopkg.in/yaml.v2"
)

const (
defaultConfigurationFile = "/etc/addons-manager/addons-manager.conf"
)

type Options struct {
// The path of configuration file
ConfigFile string
Config *ControllerConfig
Log logr.Logger
}

type ControllerConfig struct {
AntreaNsxEnabled bool `yaml:"antreaNsxEnabled,omitempty"`
}

func NewOptions(Log logr.Logger) *Options {
return &Options{
Config: new(ControllerConfig),
Log: Log,
}
}

func (o *Options) Complete(configFile string) error {
o.setDefaults()
if configFile != "" {
_, err := os.Stat(configFile)
if err != nil {
o.Log.Info("configFile does not exist, will use default settings")
return nil
}
o.ConfigFile = configFile
}
if len(o.ConfigFile) > 0 {
err := o.loadConfigFromFile(o.ConfigFile)
if err != nil {
return err
}
}
return nil
}

func (o *Options) setDefaults() {
if o.ConfigFile == "" {
o.ConfigFile = defaultConfigurationFile
}
}

func (o *Options) loadConfigFromFile(file string) error {
data, err := os.ReadFile(file)
if err != nil {
return err
}

err = yaml.UnmarshalStrict(data, o.Config)
if err != nil {
return err
}
return nil
}
15 changes: 15 additions & 0 deletions packages/addons-manager/bundle/config/upstream/addons-manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ spec:
- --feature-gate-cluster-bootstrap=true
#@ if/end data.values.tanzuAddonsManager.featureGates.packageInstallStatus:
- --feature-gate-package-install-status=true
- --config-file /etc/addons-manager/addons-manager.conf
image: addons-controller:latest
imagePullPolicy: IfNotPresent
name: tanzu-addons-controller
Expand Down Expand Up @@ -402,6 +403,20 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
volumeMounts:
- mountPath: /etc/addons-manager
name: addons-manager-config
readOnly: true
volumes:
- name: addons-manager-config
projected:
- configMap:
name: vmware-system-tkg-addons-manager-config
items:
- key: addons-manager.conf
path: addons-manager.conf
optional: true
configMap:
serviceAccount: tanzu-addons-manager-sa
terminationGracePeriodSeconds: 10
#@ if/end data.values.tanzuAddonsManager.deployment.hostNetwork:
Expand Down
24 changes: 7 additions & 17 deletions tkg/manifest/telemetry/zz_generated.bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9a0d8d5

Please sign in to comment.