Skip to content
Snippets Groups Projects
Commit 417be379 authored by kaiyou's avatar kaiyou
Browse files

Add the documented -info flag and improve related docs

parent 7ed4dae9
No related branches found
No related tags found
No related merge requests found
Pipeline #28857 passed
......@@ -41,7 +41,7 @@ To start your first cluster, run `hepto` in `full` mode, which embeds both a
master (apiserver, controller manager, etc.) and a kubelet in a single process.
```
source env
source docs/example.env
hepto \
# The node name, data will be stored in /var/lib/mycluster/mymaster
-name myfull \
......@@ -77,14 +77,14 @@ required when bootstraping nodes).
Start by running a master node anywhere:
```
source ./env
source docs/example.env
hepto -name mymaster -role master -iface eth0 -ip 2a00::dead:beef/64
```
Then on every other node, use the anchor IP address for discovery:
```
source ./env
source docs/example.env
hepto -name mynode1 -role node -iface eth0 -anchor 2a00::dead:beef
```
......@@ -103,8 +103,8 @@ In order to display hepto network configuration, which is useful for later setti
the CNI and service proxy:
```
source env
hepto -name whatever -info
source docs/example.env
hepto -iface eth0 -name whatever -info
```
### Deploying Calico
......@@ -229,7 +229,7 @@ Start by cloning the repository, then build the project:
```
# Some build configuration is declared as environmemt variables
source env
source docs/example.env
# Build a single binary
go build -tags "$TAGS" -ldflags "$LDFLAGS" ./cmd/hepto.go
```
......
......@@ -16,6 +16,8 @@ import (
// General configuration, used for parsing flags
type Config struct {
// Should we display info and exit
Info bool
// Should we fork and daemonize
Daemonize bool
// Data is stored under this base folder, a subfolder
......@@ -46,6 +48,7 @@ func (c *Config) FlagSet() *flag.FlagSet {
// General config
fs.IntVar(&config.LogLevel, "verbose", 0, "Make logs more verbose")
fs.BoolVar(&config.Daemonize, "daemonize", false, "Daemonize the subprocess")
fs.BoolVar(&config.Info, "info", false, "Display cluster info and exit")
fs.BoolVar(&config.Pprof, "pprof", false, "Enable Golang profiling")
fs.StringVar(&config.DataDir, "data", "/var/lib", "Data base directory")
// Cluster settings
......
......@@ -7,6 +7,7 @@ import (
"os"
"path"
"strings"
"text/tabwriter"
"go.acides.org/dolly"
"go.acides.org/hepto/services"
......@@ -35,7 +36,21 @@ func Hepto() error {
config.Cluster.DataDir = "/data"
config.Iface.ReadinessProbe = netip.AddrPortFrom(config.Network.DNS[0], 53)
manager := services.NewManager(&config.Cluster, &config.Node, config.Logger)
// Create a container and start the manager
// If displaying info was required, go for it
if config.Info {
w := tabwriter.NewWriter(os.Stdout, 2, 3, 1, ' ', 0)
fmt.Fprintf(w, "cluster name\t%s\n", config.Cluster.Name)
fmt.Fprintf(w, "cluster vpn CIDR\t%s\n", manager.State.Networking().NodeNet)
fmt.Fprintf(w, "cluster pod CIDR\t%s\n", manager.State.Networking().PodNet)
fmt.Fprintf(w, "cluster service CIDR\t%s\n", manager.State.Networking().ServiceNet)
fmt.Fprintf(w, "node name\t%s\n", config.Node.Name)
fmt.Fprintf(w, "node role\t%s\n", config.Node.Role)
fmt.Fprintf(w, "node vpn IP\t%s\n", manager.State.Networking().NodeAddress)
fmt.Fprintf(w, "node data\t%s\n", dataPath)
fmt.Fprintf(w, "apiserver IP\t%s\n", manager.State.Networking().APIAddress)
return w.Flush()
}
// Otherwise create a container and start the manager
c := dolly.NewForking(!config.Daemonize)
c.AddAll(
dolly.NewContainer(config.Node.Name),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment