Enable the garage admin interface
This commit is contained in:
parent
51e21c3e46
commit
f720d7accd
@ -73,3 +73,4 @@ storage:
|
||||
# capacity: 1200
|
||||
# api_port: 3900
|
||||
# rpc_port: 3901
|
||||
# admin_port: 3902
|
||||
|
@ -32,6 +32,7 @@ type Bootstrap struct {
|
||||
NebulaHostCert nebula.HostCert
|
||||
|
||||
GarageRPCSecret string
|
||||
GarageAdminToken string
|
||||
GarageGlobalBucketS3APICredentials garage.S3APICredentials
|
||||
}
|
||||
|
||||
@ -65,6 +66,7 @@ func FromFS(bootstrapFS fs.FS) (Bootstrap, error) {
|
||||
{&b.NebulaHostCert.HostCert, nebulaCertsHostCertPath},
|
||||
{&b.NebulaHostCert.HostKey, nebulaCertsHostKeyPath},
|
||||
{&b.GarageRPCSecret, garageRPCSecretPath},
|
||||
{&b.GarageAdminToken, garageAdminTokenPath},
|
||||
}
|
||||
|
||||
for _, f := range filesToLoadAsString {
|
||||
@ -115,6 +117,7 @@ func (b Bootstrap) WriteTo(into io.Writer) error {
|
||||
{b.NebulaHostCert.HostCert, nebulaCertsHostCertPath},
|
||||
{b.NebulaHostCert.HostKey, nebulaCertsHostKeyPath},
|
||||
{b.GarageRPCSecret, garageRPCSecretPath},
|
||||
{b.GarageAdminToken, garageAdminTokenPath},
|
||||
}
|
||||
|
||||
for _, f := range filesToWriteAsString {
|
||||
|
@ -7,8 +7,9 @@ import (
|
||||
|
||||
// Paths within the bootstrap FS related to garage.
|
||||
const (
|
||||
garageGlobalBucketKeyYmlPath = "garage/cryptic-net-global-bucket-key.yml"
|
||||
garageRPCSecretPath = "garage/rpc-secret.txt"
|
||||
garageAdminTokenPath = "garage/admin-token.txt"
|
||||
garageGlobalBucketKeyYmlPath = "garage/cryptic-net-global-bucket-key.yml"
|
||||
)
|
||||
|
||||
// GaragePeers returns a Peer for each known garage instance in the network.
|
||||
|
@ -4,11 +4,21 @@ import (
|
||||
"cryptic-net/admin"
|
||||
"cryptic-net/bootstrap"
|
||||
"cryptic-net/nebula"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func randStr(l int) string {
|
||||
b := make([]byte, l)
|
||||
if _, err := rand.Read(b); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return hex.EncodeToString(b)
|
||||
}
|
||||
|
||||
func readAdmin(path string) (admin.Admin, error) {
|
||||
|
||||
if path == "-" {
|
||||
@ -94,6 +104,7 @@ var subCmdAdminMakeBootstrap = subCmd{
|
||||
NebulaHostCert: nebulaHostCert,
|
||||
|
||||
GarageRPCSecret: adm.GarageRPCSecret,
|
||||
GarageAdminToken: randStr(32),
|
||||
GarageGlobalBucketS3APICredentials: adm.GarageGlobalBucketS3APICredentials,
|
||||
}
|
||||
|
||||
|
@ -156,9 +156,11 @@ func garageWriteChildConf(
|
||||
DataPath: alloc.DataPath,
|
||||
|
||||
RPCSecret: env.Bootstrap.GarageRPCSecret,
|
||||
AdminToken: env.Bootstrap.GarageAdminToken,
|
||||
|
||||
RPCAddr: net.JoinHostPort(thisHost.Nebula.IP, strconv.Itoa(alloc.RPCPort)),
|
||||
APIAddr: net.JoinHostPort(thisHost.Nebula.IP, strconv.Itoa(alloc.S3APIPort)),
|
||||
AdminAddr: net.JoinHostPort(thisHost.Nebula.IP, strconv.Itoa(alloc.AdminPort)),
|
||||
|
||||
BootstrapPeers: env.Bootstrap.GarageRPCPeerAddrs(),
|
||||
})
|
||||
|
@ -33,6 +33,7 @@ type DaemonYmlStorageAllocation struct {
|
||||
Capacity int `yaml:"capacity"`
|
||||
S3APIPort int `yaml:"s3_api_port"`
|
||||
RPCPort int `yaml:"rpc_port"`
|
||||
AdminPort int `yaml:"admin_port"`
|
||||
}
|
||||
|
||||
// DaemonYml describes the structure of the daemon.yml file.
|
||||
|
@ -14,9 +14,11 @@ type GarageTomlData struct {
|
||||
DataPath string
|
||||
|
||||
RPCSecret string
|
||||
AdminToken string
|
||||
|
||||
RPCAddr string
|
||||
APIAddr string
|
||||
AdminAddr string
|
||||
|
||||
BootstrapPeers []string
|
||||
}
|
||||
@ -40,6 +42,10 @@ bootstrap_peers = [{{- range .BootstrapPeers }}
|
||||
api_bind_addr = "{{ .APIAddr }}"
|
||||
s3_region = "garage"
|
||||
|
||||
[admin]
|
||||
api_bind_addr = "{{ .AdminAddr }}"
|
||||
admin_token = "{{ .AdminToken }}"
|
||||
|
||||
`))
|
||||
|
||||
// RenderGarageToml renders a garage.toml using the given data into the writer.
|
||||
|
Loading…
Reference in New Issue
Block a user