Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some docs for config #215

Merged
merged 2 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
These are set for These flags are defined at operator/controllers/lemming_controller.go.
DanG100 marked this conversation as resolved.
Show resolved Hide resolved
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