Skip to content

Commit

Permalink
more refinements after more testing
Browse files Browse the repository at this point in the history
  • Loading branch information
dovholuknf committed Nov 14, 2024
1 parent c812a3a commit c9163ed
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ziti/cmd/create/config_templates/controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ v: 3

{{ if .Controller.Ctrl.MinClusterSize }}
raft:
dataDir: "{{ .ZitiHome }}/raft{{ .InstanceId }}"
dataDir: "{{ .ZitiHome }}/raft"
minClusterSize: {{ .Controller.Ctrl.MinClusterSize }}
{{ else }}
db: "{{ .Controller.Database.DatabaseFile }}"
Expand Down
1 change: 1 addition & 0 deletions ziti/cmd/create/create_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ type CtrlValues struct {
BindAddress string
AltAdvertisedAddress string
MinClusterSize int
InstanceId string
}

type HealthChecksValues struct {
Expand Down
35 changes: 24 additions & 11 deletions ziti/cmd/edge/quickstart.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ func NewQuickStartCmd(out io.Writer, errOut io.Writer, context context.Context)
Run: func(cmd *cobra.Command, args []string) {
options.out = out
options.errOut = errOut
options.TrustDomain = "quickstart"
options.InstanceID = "quickstart"
options.run(context)
},
}
Expand Down Expand Up @@ -138,6 +140,7 @@ func NewQuickStartHaCmd(out io.Writer, errOut io.Writer, context context.Context
cmd.Hidden = true
return cmd
}

func NewQuickStartJoinClusterCmd(out io.Writer, errOut io.Writer, context context.Context) *cobra.Command {
options := &QuickstartOpts{}
cmd := &cobra.Command{
Expand All @@ -153,7 +156,7 @@ func NewQuickStartJoinClusterCmd(out io.Writer, errOut io.Writer, context contex
addCommonQuickstartFlags(cmd, options)
addQuickstartHaFlags(cmd, options)
cmd.Flags().IntVarP(&options.MemberPID, "member-pid", "m", 0, "the pid of a cluster member. required")
cmd.Flags().BoolVar(&options.nonVoter, "non-voting", true, "used with ha mode. specifies the member is a non-voting member")
cmd.Flags().BoolVar(&options.nonVoter, "non-voting", false, "used with ha mode. specifies the member is a non-voting member")
cmd.Hidden = true
return cmd
}
Expand Down Expand Up @@ -404,24 +407,23 @@ func (o *QuickstartOpts) run(ctx context.Context) {
time.Sleep(3 * time.Second) // output this after a bit...
nextInstId := incrementStringSuffix(o.InstanceID)
fmt.Println()
fmt.Println("=======================================================================================")
fmt.Println("controller and router started.")
fmt.Println(" controller located at : " + helpers.GetCtrlAdvertisedAddress() + ":" + strconv.Itoa(int(o.ControllerPort)))
fmt.Println(" router located at : " + helpers.GetRouterAdvertisedAddress() + ":" + strconv.Itoa(int(o.RouterPort)))
fmt.Println(" config dir located at : " + o.Home)
fmt.Println(" configured trust domain: " + o.TrustDomain)
fmt.Printf(" instance pid : %d\n", os.Getpid())
o.printDetails()
fmt.Println("=======================================================================================")
fmt.Println("Quickly add another member to this cluster using: ")
fmt.Printf(" ziti edge quickstart join \\\n")
fmt.Printf(" --ctrl-port %d \\\n", o.ControllerPort+1)
fmt.Printf(" --router-port %d \\\n", o.RouterPort+1)
fmt.Printf(" --home \"%s\" \\\n", o.Home)
fmt.Printf(" --trust-domain=\"%s\" \\\n", o.TrustDomain)
fmt.Printf(" --member-pid %d\\ \n", os.Getpid())
fmt.Printf(" --instance-id \"%s\"\n", nextInstId)
fmt.Println("=======================================================================================")
fmt.Println()
}()
} else {
fmt.Println()
o.printDetails()
fmt.Println("=======================================================================================")
}

select {
Expand All @@ -433,6 +435,16 @@ func (o *QuickstartOpts) run(ctx context.Context) {
o.cleanupHome()
}

func (o *QuickstartOpts) printDetails() {
fmt.Println("=======================================================================================")
fmt.Println("controller and router started.")
fmt.Println(" controller located at : " + helpers.GetCtrlAdvertisedAddress() + ":" + strconv.Itoa(int(o.ControllerPort)))
fmt.Println(" router located at : " + helpers.GetRouterAdvertisedAddress() + ":" + strconv.Itoa(int(o.RouterPort)))
fmt.Println(" config dir located at : " + o.Home)
fmt.Println(" configured trust domain: " + o.TrustDomain)
fmt.Printf(" instance pid : %d\n", os.Getpid())
}

func (o *QuickstartOpts) configureRouter(routerName string, configFile string, ctrlUrl string) {
if o.routerless {
return
Expand Down Expand Up @@ -534,7 +546,6 @@ func (o *QuickstartOpts) createMinimalPki() {
where := path.Join(o.Home, "pki")
fmt.Println("emitting a minimal PKI")

intermediateId := fmt.Sprintf("spiffe://%s/intermediate/%s", o.TrustDomain, o.InstanceID)
sid := fmt.Sprintf("spiffe://%s/controller/%s", o.TrustDomain, o.InstanceID)

//ziti pki create ca --pki-root="$pkiDir" --ca-file="root-ca" --ca-name="root-ca" --spiffe-id="whatever"
Expand Down Expand Up @@ -575,7 +586,6 @@ func (o *QuickstartOpts) createMinimalPki() {
fmt.Sprintf("--ca-name=%s", "root-ca"),
fmt.Sprintf("--intermediate-name=%s", o.scopedName("intermediate-ca")),
fmt.Sprintf("--intermediate-file=%s", o.scopedName("intermediate-ca")),
fmt.Sprintf("--spiffe-id=%s", intermediateId),
"--max-path-len=1",
})
intErr := intermediate.Execute()
Expand Down Expand Up @@ -662,7 +672,10 @@ func (o *QuickstartOpts) scopedName(name string) string {
}

func (o *QuickstartOpts) instHome() string {
return path.Join(o.Home, o.InstanceID)
if o.isHA {
return path.Join(o.Home, o.InstanceID)
}
return o.Home
}

func (o *QuickstartOpts) configureOverlay() {
Expand Down

0 comments on commit c9163ed

Please sign in to comment.