Skip to content

Commit

Permalink
Add some docs for config (#215)
Browse files Browse the repository at this point in the history
* Add some docs for config

* typo
  • Loading branch information
DanG100 authored Jul 11, 2023
1 parent a0a456e commit a6ad676
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <abs path to lemming src>`
1. Required: Configure subsitute-path so dlv can resolve source code: `config substitute-path /build <abs path to lemming src>`

## 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.
14 changes: 7 additions & 7 deletions cmd/lemming/lemming.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a6ad676

Please sign in to comment.