bootstrap: fix service account permission issues
diff --git a/core/installer/Makefile b/core/installer/Makefile
index 479a07c..acf0947 100644
--- a/core/installer/Makefile
+++ b/core/installer/Makefile
@@ -3,3 +3,9 @@
push_arm64: image_arm64
docker push giolekva/flux:latest
+
+build:
+ go1.18 build -o pcloud *.go
+
+bootstrap:
+ ./pcloud bootstrap --kubeconfig=../../priv/kubeconfig --charts-dir=../../charts --admin-pub-key=/Users/lekva/.ssh/id_rsa.pub --admin-priv-key=/Users/lekva/.ssh/id_rsa
diff --git a/core/installer/go.mod b/core/installer/go.mod
index 4311ce9..84eb3b4 100644
--- a/core/installer/go.mod
+++ b/core/installer/go.mod
@@ -6,6 +6,7 @@
github.com/go-git/go-billy/v5 v5.3.1
github.com/go-git/go-git/v5 v5.4.2
github.com/spf13/cobra v1.4.0
+ golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4
helm.sh/helm/v3 v3.8.2
sigs.k8s.io/yaml v1.3.0
)
@@ -114,7 +115,6 @@
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca // indirect
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
- golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
golang.org/x/net v0.0.0-20220325170049-de3da57026de // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
diff --git a/core/installer/main.go b/core/installer/main.go
index bc1ca71..4cee2c6 100644
--- a/core/installer/main.go
+++ b/core/installer/main.go
@@ -145,7 +145,7 @@
installer := action.NewInstall(config)
installer.Namespace = "pcloud"
installer.CreateNamespace = true
- installer.ReleaseName = "flux"
+ installer.ReleaseName = "flux4"
installer.Wait = true
installer.WaitForJobs = true
installer.Timeout = 5 * time.Minute
@@ -317,6 +317,32 @@
}, nil
}
+func reloadConfig(addr string, clientPrivKey []byte, serverPubKey string) error {
+ signer, err := ssh.ParsePrivateKey(clientPrivKey)
+ if err != nil {
+ return err
+ }
+ config := &ssh.ClientConfig{
+ Auth: []ssh.AuthMethod{
+ ssh.PublicKeys(signer),
+ },
+ HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error {
+ fmt.Printf("## %s || %s -- \n", serverPubKey, ssh.MarshalAuthorizedKey(key))
+ return nil
+ },
+ }
+ client, err := ssh.Dial("tcp", addr, config)
+ if err != nil {
+ return err
+ }
+ session, err := client.NewSession()
+ if err != nil {
+ return err
+ }
+ defer session.Close()
+ return session.Run("reload")
+}
+
func bootstrapCmdRun(cmd *cobra.Command, args []string) error {
adminPubKey, adminPrivKey, err := readAdminKeys()
if err != nil {
@@ -342,16 +368,24 @@
fmt.Printf("-- %s || %s -- \n", softServePub, ssh.MarshalAuthorizedKey(key))
return nil
}
+ fmt.Println("Installing SoftServe")
if err := installSoftServe(softServePub, softServePriv, string(adminPubKey)); err != nil {
return err
}
- time.Sleep(10 * time.Second)
+ time.Sleep(30 * time.Second)
+ fmt.Println("Overwriting config")
if err := overwriteConfigRepo("ssh://192.168.0.208:22/config", auth, config); err != nil {
return err
}
+ fmt.Println("Reloading config")
+ if err := reloadConfig("192.168.0.208:22", adminPrivKey, softServePub); err != nil {
+ return err
+ }
+ fmt.Println("Creating /pcloud repo")
if err := createRepo("ssh://192.168.0.208:22/pcloud", "PCloud System\n", auth); err != nil {
return err
}
+ fmt.Println("Installing Flux")
if err := installFlux("ssh://soft-serve.pcloud.svc.cluster.local:22/pcloud", "soft-serve.pcloud.svc.cluster.local", softServePub, fluxPriv); err != nil {
return err
}