Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .mockery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ require-template-schema-exists: true
template: testify
template-schema: "{{.Template}}.schema.json"
packages:
github.com/codesphere-cloud/oms/internal/bootstrap/gcp:
config:
all: true
interfaces:
github.com/codesphere-cloud/oms/internal/env:
config:
all: true
Expand All @@ -22,6 +26,10 @@ packages:
config:
all: true
interfaces:
github.com/codesphere-cloud/oms/internal/installer/node:
config:
all: true
interfaces:
github.com/codesphere-cloud/oms/internal/portal:
config:
all: true
Expand Down
44 changes: 22 additions & 22 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ License URL: https://github.com/googleapis/google-cloud-go/blob/artifactregistry

----------
Module: cloud.google.com/go/auth
Version: v0.18.0
Version: v0.18.1
License: Apache-2.0
License URL: https://github.com/googleapis/google-cloud-go/blob/auth/v0.18.0/auth/LICENSE
License URL: https://github.com/googleapis/google-cloud-go/blob/auth/v0.18.1/auth/LICENSE

----------
Module: cloud.google.com/go/auth/oauth2adapt
Expand All @@ -23,9 +23,9 @@ License URL: https://github.com/googleapis/google-cloud-go/blob/auth/oauth2adapt

----------
Module: cloud.google.com/go/compute
Version: v1.53.0
Version: v1.54.0
License: Apache-2.0
License URL: https://github.com/googleapis/google-cloud-go/blob/compute/v1.53.0/compute/LICENSE
License URL: https://github.com/googleapis/google-cloud-go/blob/compute/v1.54.0/compute/LICENSE

----------
Module: cloud.google.com/go/compute/metadata
Expand All @@ -41,9 +41,9 @@ License URL: https://github.com/googleapis/google-cloud-go/blob/iam/v1.5.3/iam/L

----------
Module: cloud.google.com/go/longrunning
Version: v0.7.0
Version: v0.8.0
License: Apache-2.0
License URL: https://github.com/googleapis/google-cloud-go/blob/longrunning/v0.7.0/longrunning/LICENSE
License URL: https://github.com/googleapis/google-cloud-go/blob/longrunning/v0.8.0/longrunning/LICENSE

----------
Module: cloud.google.com/go/resourcemanager
Expand Down Expand Up @@ -89,15 +89,15 @@ License URL: https://github.com/clipperhouse/stringish/blob/v0.1.1/LICENSE

----------
Module: github.com/clipperhouse/uax29/v2
Version: v2.3.0
Version: v2.4.0
License: MIT
License URL: https://github.com/clipperhouse/uax29/blob/v2.3.0/LICENSE
License URL: https://github.com/clipperhouse/uax29/blob/v2.4.0/LICENSE

----------
Module: github.com/codesphere-cloud/cs-go/pkg/io
Version: v0.15.0
Version: v0.16.2
License: Apache-2.0
License URL: https://github.com/codesphere-cloud/cs-go/blob/v0.15.0/LICENSE
License URL: https://github.com/codesphere-cloud/cs-go/blob/v0.16.2/LICENSE

----------
Module: github.com/codesphere-cloud/oms/internal/tmpl
Expand Down Expand Up @@ -275,9 +275,9 @@ License URL: https://github.com/ulikunitz/xz/blob/v0.5.15/LICENSE

----------
Module: gitlab.com/gitlab-org/api/client-go
Version: v1.11.0
Version: v1.24.0
License: Apache-2.0
License URL: https://gitlab.com/gitlab-org/api/client-go/-/blob/v1.11.0/LICENSE
License URL: https://gitlab.com/gitlab-org/api/client-go/-/blob/v1.24.0/LICENSE

----------
Module: go.opentelemetry.io/auto/sdk
Expand Down Expand Up @@ -401,33 +401,33 @@ License URL: https://cs.opensource.google/go/x/time/+/v0.14.0:LICENSE

----------
Module: google.golang.org/api
Version: v0.261.0
Version: v0.263.0
License: BSD-3-Clause
License URL: https://github.com/googleapis/google-api-go-client/blob/v0.261.0/LICENSE
License URL: https://github.com/googleapis/google-api-go-client/blob/v0.263.0/LICENSE

----------
Module: google.golang.org/api/internal/third_party/uritemplates
Version: v0.261.0
Version: v0.263.0
License: BSD-3-Clause
License URL: https://github.com/googleapis/google-api-go-client/blob/v0.261.0/internal/third_party/uritemplates/LICENSE
License URL: https://github.com/googleapis/google-api-go-client/blob/v0.263.0/internal/third_party/uritemplates/LICENSE

