From a6ad676cf7d4992d0d2e8f2df05701e8a8f6bfcc Mon Sep 17 00:00:00 2001 From: Daniel Grau Date: Tue, 11 Jul 2023 15:44:12 -0700 Subject: [PATCH] Add some docs for config (#215) * Add some docs for config * typo --- README.md | 24 +++++++++++++++++++++++- cmd/lemming/lemming.go | 14 +++++++------- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 1579eb49..1cf33ae2 100644 --- a/README.md +++ b/README.md @@ -80,4 +80,26 @@ nodes: { 5. Attach to the debugger. 1. Using VS Code: Run and Debug -> Connect to server 2. Using dlv cli: `dlv connect localhost:56268` - 1. Required: Configure subsitute-path so dlv can resolve source code: `config substitute-path /build ` \ No newline at end of file + 1. Required: Configure subsitute-path so dlv can resolve source code: `config substitute-path /build ` + +## Configuration + +In general, Lemming should be configured through gNMI, however in some cases using flags is acceptable. + +When to use gNMI: +* Config modelled in OC +* Values that may be modified at runtime + +When to use flags: +* Startup options: (eg gNMI listen port) +* Immutable config +* Environment specific options (location of some resource) + +Lemming uses Viper and pflags for configuration. Currently, only flags are supported (no env vars and no config file). +Flags are defined in cmd/lemming/lemming.go. + + +In KNE, flags are set using the `args` attribute in the topology file. +The Lemming operator also adds some mandatory flags to lemming for ease of use. These are flags that are always set +since they required to run lemming in a containerized environment. +They are defined at operator/controllers/lemming_controller.go. \ No newline at end of file diff --git a/cmd/lemming/lemming.go b/cmd/lemming/lemming.go index c5a4faa9..c799aff9 100644 --- a/cmd/lemming/lemming.go +++ b/cmd/lemming/lemming.go @@ -17,29 +17,29 @@ package main import ( "flag" - "github.com/openconfig/lemming" - "github.com/openconfig/lemming/sysrib" "github.com/spf13/pflag" "github.com/spf13/viper" "google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials/insecure" + "github.com/openconfig/lemming" + "github.com/openconfig/lemming/sysrib" + log "github.com/golang/glog" ) var ( - gnmiAddr = flag.String("gnmi", ":9339", "gNMI listen address") - gribiAddr = flag.String("gribi", ":9340", "gRIBI listen address") - bgpPort = flag.Uint("bgp_port", 179, "BGP listening port") + gnmiAddr = pflag.String("gnmi", ":9339", "gNMI listen address") + gribiAddr = pflag.String("gribi", ":9340", "gRIBI listen address") + bgpPort = pflag.Uint("bgp_port", 179, "BGP listening port") target = pflag.String("target", "fakedut", "name of the fake target") tlsKeyFile = pflag.String("tls_key_file", "", "Controls whether to enable TLS for gNXI services. If unspecified, insecure credentials are used.") tlsCertFile = pflag.String("tls_cert_file", "", "Controls whether to enable TLS for gNXI services. If unspecified, insecure credentials are used.") zapiAddr = pflag.String("zapi_addr", sysrib.ZAPIAddr, "Custom ZAPI address: use unix:/tmp/zserv.api for a temp.") + _ = pflag.Bool("enable_dataplane", false, "Controls whether to enable dataplane") ) func main() { - pflag.Bool("enable_dataplane", false, "Controls whether to enable dataplane") - pflag.CommandLine.AddGoFlagSet(flag.CommandLine) pflag.Parse() viper.BindPFlags(pflag.CommandLine)