diff --git a/README.md b/README.md index da17f9c..ce5d17f 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,6 @@ commands you run: | Tool | Needed by | |---|---| -| `kubeseal` | all secret-generating commands, `quickstart` | | `helm` (3.8+) | `deploy render` | | `git` | `deploy init`, `deploy render` | | `argo` | `node enroll-server`, `node inspect-server` | diff --git a/cmd/argocd/argocd.go b/cmd/argocd/argocd.go deleted file mode 100644 index 46a3aeb..0000000 --- a/cmd/argocd/argocd.go +++ /dev/null @@ -1,107 +0,0 @@ -package argocd - -import ( - _ "embed" - "fmt" - "os" - "path/filepath" - - "github.com/rackerlabs/understackctl/helpers" - - "github.com/charmbracelet/log" - "github.com/gookit/goutil/envutil" - "github.com/gookit/goutil/fsutil" - "github.com/spf13/cobra" -) - -//go:embed templates/argoCluster.tmpl -var argoClusterTemplate string - -//go:embed templates/argoSecretDeployRepo.tmpl -var argoSecretDeployRepoTemplate string - -// Constants for file paths and template names -const ( - clusterSecretFile = "secret-%s-cluster.yaml" - secretDeployRepoFile = "secret-deploy-repo.yaml" - argoNamespace = "argocd" -) - -func NewCmdArgocdSecret() *cobra.Command { - return &cobra.Command{ - Use: "argocd-secrets", - Short: "Generate ArgoCD secrets", - Long: "Generate repository and cluster secrets for ArgoCD deployment", - Run: func(cmd *cobra.Command, args []string) { - if err := generateSecrets(); err != nil { - log.Fatal("Failed to generate secrets", "error", err) - os.Exit(1) - } - }, - } -} - -// generateSecrets orchestrates the generation of all ArgoCD secrets -func generateSecrets() error { - basePath := helpers.GetManifestPathToService("argocd") - - if err := generateDeployRepoSecret(basePath); err != nil { - return fmt.Errorf("deploy repo secret generation failed: %w", err) - } - - if err := generateClusterSecret(basePath); err != nil { - return fmt.Errorf("cluster secret generation failed: %w", err) - } - - helpers.UpdateKustomizeFile(basePath) - return nil -} - -// generateDeployRepoSecret generates the repository deployment secret -func generateDeployRepoSecret(basePath string) error { - vars := map[string]any{ - "Config": `{"tlsClientConfig":{"insecure":false}}`, - "Name": envutil.Getenv("DEPLOY_NAME"), - "Server": "https://kubernetes.default.svc", - "DEPLOY_NAME": envutil.Getenv("DEPLOY_NAME"), - "UC_DEPLOY_GIT_URL": envutil.Getenv("UC_DEPLOY_GIT_URL"), - "DNS_ZONE": envutil.Getenv("DNS_ZONE"), - } - - result, err := helpers.TemplateHelper(argoSecretDeployRepoTemplate, vars) - if err != nil { - return fmt.Errorf("template rendering failed: %w", err) - } - - outputFilePath := filepath.Join(basePath, fmt.Sprintf(clusterSecretFile, envutil.Getenv("DEPLOY_NAME"))) - - return writeToFile(outputFilePath, result) -} - -// generateClusterSecret generates the cluster secret -func generateClusterSecret(basePath string) error { - vars := map[string]any{ - "DEPLOY_NAME": envutil.Getenv("DEPLOY_NAME"), - "Type": "git", - "UC_DEPLOY_GIT_URL": envutil.Getenv("UC_DEPLOY_GIT_URL"), - "DNS_ZONE": envutil.Getenv("DNS_ZONE"), - "UC_DEPLOY_SSH_FILE": envutil.Getenv("UC_DEPLOY_SSH_FILE"), - } - - result, err := helpers.TemplateHelper(argoClusterTemplate, vars) - if err != nil { - return fmt.Errorf("template rendering failed: %w", err) - } - - outputFilePath := filepath.Join(basePath, secretDeployRepoFile) - return writeToFile(outputFilePath, result) -} - -// writeToFile writes content to a file with proper permissions -func writeToFile(filePath string, content string) error { - err := fsutil.WriteFile(filePath, content, os.ModePerm) - if err != nil { - return fmt.Errorf("file write failed: %w", err) - } - return nil -} diff --git a/cmd/argocd/templates/argoCluster.tmpl b/cmd/argocd/templates/argoCluster.tmpl deleted file mode 100644 index f1d48e8..0000000 --- a/cmd/argocd/templates/argoCluster.tmpl +++ /dev/null @@ -1,12 +0,0 @@ ---- -apiVersion: v1 -kind: Secret -metadata: - name: {{ .DEPLOY_NAME }}-repo - namespace: argocd - labels: - argocd.argoproj.io/secret-type: repo-creds -data: - sshPrivateKey: {{ .UC_DEPLOY_SSH_FILE }} - type: {{ .Type | b64enc }} - url: {{ .UC_DEPLOY_GIT_URL | b64enc }} diff --git a/cmd/argocd/templates/argoSecretDeployRepo.tmpl b/cmd/argocd/templates/argoSecretDeployRepo.tmpl deleted file mode 100644 index 0b9a6c7..0000000 --- a/cmd/argocd/templates/argoSecretDeployRepo.tmpl +++ /dev/null @@ -1,18 +0,0 @@ ---- -apiVersion: v1 -kind: Secret -data: - config: {{ .Config | b64enc }} - name: {{ .Name | b64enc }} - server: {{ .Server | b64enc }} -metadata: - name: {{ .DEPLOY_NAME }}-cluster - namespace: argocd - labels: - argocd.argoproj.io/secret-type: cluster - understack.rackspace.com/argocd: enabled - annotations: - uc_repo_git_url: "https://github.com/rackerlabs/understack.git" - uc_repo_ref: "HEAD" - uc_deploy_git_url: "{{ .UC_DEPLOY_GIT_URL }}" - uc_deploy_ref: "HEAD" diff --git a/cmd/certManager/certManger.go b/cmd/certManager/certManger.go deleted file mode 100644 index d4ae930..0000000 --- a/cmd/certManager/certManger.go +++ /dev/null @@ -1,57 +0,0 @@ -package certManager - -import ( - _ "embed" - "fmt" - "os" - - "github.com/rackerlabs/understackctl/helpers" - - "github.com/charmbracelet/log" - "github.com/gookit/goutil/envutil" - "github.com/gookit/goutil/fsutil" - - "github.com/spf13/cobra" -) - -//go:embed templates/clusterIssuer.tmpl -var clusterIssuerTemplate string - -func NewCmdCertManagerSecret() *cobra.Command { - return &cobra.Command{ - Use: "certmanager-secrets", - Short: "Generate certmanager-secrets secrets", - Long: "", - Run: certManagerGen, - } -} - -func certManagerGen(cmd *cobra.Command, args []string) { - err := clusterIssuer() - if err != nil { - log.Error("certManagerGen failed", "error", err) - } -} - -// credGen prints out the cli version number -func clusterIssuer() error { - vars := map[string]any{ - "UC_DEPLOY_EMAIL": envutil.Getenv("UC_DEPLOY_EMAIL"), - "DNS_ZONE": envutil.Getenv("DNS_ZONE"), - } - - result, err := helpers.TemplateHelper(string(clusterIssuerTemplate), vars) - if err != nil { - return fmt.Errorf("template rendering failed: %w", err) - } - - outputFilePath := helpers.GetManifestPathToService("cert-manager") + "/cluster-issuer.yaml" - - if err := fsutil.WriteFile(outputFilePath, result, os.ModePerm); err != nil { - log.Fatal("error in kustomization.yaml file", "err", err) - os.Exit(1) - } - helpers.UpdateKustomizeFile(helpers.GetManifestPathToService("cert-manager")) - - return nil -} diff --git a/cmd/certManager/templates/clusterIssuer.tmpl b/cmd/certManager/templates/clusterIssuer.tmpl deleted file mode 100644 index 7b0f37c..0000000 --- a/cmd/certManager/templates/clusterIssuer.tmpl +++ /dev/null @@ -1,27 +0,0 @@ ---- -apiVersion: cert-manager.io/v1 -kind: ClusterIssuer -metadata: - name: understack-cluster-issuer - annotations: - argocd.argoproj.io/sync-wave: "5" -spec: - acme: - email: {{ .UC_DEPLOY_EMAIL }} - privateKeySecretRef: - name: letsencrypt-prod - server: https://acme-v02.api.letsencrypt.org/directory - solvers: - - http01: - ingress: - ingressClassName: nginx - selector: - matchLabels: - authorizeWith: http - - dns01: - webhook: - groupName: acme.undercloud.rackspace.net - solverName: rackspace - config: - authSecretRef: cert-manager-webhook-rackspace-creds - domainName: {{ .DNS_ZONE }} diff --git a/cmd/dex/dex.go b/cmd/dex/dex.go deleted file mode 100644 index f3d010c..0000000 --- a/cmd/dex/dex.go +++ /dev/null @@ -1,58 +0,0 @@ -package dex - -import ( - "fmt" - "path/filepath" - - "github.com/rackerlabs/understackctl/helpers" - - "github.com/charmbracelet/log" - "github.com/gookit/goutil/envutil" - - "github.com/spf13/cobra" -) - -func NewCmdDexSecrets() *cobra.Command { - return &cobra.Command{ - Use: "dex-secrets", - Short: "Create dex secret for nautobot, argo, argocd, keystone, grafana", - Long: "Create dex secret for nautobot, argo, argocd, keystone, grafana", - Run: generateDexSecrets, - } -} - -func generateDexSecrets(cmd *cobra.Command, args []string) { - if err := generateDexServiceSecrets(); err != nil { - log.Error("Failed to generate secrets for dex", "err", err) - } -} - -// credGen prints out the cli version number -func generateDexServiceSecrets() error { - clients := []string{"nautobot", "argo", "argocd", "keystone", "grafana"} - - manifestPath := helpers.GetManifestPathToService("dex") - - for _, client := range clients { - - config := helpers.SecretConfig{ - Name: fmt.Sprintf("%s-sso", client), - Namespace: "dex", - Data: map[string]string{ - "client-secret": helpers.GenerateRandomString(32), - "client-id": client, - "issuer": fmt.Sprintf("https://dex.%s", envutil.Getenv("DNS_ZONE")), - }, - } - - outputFilePath := manifestPath + fmt.Sprintf("/secret-%s-sso-dex.yaml", client) - - if err := helpers.CreateKubeSealSecretFile(config, outputFilePath); err != nil { - return err - } - } - - helpers.UpdateKustomizeFile(filepath.Join(envutil.Getenv("DEPLOY_NAME"), "dex")) - - return nil -} diff --git a/cmd/helmConfig/helmConfig.go b/cmd/helmConfig/helmConfig.go deleted file mode 100644 index 411e1ac..0000000 --- a/cmd/helmConfig/helmConfig.go +++ /dev/null @@ -1,222 +0,0 @@ -package helmConfig - -import ( - "fmt" - "os" - "path/filepath" - - "github.com/rackerlabs/understackctl/helpers" - - "github.com/gookit/goutil/envutil" - "github.com/gookit/goutil/fsutil" - "github.com/spf13/cobra" -) - -func NewCmdHelmConfig() *cobra.Command { - return &cobra.Command{ - Use: "helm-config", - Short: "Create helm config for individual services", - Long: "", - Run: helmConfigGen, - } -} -func helmConfigGen(cmd *cobra.Command, args []string) { - functions := []func() error{ - dex, - glance, - ironic, - rook, - } - for _, fn := range functions { - if err := fn(); err != nil { - fmt.Printf("Error helmConfigGen: %v\n", err) - os.Exit(1) - } - } -} - -func dex() error { - template := `config: - staticClients: - - id: nautobot - secretEnv: NAUTOBOT_SSO_CLIENT_SECRET - name: "Undercloud Nautobot" - redirectURIs: - - "https://nautobot.{{ .DNS_ZONE }}/complete/oidc/" - - id: argo - secretEnv: ARGO_SSO_CLIENT_SECRET - name: "Undercloud Argo" - redirectURIs: - - "https://workflows.{{ .DNS_ZONE }}/oauth2/callback" - - id: argocd - secretEnv: ARGOCD_SSO_CLIENT_SECRET - name: "Undercloud ArgoCD" - redirectURIs: - - "https://argocd.{{ .DNS_ZONE }}/auth/callback"` - - vars := map[string]any{ - "DNS_ZONE": envutil.Getenv("DNS_ZONE"), - } - - data, err := helpers.TemplateHelper(template, vars) - if err != nil { - return fmt.Errorf("failed to render template: %w", err) - } - - filePath := filepath.Join( - envutil.Getenv("DEPLOY_NAME"), - "dex", - "values.yaml", - ) - - if err := fsutil.WriteFile(filePath, data, os.ModePerm); err != nil { - return fmt.Errorf("failed to write %s: %w", filePath, err) - } - return nil -} - -func glance() error { - template := `volume: - class_name: csi-cinder-sc-delete - size: 20Gi` - - filePath := filepath.Join( - envutil.Getenv("DEPLOY_NAME"), - "glance", - "values.yaml", - ) - - if err := fsutil.WriteFile(filePath, template, os.ModePerm); err != nil { - return fmt.Errorf("failed to write %s: %w", filePath, err) - } - - return nil -} - -func ironic() error { - template := `labels: - conductor: - node_selector_key: "understack.node.cluster.x-k8s.io/ironic-role" - node_selector_value: conductor - - conductor: - initContainers: - - name: create-tmpdir - image: ghcr.io/rackerlabs/understack/openstack-client:2026.1 - imagePullPolicy: IfNotPresent - command: [bash] - args: - - "-c" - - "mkdir -p /var/lib/openstack-helm/tmp" - volumeMounts: - - name: pod-data - mountPath: /var/lib/openstack-helm` - - filePath := filepath.Join( - envutil.Getenv("DEPLOY_NAME"), - "ironic", - "values.yaml", - ) - - if err := fsutil.WriteFile(filePath, template, os.ModePerm); err != nil { - return fmt.Errorf("failed to write %s: %w", filePath, err) - } - - return nil -} - -func rook() error { - template := `cephClusterSpec: - mon: - # Set the number of mons to be started. Generally recommended to be 3. - # For highest availability, an odd number of mons should be specified. - count: 2 - # The mons should be on unique nodes. For production, at least 3 nodes are recommended for this reason. - # Mons should only be allowed on the same node for test environments where data loss is acceptable. - allowMultiplePerNode: false - - mgr: - # When higher availability of the mgr is needed, increase the count to 2. - # In that case, one mgr will be active and one in standby. When Ceph updates which - # mgr is active, Rook will update the mgr services to match the active mgr. - count: 2 - allowMultiplePerNode: false - - storage: - useAllDevices: false - useAllNodes: true - deviceFilter: "vdb" - resources: - mgr: - limits: - memory: "1Gi" - requests: - cpu: "0" - memory: "512Mi" - mon: - limits: - memory: "2Gi" - requests: - cpu: "0" - memory: "1Gi" - osd: - limits: - memory: "4Gi" - requests: - cpu: "0" - memory: "4Gi" - prepareosd: - # limits: It is not recommended to set limits on the OSD prepare job - # since it's a one-time burst for memory that must be allowed to - # complete without an OOM kill. Note however that if a k8s - # limitRange guardrail is defined external to Rook, the lack of - # a limit here may result in a sync failure, in which case a - # limit should be added. 1200Mi may suffice for up to 15Ti - # OSDs ; for larger devices 2Gi may be required. - # cf. https://github.com/rook/rook/pull/11103 - requests: - cpu: "0" - memory: "50Mi" - mgr-sidecar: - limits: - memory: "100Mi" - requests: - cpu: "0" - memory: "40Mi" - crashcollector: - limits: - memory: "60Mi" - requests: - cpu: "0" - memory: "60Mi" - logcollector: - limits: - memory: "1Gi" - requests: - cpu: "0" - memory: "100Mi" - cleanup: - limits: - memory: "1Gi" - requests: - cpu: "0" - memory: "100Mi" - exporter: - limits: - memory: "128Mi" - requests: - cpu: "0" - memory: "50Mi"` - - filePath := filepath.Join( - envutil.Getenv("DEPLOY_NAME"), - "rook-cluster", - "values.yaml", - ) - - if err := fsutil.WriteFile(filePath, template, os.ModePerm); err != nil { - return fmt.Errorf("failed to write %s: %w", filePath, err) - } - - return nil -} diff --git a/cmd/openstack/secrets.go b/cmd/openstack/secrets.go deleted file mode 100644 index fe2af90..0000000 --- a/cmd/openstack/secrets.go +++ /dev/null @@ -1,47 +0,0 @@ -package openstack - -import ( - "github.com/rackerlabs/understackctl/helpers" - - "github.com/charmbracelet/log" - - "github.com/spf13/cobra" -) - -func NewCmdOpenstackSecrets() *cobra.Command { - return &cobra.Command{ - Use: "openstack-secrets", - Short: "Generate openstack-secrets", - Long: "Generate openstack-secrets", - Run: openStackGen, - } -} - -func openStackGen(cmd *cobra.Command, args []string) { - if err := generateMariaDBSecret(); err != nil { - log.Errorf("Failed to generate MariaDB secret: %v", err) - } -} - -// credGen prints out the cli version number -func generateMariaDBSecret() error { - filePath := helpers.GetManifestPathToService("openstack") + "/secret-mariadb.yaml" - - config := helpers.SecretConfig{ - Name: "mariadb", - Namespace: "openstack", - Data: map[string]string{ - "password": helpers.GenerateRandomString(32), - "root-password": helpers.GenerateRandomString(32), - }, - } - - if err := helpers.CreateKubeSealSecretFile(config, filePath); err != nil { - log.Warn("Failed to create sealed secret", "error", err) - return err - } - - helpers.UpdateKustomizeFile(helpers.GetManifestPathToService("openstack")) - - return nil -} diff --git a/cmd/other/openstack.go b/cmd/other/openstack.go deleted file mode 100644 index edb58cd..0000000 --- a/cmd/other/openstack.go +++ /dev/null @@ -1,141 +0,0 @@ -package other - -var SecretOpenStackTemplate = ` -# The purpose of this file is to serve as a template for OpenStack Helm -# based endpoints configuration so that OpenStack Helm populates the -# correct URLs in the configs that it generates for the various services ---- -endpoints: - # 'identity' endpoints are for keystone access - identity: - auth: - # this is the 'admin' user created in keystone by the initial start - # and used by the other services to create their service accounts - # and endpoint in the service catalog. - admin: - password: "{{ .KEYSTONE_ADMIN_PASSWORD }}" - # this user is the service account that glance uses - glance: - password: "{{ .GLANCE_KEYSTONE_PASSWORD }}" - # this user is the service account that ironic uses - ironic: - password: "{{ .IRONIC_KEYSTONE_PASSWORD }}" - # this user is the service account that neutron uses - neutron: - password: "{{ .NEUTRON_KEYSTONE_PASSWORD }}" - # this user is the service account that nova uses - nova: - password: "{{ .NOVA_KEYSTONE_PASSWORD }}" - # this user is the service account that placement uses - placement: - password: "{{ .PLACEMENT_KEYSTONE_PASSWORD }}" - - # set our public facing URL - host_fqdn_override: - public: - host: keystone.{{ .DNS_ZONE }} - - # 'oslo_cache' is the memcache layer - oslo_cache: - auth: - # this is used for encrypting / protecting the memcache tokens - memcache_secret_key: "{{ .MEMCACHE_SECRET_KEY }}" - - # 'oslo_db' is for MariaDB - oslo_db: - auth: - # this is what the keystone service uses to connect to MariaDB - keystone: - password: "{{ .KEYSTONE_DB_PASSWORD }}" - # this is what the glance service uses to connect to MariaDB - glance: - password: "{{ .GLANCE_DB_PASSWORD }}" - # this is what the ironic service uses to connect to MariaDB - ironic: - password: "{{ .IRONIC_DB_PASSWORD }}" - # this is what the neutron service uses to connect to MariaDB - neutron: - password: "{{ .NEUTRON_DB_PASSWORD }}" - # this is what the nova service uses to connect to MariaDB - nova: - password: "{{ .NOVA_DB_PASSWORD }}" - # this is what the placement service uses to connect to MariaDB - placement: - password: "{{ .PLACEMENT_DB_PASSWORD }}" - # this is what the horizon dashboard service uses to connect to MariaDB - horizon: - password: "{{ .HORIZON_DB_PASSWORD }}" - - # 'oslo_db_api' is for MariaDB specific for nova - oslo_db_api: - auth: - nova: - password: "{{ .NOVA_DB_PASSWORD }}" - - # 'oslo_db_cell0' is for MariaDB specific for nova - oslo_db_cell0: - auth: - nova: - password: "{{ .NOVA_DB_PASSWORD }}" - - # 'oslo_messaging' is for RabbitMQ - oslo_messaging: - auth: - # this is what the keystone service uses to connect to RabbitMQ - keystone: - password: "{{ .KEYSTONE_RABBITMQ_PASSWORD }}" - # this is what the glance service uses to connect to RabbitMQ - glance: - password: "{{ .GLANCE_RABBITMQ_PASSWORD }}" - # this is what the ironic service uses to connect to RabbitMQ - ironic: - password: "{{ .IRONIC_RABBITMQ_PASSWORD }}" - # this is what the neutron service uses to connect to RabbitMQ - neutron: - password: "{{ .NEUTRON_RABBITMQ_PASSWORD }}" - # this is what the nova service uses to connect to RabbitMQ - nova: - password: "{{ .NOVA_RABBITMQ_PASSWORD }}" - - # 'baremetal' is the ironic service - baremetal: - # set our public facing URL - host_fqdn_override: - public: - host: ironic.{{ .DNS_ZONE }} - - # 'image' is the glance service - image: - # set our public facing URL - host_fqdn_override: - public: - host: glance.{{ .DNS_ZONE }} - - # 'network' is the neutron service - network: - # set our public facing URL - host_fqdn_override: - public: - host: neutron.{{ .DNS_ZONE }} - - # 'compute' is the nova service - compute: - # set our public facing URL - host_fqdn_override: - public: - host: nova.{{ .DNS_ZONE }} - - # 'placement' is the nova service - placement: - # set our public facing URL - host_fqdn_override: - public: - host: placement.{{ .DNS_ZONE }} - - # 'dashboard' is the horizon service - dashboard: - # set our public facing URL - host_fqdn_override: - public: - host: horizon.{{ .DNS_ZONE }} -` diff --git a/cmd/other/other.go b/cmd/other/other.go deleted file mode 100644 index 587477f..0000000 --- a/cmd/other/other.go +++ /dev/null @@ -1,122 +0,0 @@ -package other - -import ( - "os" - "path/filepath" - - "github.com/rackerlabs/understackctl/helpers" - - "github.com/charmbracelet/log" - "github.com/gookit/goutil/envutil" - "github.com/gookit/goutil/fsutil" - "github.com/gookit/goutil/strutil" - - "context" - "fmt" - - "github.com/spf13/cobra" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -var openStackSecrets map[string]any - -func NewCmdOtherSecrets() *cobra.Command { - return &cobra.Command{ - Use: "other-secrets", - Short: "Create secret for keystone, ironic, placement, neutron, nova, glance", - Long: "Create secret for keystone, ironic, placement, neutron, nova, glance", - Run: generateOtherSecrets, - } -} - -func generateOtherSecrets(_ *cobra.Command, _ []string) { - // create constant OpenStack memcache key to avoid cache invalidation on deploy - openStackSecrets = map[string]any{ - "DNS_ZONE": envutil.Getenv("DNS_ZONE"), - "MEMCACHE_SECRET_KEY": helpers.GenerateRandomString(32), - "HORIZON_DB_PASSWORD": helpers.GenerateRandomString(32), - "KEYSTONE_ADMIN_PASSWORD": loadOrGenSecret("admin-keystone-password", "openstack"), - } - - services := []string{"keystone", "ironic", "placement", "neutron", "nova", "glance", "horizon"} - dependencies := []string{"rabbitmq", "keystone", "db"} - - for _, service := range services { - log.Warnf("Running For %s Services", service) - - if err := generateServiceSecrets(service, dependencies); err != nil { - log.Errorf("Failed to generate secrets for %s: %v", service, err) - } - } - - if err := updateOpenStackSecretsFile(); err != nil { - log.Fatal("failed to update openstack file", "err", err) - } - - // Create Empty Dirs - emptyDirs := []string{"argo-events", "ovn", "metallb", "undersync", "cilium"} - for _, service := range emptyDirs { - if err := fsutil.WriteFile(helpers.GetManifestPathToService(service)+"/.keep", "", os.ModePerm); err != nil { - log.Errorf("Failed creating .keep file for %s: %v", service, err) - } - } -} - -func generateServiceSecrets(service string, dependencies []string) error { - manifestPath := helpers.GetManifestPathToService(service) - - for _, dep := range dependencies { - secretName := fmt.Sprintf("secret-%s-password", dep) - filePath := filepath.Join(manifestPath, secretName+".yaml") - secret := loadOrGenSecret(fmt.Sprintf("%s-%s-password", service, dep), "openstack") - - config := helpers.SecretConfig{ - Name: secretName, - Namespace: "openstack", - Data: map[string]string{ - "username": service, - "password": secret, - }, - } - - if err := helpers.CreateKubeSealSecretFile(config, filePath); err != nil { - return err - } - // add all the passwords to map, for openstack secrets.yaml file - openStackSecrets[strutil.Uppercase(fmt.Sprintf("%s_%s_PASSWORD", service, dep))] = secret - } - - helpers.UpdateKustomizeFile(manifestPath) - - return nil -} - -func updateOpenStackSecretsFile() error { - data, err := helpers.TemplateHelper(SecretOpenStackTemplate, openStackSecrets) - if err != nil { - return fmt.Errorf("failed to render template: %w", err) - } - - secretFilePath := filepath.Join( - envutil.Getenv("DEPLOY_NAME"), - "secret-openstack.yaml", - ) - log.Info("updating secret-openstack.yaml", "path", secretFilePath) - - if err := fsutil.WriteFile(secretFilePath, data, os.ModePerm); err != nil { - return fmt.Errorf("failed to write %s: %w", secretFilePath, err) - } - return nil -} - -func loadOrGenSecret(serviceName, namespace string) string { - client, _ := helpers.KubeClientSet().CoreV1().Secrets(namespace).Get(context.Background(), serviceName, metav1.GetOptions{}) - encodedPassword, ok := client.Data["password"] - if ok { - log.Info("using password from cluster", "service", serviceName, "namespace", namespace) - return string(encodedPassword) - } - log.Warn("password not in cluster", "service", serviceName, "namespace", namespace) - log.Info("Creating Random password for", "service", serviceName, "namespace", namespace) - return helpers.GenerateRandomString(32) -} diff --git a/cmd/quickstart/quickstart.go b/cmd/quickstart/quickstart.go deleted file mode 100644 index ee0be34..0000000 --- a/cmd/quickstart/quickstart.go +++ /dev/null @@ -1,78 +0,0 @@ -package quickstart - -import ( - "fmt" - "os" - "os/exec" - - "github.com/charmbracelet/log" - "github.com/gookit/goutil/envutil" - "github.com/rackerlabs/understackctl/cmd/argocd" - "github.com/rackerlabs/understackctl/cmd/certManager" - "github.com/rackerlabs/understackctl/cmd/dex" - "github.com/rackerlabs/understackctl/cmd/helmConfig" - "github.com/rackerlabs/understackctl/cmd/node" - "github.com/rackerlabs/understackctl/cmd/openstack" - "github.com/rackerlabs/understackctl/cmd/other" - "github.com/spf13/cobra" -) - -func NewCmdQuickStart() *cobra.Command { - return &cobra.Command{ - Use: "quickstart", - Short: "Run all the steps required", - Long: "Run all the steps required", - Run: qsRun, - } -} - -func qsRun(cmd *cobra.Command, args []string) { - - log.Info("using envs", - "DEPLOY_NAME", envutil.Getenv("DEPLOY_NAME"), - "UC_DEPLOY_GIT_URL", envutil.Getenv("UC_DEPLOY_GIT_URL"), - "UC_DEPLOY_SSH_FILE", envutil.Getenv("UC_DEPLOY_SSH_FILE"), - "DNS_ZONE", envutil.Getenv("DNS_ZONE"), - "UC_DEPLOY_EMAIL", envutil.Getenv("UC_DEPLOY_EMAIL"), - "UC_AIO", envutil.Getenv("UC_AIO"), - ) - - var errors []string - - // Check if kubeseal is installed - _, err := exec.LookPath("kubeseal") - if err != nil { - errors = append(errors, "kubeseal is not installed on system, please install kubeseal binary") - } - - // If there are any errors, report them all and exit - if len(errors) > 0 { - for _, errMsg := range errors { - log.Warn(errMsg) - } - os.Exit(1) - } - - fmt.Println(envutil.Getenv("DEPLOY_NAME")) - - log.Info("== Node Update") - node.NewCmdNode().Run(cmd, args) - - log.Info("== Node ArgoCd") - argocd.NewCmdArgocdSecret().Run(cmd, args) - - log.Info("== Node Cert Manager") - certManager.NewCmdCertManagerSecret().Run(cmd, args) - - log.Info("== Running Dex") - dex.NewCmdDexSecrets().Run(cmd, args) - - log.Info("== Running For Other Services") - other.NewCmdOtherSecrets().Run(cmd, args) - - log.Info("== Running Openstack") - openstack.NewCmdOpenstackSecrets().Run(cmd, args) - - log.Info("== Creating Helm Configs") - helmConfig.NewCmdHelmConfig().Run(cmd, args) -} diff --git a/cmd/root/root.go b/cmd/root/root.go index c539d88..f858c12 100644 --- a/cmd/root/root.go +++ b/cmd/root/root.go @@ -3,18 +3,11 @@ package root import ( "fmt" - "github.com/rackerlabs/understackctl/cmd/argocd" - "github.com/rackerlabs/understackctl/cmd/certManager" "github.com/rackerlabs/understackctl/cmd/deploy" "github.com/rackerlabs/understackctl/cmd/deviceType" - "github.com/rackerlabs/understackctl/cmd/dex" "github.com/rackerlabs/understackctl/cmd/flavor" - "github.com/rackerlabs/understackctl/cmd/helmConfig" "github.com/rackerlabs/understackctl/cmd/nautobotOp" "github.com/rackerlabs/understackctl/cmd/node" - "github.com/rackerlabs/understackctl/cmd/openstack" - "github.com/rackerlabs/understackctl/cmd/other" - "github.com/rackerlabs/understackctl/cmd/quickstart" cmdversion "github.com/rackerlabs/understackctl/cmd/version" "github.com/rackerlabs/understackctl/internal/version" "github.com/spf13/cobra" @@ -33,17 +26,10 @@ var rootCmd = &cobra.Command{ func init() { rootCmd.AddCommand(deploy.NewCmdDeploy()) - rootCmd.AddCommand(argocd.NewCmdArgocdSecret()) - rootCmd.AddCommand(certManager.NewCmdCertManagerSecret()) rootCmd.AddCommand(deviceType.NewCmdDeviceType()) - rootCmd.AddCommand(dex.NewCmdDexSecrets()) rootCmd.AddCommand(flavor.NewCmdFlavor()) - rootCmd.AddCommand(helmConfig.NewCmdHelmConfig()) rootCmd.AddCommand(nautobotOp.NewCmdNautobotOp()) rootCmd.AddCommand(node.NewCmdNode()) - rootCmd.AddCommand(openstack.NewCmdOpenstackSecrets()) - rootCmd.AddCommand(quickstart.NewCmdQuickStart()) - rootCmd.AddCommand(other.NewCmdOtherSecrets()) rootCmd.AddCommand(cmdversion.NewCmdVersion()) } diff --git a/dex/values.yaml b/dex/values.yaml new file mode 100755 index 0000000..1d0a54d --- /dev/null +++ b/dex/values.yaml @@ -0,0 +1,17 @@ +config: + staticClients: + - id: nautobot + secretEnv: NAUTOBOT_SSO_CLIENT_SECRET + name: "Undercloud Nautobot" + redirectURIs: + - "https://nautobot./complete/oidc/" + - id: argo + secretEnv: ARGO_SSO_CLIENT_SECRET + name: "Undercloud Argo" + redirectURIs: + - "https://workflows./oauth2/callback" + - id: argocd + secretEnv: ARGOCD_SSO_CLIENT_SECRET + name: "Undercloud ArgoCD" + redirectURIs: + - "https://argocd./auth/callback" \ No newline at end of file diff --git a/glance/values.yaml b/glance/values.yaml new file mode 100755 index 0000000..486cf13 --- /dev/null +++ b/glance/values.yaml @@ -0,0 +1,3 @@ +volume: + class_name: csi-cinder-sc-delete + size: 20Gi \ No newline at end of file diff --git a/go.mod b/go.mod index 21b1879..173be13 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module github.com/rackerlabs/understackctl go 1.26.0 require ( - github.com/Masterminds/sprig/v3 v3.3.0 github.com/charmbracelet/log v1.0.0 github.com/google/go-containerregistry v0.22.1 github.com/gookit/goutil v0.8.4 @@ -11,16 +10,11 @@ require ( github.com/spf13/cobra v1.10.2 github.com/spf13/viper v1.21.0 gopkg.in/yaml.v3 v3.0.1 - k8s.io/api v0.37.1 k8s.io/apimachinery v0.37.1 k8s.io/client-go v0.37.1 - sigs.k8s.io/yaml v1.6.0 ) require ( - dario.cat/mergo v1.0.2 // indirect - github.com/Masterminds/goutils v1.1.1 // indirect - github.com/Masterminds/semver/v3 v3.5.0 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/charmbracelet/colorprofile v0.4.3 // indirect github.com/charmbracelet/lipgloss v1.1.0 // indirect @@ -32,37 +26,23 @@ require ( github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/docker/cli v29.9.2+incompatible // indirect github.com/docker/docker-credential-helpers v0.9.12 // indirect - github.com/emicklei/go-restful/v3 v3.13.0 // indirect github.com/fsnotify/fsnotify v1.10.1 // indirect github.com/fxamacker/cbor/v2 v2.9.6 // indirect github.com/go-logfmt/logfmt v0.6.1 // indirect github.com/go-logr/logr v1.4.4 // indirect github.com/go-openapi/jsonpointer v1.0.2 // indirect github.com/go-openapi/jsonreference v1.0.3 // indirect - github.com/go-openapi/swag v0.27.1 // indirect - github.com/go-openapi/swag/cmdutils v0.27.1 // indirect github.com/go-openapi/swag/conv v0.29.2 // indirect - github.com/go-openapi/swag/fileutils v0.27.1 // indirect github.com/go-openapi/swag/jsonutils v0.29.2 // indirect - github.com/go-openapi/swag/loading v0.27.1 // indirect - github.com/go-openapi/swag/mangling v0.27.1 // indirect - github.com/go-openapi/swag/netutils v0.27.1 // indirect - github.com/go-openapi/swag/pools v0.29.2 // indirect - github.com/go-openapi/swag/stringutils v0.27.1 // indirect github.com/go-openapi/swag/typeutils v0.29.2 // indirect - github.com/go-openapi/swag/yamlutils v0.27.1 // indirect github.com/go-viper/mapstructure/v2 v2.5.0 // indirect github.com/google/gnostic-models v0.7.1 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/huandu/xstrings v1.6.3 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.20.3 // indirect github.com/lucasb-eyer/go-colorful v1.4.1 // indirect github.com/mattn/go-isatty v0.0.24 // indirect github.com/mattn/go-runewidth v0.0.31 // indirect - github.com/mitchellh/copystructure v1.2.0 // indirect - github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect github.com/muesli/termenv v0.16.0 // indirect @@ -72,7 +52,6 @@ require ( github.com/pelletier/go-toml/v2 v2.4.3 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/sagikazarmark/locafero v0.12.0 // indirect - github.com/shopspring/decimal v1.6.0 // indirect github.com/sirupsen/logrus v1.10.2 // indirect github.com/spf13/afero v1.15.0 // indirect github.com/spf13/cast v1.10.0 // indirect @@ -82,7 +61,6 @@ require ( github.com/xo/terminfo v1.2.0 // indirect go.yaml.in/yaml/v2 v2.4.4 // indirect go.yaml.in/yaml/v3 v3.0.5 // indirect - golang.org/x/crypto v0.58.0 // indirect golang.org/x/exp v0.0.0-20261014143641-f0251eb4aa3e // indirect golang.org/x/net v0.61.0 // indirect golang.org/x/oauth2 v0.37.0 // indirect @@ -92,7 +70,6 @@ require ( golang.org/x/text v0.43.0 // indirect golang.org/x/time v0.16.0 // indirect google.golang.org/protobuf v1.36.12 // indirect - gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gotest.tools/v3 v3.5.2 // indirect k8s.io/klog/v2 v2.140.0 // indirect @@ -101,4 +78,5 @@ require ( sigs.k8s.io/json v0.0.0-20260909141634-11ed52e25bc5 // indirect sigs.k8s.io/randfill v1.0.0 // indirect sigs.k8s.io/structured-merge-diff/v6 v6.4.2 // indirect + sigs.k8s.io/yaml v1.6.0 // indirect ) diff --git a/go.sum b/go.sum index c29636c..cb3bd18 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,3 @@ -dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8= -dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA= -github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= -github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= -github.com/Masterminds/semver/v3 v3.5.0 h1:kQceYJfbupGfZOKZQg0kou0DgAKhzDg2NZPAwZ/2OOE= -github.com/Masterminds/semver/v3 v3.5.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= -github.com/Masterminds/sprig/v3 v3.3.0 h1:mQh0Yrg1XPo6vjYXgtf5OtijNAKJRNcTdOOGZe3tPhs= -github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSCzdgBfDb35Lz0= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/charmbracelet/colorprofile v0.4.3 h1:QPa1IWkYI+AOB+fE+mg/5/4HRMZcaXex9t5KX76i20Q= @@ -59,8 +51,6 @@ github.com/go-openapi/swag/fileutils v0.27.1 h1:QQqBSoi5mW4XpU85nS0mLcA+zAE6vLzr github.com/go-openapi/swag/fileutils v0.27.1/go.mod h1:VvJFZLTZS0AI854gEQz5tk7dBESdLjiNUMSZ/th2ry8= github.com/go-openapi/swag/jsonutils v0.29.2 h1:uZNSD2/rJDYAfvsLYkykTzXuyxM3QpDKV9jhRHrMu6k= github.com/go-openapi/swag/jsonutils v0.29.2/go.mod h1:ONTdNvj3Y+IXRzfa17E+Rgt2ns/qiSOYjIo2K7v2yDs= -github.com/go-openapi/swag/jsonutils/fixtures_test v0.29.2 h1:w+Fd6EBOMGlC74GYGHqCLGyb3Bpams8TtNrgM/SG4jo= -github.com/go-openapi/swag/jsonutils/fixtures_test v0.29.2/go.mod h1:HC2egPORFzbj/gf05Zrfgz8Mgplx3oW7hgGi7pjZVhM= github.com/go-openapi/swag/loading v0.27.1 h1:/DxUgDXKbBX4bcn7r9uEXfJyzN5XpiJmZplzQTjrRCY= github.com/go-openapi/swag/loading v0.27.1/go.mod h1:jvGh3iA2+zyUUycB5fgJWzeHnhrpvGnJJM0RVE9ZShE= github.com/go-openapi/swag/mangling v0.27.1 h1:yC9D0HyUE8gbP+BfmGx9+AA89ikwZTMjESK3OnnoaqA= @@ -75,10 +65,6 @@ github.com/go-openapi/swag/typeutils v0.29.2 h1:O7aVvkTs3pXwikgtrPLenigEMdQFgONK github.com/go-openapi/swag/typeutils v0.29.2/go.mod h1:7+GDG+uz9Ke+eVt4rClZg7wklSDp8hT/mKNh/pC26TE= github.com/go-openapi/swag/yamlutils v0.27.1 h1:ftxv6xvXb1E3zohUc+okZ9nSqNb9StQX/FXnKZ98sQA= github.com/go-openapi/swag/yamlutils v0.27.1/go.mod h1:bnxFIB1qewGRiZHypXGZ3fNgf13/0HfRgnS/iZBDrOo= -github.com/go-openapi/testify/enable/yaml/v2 v2.7.0 h1:wPW6YRgx3+SID1yUy/Xwa17L8kFEaEKod2VRbJDZNUs= -github.com/go-openapi/testify/enable/yaml/v2 v2.7.0/go.mod h1:mI1M88etYbc3PhgHsWQK2kwvNwW5aGFqMPbmib+SGIs= -github.com/go-openapi/testify/v2 v2.8.0 h1:19QDx5b57p8KjO2E4sgs/woL4Akp+FGLRlVm2xn0Rho= -github.com/go-openapi/testify/v2 v2.8.0/go.mod h1:4gUN8jC+RqOE2qjW/vDmfyTvl5BCht4qL7oca0odrak= github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro= github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/google/gnostic-models v0.7.1 h1:SisTfuFKJSKM5CPZkffwi6coztzzeYUhc3v4yxLWH8c= @@ -92,8 +78,6 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gookit/goutil v0.8.4 h1:LU93xrWsR+csbPMLI65pavJ/qD65g8pWeRaTdqbmHA0= github.com/gookit/goutil v0.8.4/go.mod h1:vJS9HXctYTCLtCsZot5L5xF+O1oR17cDYO9R0HxBmnU= -github.com/huandu/xstrings v1.6.3 h1:7997PcI0mYC9uPNBJ7udg/KrdJh1GhJid8f2tzKFHYQ= -github.com/huandu/xstrings v1.6.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= @@ -110,10 +94,6 @@ github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsRe github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A= github.com/mattn/go-runewidth v0.0.31 h1:1oCV4ReTlosDBc6rYRw5cL8S/4y8iv5oRl4SJ5IBgwo= github.com/mattn/go-runewidth v0.0.31/go.mod h1:3qAiGCV4Koz/yuveO58qUefmUTRm8r0IGEXZ9jeHp/8= -github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= -github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= -github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= -github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -142,8 +122,6 @@ github.com/sagikazarmark/locafero v0.12.0 h1:/NQhBAkUb4+fH1jivKHWusDYFjMOOKU88ee github.com/sagikazarmark/locafero v0.12.0/go.mod h1:sZh36u/YSZ918v0Io+U9ogLYQJ9tLLBmM4eneO6WwsI= github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4= github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY= -github.com/shopspring/decimal v1.6.0 h1:DcTwjCj4tJPLuGZYsR9W0hyX9pQwMIkdo26Ig1T9xX4= -github.com/shopspring/decimal v1.6.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME= github.com/sirupsen/logrus v1.10.2 h1:G2SED73/qrAu6YwbdxOD6peLkCBI3z7L+ykJFTXJBBo= github.com/sirupsen/logrus v1.10.2/go.mod h1:SLEg8TqYulVKKfIGHldVp2K2aYz2DKSVBq4g/H5bR7Q= github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I= @@ -174,8 +152,6 @@ go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= -golang.org/x/crypto v0.58.0 h1:COkYLr4k7nDI4r6QtMML2AfzeIswWHAJthLS6K/M/54= -golang.org/x/crypto v0.58.0/go.mod h1:Xh+kl5A+M0gMiWDytH2Hhr5Z7WbNCpv/eB/EFgfSk+w= golang.org/x/exp v0.0.0-20261014143641-f0251eb4aa3e h1:HgI6W1OolKK6tcV74is+rl9SMT0njsHlp0TbQiGXI/A= golang.org/x/exp v0.0.0-20261014143641-f0251eb4aa3e/go.mod h1:DBoxwWhjaW8DJJw/YeM4zpeOKMC1FMXSblsYy+1mFSw= golang.org/x/net v0.61.0 h1:RR+6j/BTBCrggOLugxa+66R8FvoN6MHlzDlZIbN9YFw= diff --git a/helpers/helpers.go b/helpers/helpers.go deleted file mode 100644 index 69b0c43..0000000 --- a/helpers/helpers.go +++ /dev/null @@ -1,48 +0,0 @@ -package helpers - -import ( - "path/filepath" - - "github.com/charmbracelet/log" - "github.com/gookit/goutil/envutil" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/yaml" -) - -// SecretConfig holds configuration for creating secrets -type SecretConfig struct { - Name string - Namespace string - Data map[string]string -} - -func GetManifestPathToService(service string) string { - return filepath.Join( - envutil.Getenv("DEPLOY_NAME"), - service, - ) -} - -func CreateKubeSealSecretFile(config SecretConfig, filePath string) error { - secret := &corev1.Secret{ - TypeMeta: metav1.TypeMeta{ - Kind: "Secret", - APIVersion: "v1", - }, - ObjectMeta: metav1.ObjectMeta{ - Name: config.Name, - Namespace: config.Namespace, - }, - Type: corev1.SecretTypeOpaque, - StringData: config.Data, - } - - secretYAML, err := yaml.Marshal(secret) - if err != nil { - return err - } - - log.Info("creating kubeseal secret", "path", filePath) - return KubeSeal(secretYAML, filePath) -} diff --git a/helpers/kube.go b/helpers/kube.go deleted file mode 100644 index acf8eff..0000000 --- a/helpers/kube.go +++ /dev/null @@ -1,24 +0,0 @@ -package helpers - -import ( - "log" - - "k8s.io/client-go/kubernetes" - "k8s.io/client-go/tools/clientcmd" -) - -func KubeClientSet() *kubernetes.Clientset { - // Load kubeconfig from the default location (~/.kube/config) - config, err := clientcmd.BuildConfigFromFlags("", clientcmd.RecommendedHomeFile) - if err != nil { - log.Fatalf("Failed to load kubeconfig: %v", err) - } - - // Create Kubernetes clientset - clientset, err := kubernetes.NewForConfig(config) - if err != nil { - log.Fatalf("Failed to create Kubernetes client: %v", err) - } - - return clientset -} diff --git a/helpers/kubeseal.go b/helpers/kubeseal.go deleted file mode 100644 index e076eb4..0000000 --- a/helpers/kubeseal.go +++ /dev/null @@ -1,61 +0,0 @@ -package helpers - -import ( - "bytes" - "fmt" - "os" - "os/exec" - - "github.com/charmbracelet/log" - "github.com/gookit/goutil/fsutil" -) - -func KubeSeal(inputData []byte, outputPath string) error { - // Convert secret to YAML first - tmpFile, err := os.CreateTemp("", "secret-*.yaml") - if err != nil { - return err - } - defer removeTempFile(tmpFile) - - if _, err := tmpFile.Write([]byte(inputData)); err != nil { - return err - } - if err := tmpFile.Close(); err != nil { - return err - } - - cmd := exec.Command("kubeseal", - "--scope", "cluster-wide", - "--allow-empty-data", - "--format", "yaml", - ) - // Set up stdin - cmd.Stdin, err = os.Open(tmpFile.Name()) - if err != nil { - return err - } - - // Capture output - var out bytes.Buffer - cmd.Stdout = &out - - // Run command - err = cmd.Run() - if err != nil { - log.Info("err", "err", err) - return fmt.Errorf("kubeseal failed: %v", err) - } - - err = fsutil.WriteFile(outputPath, out.String(), os.ModePerm) - if err != nil { - log.Fatal("error in kustomization.yaml file", "err", err) - } - return nil -} - -func removeTempFile(file *os.File) { - if err := os.Remove(file.Name()); err != nil { - log.Printf("Failed to remove temporary file: %v", err) - } -} diff --git a/helpers/kustomization.go b/helpers/kustomization.go deleted file mode 100644 index 6198b5b..0000000 --- a/helpers/kustomization.go +++ /dev/null @@ -1,69 +0,0 @@ -package helpers - -import ( - "fmt" - "io/fs" - "os" - "path/filepath" - "sort" - "strings" - - "github.com/charmbracelet/log" - "github.com/gookit/goutil/fsutil" -) - -const kustomizationFile = "kustomization.yaml" - -func UpdateKustomizeFile(dir string) { - files, err := scanYamlFiles(dir) - if err != nil { - log.Fatalf("Error scanning directory: %v", err) - } - - if len(files) == 0 { - log.Info("No YAML files found to include in kustomization.yaml") - return - } - - kustomization := buildKustomizationYAML(files) - - kustomPath := filepath.Join(dir, kustomizationFile) - err = os.WriteFile(kustomPath, []byte(kustomization), 0644) - if err != nil { - log.Fatalf("Error writing kustomization.yaml: %v", err) - } - - log.Printf("Successfully wrote %s with %d resources.\n", kustomPath, len(files)) -} - -func scanYamlFiles(dir string) ([]string, error) { - fileSet := make(map[string]bool) - - err := fsutil.FindInDir(dir, func(filePath string, de fs.DirEntry) error { - fileSet[de.Name()] = true - return nil - }, fsutil.IncludeSuffix(".yaml", ".yml"), - fsutil.ExcludeDotFile, - fsutil.ExcludeNames(kustomizationFile)) - if err != nil { - return nil, err - } - - var uniqueFiles []string - for f := range fileSet { - uniqueFiles = append(uniqueFiles, f) - } - sort.Strings(uniqueFiles) - return uniqueFiles, nil -} - -func buildKustomizationYAML(resources []string) string { - var sb strings.Builder - sb.WriteString("apiVersion: kustomize.config.k8s.io/v1beta1\n") - sb.WriteString("kind: Kustomization\n") - sb.WriteString("resources:\n") - for _, res := range resources { - fmt.Fprintf(&sb, "- %s\n", res) - } - return sb.String() -} diff --git a/helpers/random.go b/helpers/random.go deleted file mode 100644 index de6ef93..0000000 --- a/helpers/random.go +++ /dev/null @@ -1,30 +0,0 @@ -package helpers - -import ( - "crypto/rand" - "log" - "math/big" - "os" -) - -func GenerateRandomString(length int) string { - // Define the dictionary: _A-Za-z0-9 - const dictionary = "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" - dictLen := big.NewInt(int64(len(dictionary))) - - // Buffer to hold the result - result := make([]byte, length) - - // Generate random indices into the dictionary - for i := 0; i < length; i++ { - // Generate a secure random number between 0 and dictLen-1 - n, err := rand.Int(rand.Reader, dictLen) - if err != nil { - log.Fatal("failed to generate random password", "err", err) - os.Exit(1) - } - result[i] = dictionary[n.Int64()] - } - - return string(result) -} diff --git a/helpers/template.go b/helpers/template.go deleted file mode 100644 index 2b2554c..0000000 --- a/helpers/template.go +++ /dev/null @@ -1,22 +0,0 @@ -package helpers - -import ( - "bytes" - "text/template" - - "github.com/Masterminds/sprig/v3" -) - -// TemplateHelper renders a template string using the provided variables -func TemplateHelper(tmplStr string, vars map[string]any) (string, error) { - tmpl, err := template.New("tmpl"). - Funcs(sprig.TxtFuncMap()). - Option("missingkey=error"). - Parse(tmplStr) - if err != nil { - return "", err - } - var buf bytes.Buffer - err = tmpl.Execute(&buf, vars) - return buf.String(), err -} diff --git a/ironic/values.yaml b/ironic/values.yaml new file mode 100755 index 0000000..193e1ae --- /dev/null +++ b/ironic/values.yaml @@ -0,0 +1,17 @@ +labels: + conductor: + node_selector_key: "understack.node.cluster.x-k8s.io/ironic-role" + node_selector_value: conductor + + conductor: + initContainers: + - name: create-tmpdir + image: ghcr.io/rackerlabs/understack/openstack-client:2025.2 + imagePullPolicy: IfNotPresent + command: [bash] + args: + - "-c" + - "mkdir -p /var/lib/openstack-helm/tmp" + volumeMounts: + - name: pod-data + mountPath: /var/lib/openstack-helm \ No newline at end of file diff --git a/rook-cluster/values.yaml b/rook-cluster/values.yaml new file mode 100755 index 0000000..8ce0f55 --- /dev/null +++ b/rook-cluster/values.yaml @@ -0,0 +1,81 @@ +cephClusterSpec: + mon: + # Set the number of mons to be started. Generally recommended to be 3. + # For highest availability, an odd number of mons should be specified. + count: 2 + # The mons should be on unique nodes. For production, at least 3 nodes are recommended for this reason. + # Mons should only be allowed on the same node for test environments where data loss is acceptable. + allowMultiplePerNode: false + + mgr: + # When higher availability of the mgr is needed, increase the count to 2. + # In that case, one mgr will be active and one in standby. When Ceph updates which + # mgr is active, Rook will update the mgr services to match the active mgr. + count: 2 + allowMultiplePerNode: false + + storage: + useAllDevices: false + useAllNodes: true + deviceFilter: "vdb" + resources: + mgr: + limits: + memory: "1Gi" + requests: + cpu: "0" + memory: "512Mi" + mon: + limits: + memory: "2Gi" + requests: + cpu: "0" + memory: "1Gi" + osd: + limits: + memory: "4Gi" + requests: + cpu: "0" + memory: "4Gi" + prepareosd: + # limits: It is not recommended to set limits on the OSD prepare job + # since it's a one-time burst for memory that must be allowed to + # complete without an OOM kill. Note however that if a k8s + # limitRange guardrail is defined external to Rook, the lack of + # a limit here may result in a sync failure, in which case a + # limit should be added. 1200Mi may suffice for up to 15Ti + # OSDs ; for larger devices 2Gi may be required. + # cf. https://github.com/rook/rook/pull/11103 + requests: + cpu: "0" + memory: "50Mi" + mgr-sidecar: + limits: + memory: "100Mi" + requests: + cpu: "0" + memory: "40Mi" + crashcollector: + limits: + memory: "60Mi" + requests: + cpu: "0" + memory: "60Mi" + logcollector: + limits: + memory: "1Gi" + requests: + cpu: "0" + memory: "100Mi" + cleanup: + limits: + memory: "1Gi" + requests: + cpu: "0" + memory: "100Mi" + exporter: + limits: + memory: "128Mi" + requests: + cpu: "0" + memory: "50Mi" \ No newline at end of file