----------
Module: google.golang.org/genproto/googleapis
Version: v0.0.0-20251222181119-0a764e51fe1b
Version: v0.0.0-20260128011058-8636f8732409
License: Apache-2.0
License URL: https://github.com/googleapis/go-genproto/blob/0a764e51fe1b/LICENSE
License URL: https://github.com/googleapis/go-genproto/blob/8636f8732409/LICENSE

----------
Module: google.golang.org/genproto/googleapis/api
Version: v0.0.0-20251222181119-0a764e51fe1b
Version: v0.0.0-20260128011058-8636f8732409
License: Apache-2.0
License URL: https://github.com/googleapis/go-genproto/blob/0a764e51fe1b/googleapis/api/LICENSE
License URL: https://github.com/googleapis/go-genproto/blob/8636f8732409/googleapis/api/LICENSE

----------
Module: google.golang.org/genproto/googleapis/rpc
Version: v0.0.0-20260120174246-409b4a993575
Version: v0.0.0-20260128011058-8636f8732409
License: Apache-2.0
License URL: https://github.com/googleapis/go-genproto/blob/409b4a993575/googleapis/rpc/LICENSE
License URL: https://github.com/googleapis/go-genproto/blob/8636f8732409/googleapis/rpc/LICENSE

----------
Module: google.golang.org/grpc
Expand Down
51 changes: 29 additions & 22 deletions cli/cmd/bootstrap_gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,23 @@ import (

"github.com/codesphere-cloud/cs-go/pkg/io"
"github.com/codesphere-cloud/oms/internal/bootstrap"
"github.com/codesphere-cloud/oms/internal/bootstrap/gcp"
"github.com/codesphere-cloud/oms/internal/env"
"github.com/codesphere-cloud/oms/internal/installer"
"github.com/codesphere-cloud/oms/internal/installer/node"
"github.com/codesphere-cloud/oms/internal/util"
)

type BootstrapGcpCmd struct {
cmd *cobra.Command
Opts *GlobalOptions
Env env.Env
CodesphereEnv *bootstrap.CodesphereEnvironment

cmd *cobra.Command
Opts *GlobalOptions
Env env.Env
CodesphereEnv *gcp.CodesphereEnvironment
InputRegistryType string
SSHQuiet bool
}

