master

package
v0.0.0-...-1f5c564 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "master",
	Short: "Netappsd master: discover filers from netbox",
	Run: func(cmd *cobra.Command, _ []string) {
		ctx := httpext.ContextWithSIGINT(context.Background(), 0)

		l := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
			Level: slog.LevelDebug,
		}))
		slog.SetDefault(l)

		workerName := viper.GetString("worker")
		workerLabel := viper.GetString("worker_label")
		if workerLabel == "" {
			workerLabel = fmt.Sprintf("name=%s", workerName)
		}

		netappsdMaster := new(NetappsdMaster)
		netappsdMaster.NetAppSD = &netappsd.NetAppSD{
			NetboxHost:     viper.GetString("netbox_host"),
			NetboxToken:    viper.GetString("netbox_token"),
			Namespace:      viper.GetString("pod_namespace"),
			Region:         viper.GetString("region"),
			FilerTag:       viper.GetString("tag"),
			WorkerName:     workerName,
			WorkerLabel:    workerLabel,
			NetAppUsername: viper.GetString("netapp_username"),
			NetAppPassword: viper.GetString("netapp_password"),
		}

		slog.Info("starting netappsd master")
		slog.Info("netappsd master config", "region", netappsdMaster.Region, "tag", netappsdMaster.FilerTag, "worker", netappsdMaster.WorkerName)

		if err := netappsdMaster.Run(ctx); err != nil {
			slog.Error(err.Error())
			os.Exit(1)
		}

		mux := http.NewServeMux()
		mux.Handle("/", httpapi.Compose(netappsdMaster))
		mux.Handle("/metrics", promhttp.Handler())
		must.Succeed(httpext.ListenAndServeContext(ctx, viper.GetString("listen_addr"), mux))
	},
}

Functions

This section is empty.

Types

type NetappsdMaster

type NetappsdMaster struct {
	*netappsd.NetAppSD
}

func (*NetappsdMaster) AddTo

func (n *NetappsdMaster) AddTo(r *mux.Router)

AddTo implements the go-bits/httpapi.API interface. It registers the handler for the /next/filer.json endpoint, which returns the next filer to be worked on. It also registers the /healthz endpoint, which is used by the Kubernetes readiness/liveness probe.

func (*NetappsdMaster) IsValidPodName

func (n *NetappsdMaster) IsValidPodName(podname string) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL