mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-10-18 13:21:00 +02:00
Simplified bootstrapping of a cluster (#40)
* Simplified bootstrapping of a cluster Introduced a new convention about a pre-defined `bootstrap-admin` account for `orchard controller run`. Providing `ORCHARD_BOOTSTRAP_ADMIN_TOKEN` will auto-create such user for easier configuration. `bootstrap-admin` can be used for creating other service accounts on the first run and after that can be disposed. Also change `orchard worker run` to expect controller URL as the only parameter and a bootstrap token passed via an argument instead of using a context that might not be created. * Missing error check
This commit is contained in:
@@ -48,21 +48,11 @@ func newCreateCommand() *cobra.Command {
|
||||
}
|
||||
|
||||
func runCreate(cmd *cobra.Command, args []string) error {
|
||||
addr := args[0]
|
||||
|
||||
if !strings.HasPrefix(addr, "https://") && !strings.HasPrefix(addr, "http://") {
|
||||
addr = "https://" + addr
|
||||
}
|
||||
|
||||
controllerURL, err := url.Parse(addr)
|
||||
controllerURL, err := netconstants.NormalizeAddress(args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if controllerURL.Port() == "" {
|
||||
controllerURL.Host += fmt.Sprintf(":%d", netconstants.DefaultControllerPort)
|
||||
}
|
||||
|
||||
// Establish trust
|
||||
var trustedControllerCertificate *x509.Certificate
|
||||
|
||||
@@ -82,19 +72,9 @@ func runCreate(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
}
|
||||
|
||||
// Check that the API is accessible
|
||||
privatePool := x509.NewCertPool()
|
||||
privatePool.AddCert(trustedControllerCertificate)
|
||||
|
||||
tlsConfig := &tls.Config{
|
||||
MinVersion: tls.VersionTLS13,
|
||||
RootCAs: privatePool,
|
||||
ServerName: netconstants.DefaultControllerServerName,
|
||||
}
|
||||
|
||||
client, err := client.New(
|
||||
client.WithAddress(controllerURL.String()),
|
||||
client.WithTLSConfig(tlsConfig),
|
||||
client.WithTrustedCertificate(trustedControllerCertificate),
|
||||
client.WithCredentials(serviceAccountName, serviceAccountToken),
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user