func (c *BootstrapGcpCmd) RunE(_ *cobra.Command, args []string) error {

err := c.BootstrapGcp()
if err != nil {
return fmt.Errorf("failed to bootstrap: %w", err)
Expand All @@ -49,7 +51,7 @@ func AddBootstrapGcpCmd(root *cobra.Command, opts *GlobalOptions) {
},
Opts: opts,
Env: env.NewEnv(),
CodesphereEnv: &bootstrap.CodesphereEnvironment{},
CodesphereEnv: &gcp.CodesphereEnvironment{},
}

flags := bootstrapGcpCmd.cmd.Flags()
Expand All @@ -65,15 +67,16 @@ func AddBootstrapGcpCmd(root *cobra.Command, opts *GlobalOptions) {
flags.BoolVar(&bootstrapGcpCmd.CodesphereEnv.Preemptible, "preemptible", false, "Use preemptible VMs for Codesphere infrastructure (default: false)")
flags.IntVar(&bootstrapGcpCmd.CodesphereEnv.DatacenterID, "datacenter-id", 1, "Datacenter ID (default: 1)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.CustomPgIP, "custom-pg-ip", "", "Custom PostgreSQL IP (optional)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.InstallConfig, "install-config", "config.yaml", "Path to install config file (optional)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.SecretsFile, "secrets-file", "prod.vault.yaml", "Path to secrets files (optional)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.InstallConfigPath, "install-config", "config.yaml", "Path to install config file (optional)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.SecretsFilePath, "secrets-file", "prod.vault.yaml", "Path to secrets files (optional)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.Region, "region", "europe-west4", "GCP Region (default: europe-west4)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.Zone, "zone", "europe-west4-a", "GCP Zone (default: europe-west4-a)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.DNSProjectID, "dns-project-id", "", "GCP Project ID for Cloud DNS (optional)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.DNSZoneName, "dns-zone-name", "oms-testing", "Cloud DNS Zone Name (optional)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.InstallCodesphereVersion, "install-codesphere-version", "", "Codesphere version to install (default: none)")
flags.StringVar(&bootstrapGcpCmd.InputRegistryType, "registry-type", "local-container", "Container registry type to use (options: local-container, artifact-registry) (default: artifact-registry)")
flags.BoolVar(&bootstrapGcpCmd.CodesphereEnv.WriteConfig, "write-config", true, "Write generated install config to file (default: true)")
flags.BoolVar(&bootstrapGcpCmd.SSHQuiet, "ssh-quiet", true, "Suppress SSH command output (default: true)")

util.MarkFlagRequired(bootstrapGcpCmd.cmd, "project-name")
util.MarkFlagRequired(bootstrapGcpCmd.cmd, "billing-account")
Expand All @@ -84,33 +87,37 @@ func AddBootstrapGcpCmd(root *cobra.Command, opts *GlobalOptions) {
}

func (c *BootstrapGcpCmd) BootstrapGcp() error {
c.CodesphereEnv.RegistryType = bootstrap.RegistryType(c.InputRegistryType)

gcpClient := bootstrap.NewGCPClient(os.Getenv("GOOGLE_APPLICATION_CREDENTIALS"))
bootstrapper, err := bootstrap.NewGCPBootstrapper(c.Env, c.CodesphereEnv, gcpClient)
ctx := c.cmd.Context()
stlog := bootstrap.NewStepLogger(false)
icg := installer.NewInstallConfigManager()
gcpClient := gcp.NewGCPClient(ctx, stlog, os.Getenv("GOOGLE_APPLICATION_CREDENTIALS"))
fw := util.NewFilesystemWriter()
nm := node.NewNode(fw, c.CodesphereEnv.SSHPrivateKeyPath, c.SSHQuiet)

bs, err := gcp.NewGCPBootstrapper(ctx, c.Env, stlog, c.CodesphereEnv, icg, gcpClient, nm, fw)
if err != nil {
return err
}

env, err := bootstrapper.Bootstrap()
envBytes, err2 := json.MarshalIndent(env, "", " ")
c.CodesphereEnv.RegistryType = gcp.RegistryType(c.InputRegistryType)

err = bs.Bootstrap()
envBytes, err2 := json.MarshalIndent(bs.Env, "", " ")
envString := string(envBytes)
if err2 != nil {
envString = ""
}
if err != nil {
if env.Jumpbox.ExternalIP != "" {
log.Printf("To debug on the jumpbox host:\nssh-add $SSH_KEY_PATH; ssh -o StrictHostKeyChecking=no -o ForwardAgent=yes -o SendEnv=OMS_PORTAL_API_KEY root@%s", env.Jumpbox.ExternalIP)
if bs.Env.Jumpbox != nil && bs.Env.Jumpbox.GetExternalIP() != "" {
log.Printf("To debug on the jumpbox host:\nssh-add $SSH_KEY_PATH; ssh -o StrictHostKeyChecking=no -o ForwardAgent=yes -o SendEnv=OMS_PORTAL_API_KEY root@%s", bs.Env.Jumpbox.GetExternalIP())
}
return fmt.Errorf("failed to bootstrap GCP: %w, env: %s", err, envString)
}
log.Println("GCP infrastructure bootstrapped:")

log.Println("\n🎉🎉🎉 GCP infrastructure bootstrapped successfully!")
log.Println(envString)

log.Printf("Start the Codesphere installation using OMS from the jumpbox host:\nssh-add $SSH_KEY_PATH; ssh -o StrictHostKeyChecking=no -o ForwardAgent=yes -o SendEnv=OMS_PORTAL_API_KEY root@%s", env.Jumpbox.ExternalIP)

log.Printf("When the installation is done, run the k0s configuration script generated at the k0s-1 host %s /root/configure-k0s.sh.", env.ControlPlaneNodes[0].InternalIP)
log.Printf("Start the Codesphere installation using OMS from the jumpbox host:\nssh-add $SSH_KEY_PATH; ssh -o StrictHostKeyChecking=no -o ForwardAgent=yes -o SendEnv=OMS_PORTAL_API_KEY root@%s", bs.Env.Jumpbox.GetExternalIP())
log.Printf("When the installation is done, run the k0s configuration script generated at the k0s-1 host %s /root/configure-k0s.sh.", bs.Env.ControlPlaneNodes[0].GetInternalIP())

return err
}
1 change: 1 addition & 0 deletions docs/oms-cli_beta_bootstrap-gcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ oms-cli beta bootstrap-gcp [flags]
--secrets-file string Path to secrets files (optional) (default "prod.vault.yaml")
--ssh-private-key-path string SSH Private Key Path (default: ~/.ssh/id_rsa) (default "~/.ssh/id_rsa")
--ssh-public-key-path string SSH Public Key Path (default: ~/.ssh/id_rsa.pub) (default "~/.ssh/id_rsa.pub")
--ssh-quiet Suppress SSH command output (default: true) (default true)
--write-config Write generated install config to file (default: true) (default true)
--zone string GCP Zone (default: europe-west4-a) (default "europe-west4-a")
```
Expand Down
Loading
Loading