diff --git a/mage/Magefile.go b/mage/Magefile.go index 71dc215ce..798e0190c 100644 --- a/mage/Magefile.go +++ b/mage/Magefile.go @@ -474,12 +474,9 @@ func (d Deploy) KindMinimal() error { // Deploy kind cluster, Argo CD, and Orchestrator services with customized settings. func (d Deploy) KindCustom() error { - targetEnv, err := Config{}.createCluster() - if err != nil { - return fmt.Errorf("failed to create cluster: %w", err) - } - - return d.all(targetEnv) + fmt.Println("Interactive cluster configuration is not currently supported.") + fmt.Println("Use config:usePreset with a manually generated preset file until this functionality is supported.") + return fmt.Errorf("unsupported") } // Deploy kind cluster, Argo CD, and Orchestrator services with preset settings. @@ -1204,6 +1201,7 @@ func (d Deploy) OrchLocal(targetEnv string) error { return d.orchLocal(targetEnv) } +// OrchCA Saves Orchestrators's CA certificate to `orch-ca.crt` so it can be imported to trust store for web access. func (d Deploy) OrchCA() error { return d.orchCA() } @@ -1835,14 +1833,6 @@ func (g Gen) FirewallDoc() error { type Config mg.Namespace -func (c Config) CreateCluster() error { - _, err := c.createCluster() - if err != nil { - return fmt.Errorf("failed to create cluster: %w", err) - } - return nil -} - // Create a cluster deployment configuration from a cluster values file. func (c Config) UsePreset(clusterPresetFile string) error { _, err := c.usePreset(clusterPresetFile) diff --git a/mage/config.go b/mage/config.go index ff899f29d..9ef2e77fd 100644 --- a/mage/config.go +++ b/mage/config.go @@ -10,6 +10,7 @@ import ( "io" "os" "path/filepath" + "strconv" "strings" "text/template" @@ -22,6 +23,8 @@ var ( "targetCluster": "kind", "clusterDomain": serviceDomain, "argoServiceType": "LoadBalancer", + "enableAppOrch": true, + "enableClusterOrch": true, "enableObservability": true, "enableAuditLogging": false, "enableKyverno": true, @@ -37,23 +40,6 @@ var ( } ) -func (c Config) createCluster() (string, error) { - fmt.Println("Interactive cluster configuration is not currently supported.") - fmt.Println("Use config:usePreset with a manually generated preset file until this functionality is supported.") - - // TBD: Implement interactive queryClusterPresetSettings interface - // clusterSettings, err := queryClusterPresetSettings() - // if err != nil { - // return "", fmt.Errorf("invalid cluster settings: %w", err) - // } - - // Render the cluster deployment configuration template. - // clusterName, err := renderClusterTemplate(clusterSettings) - // return clusterName, nil - - return "", nil -} - // writeMapAsYAML writes a map[string]interface{} as a YAML string. func writeMapAsYAML(data map[string]interface{}) (string, error) { var sb strings.Builder @@ -139,8 +125,58 @@ func parseClusterValues(clusterConfigPath string) (map[string]interface{}, error return clusterValues, nil } -// Create a cluster deployment configuration from a cluster values file. -func (Config) usePreset(clusterPresetFile string) (string, error) { +func (Config) overrideFromEnvironment(presetData map[string]interface{}) error { + // DISABLE_AO_PROFILE, DISABLE_CO_PROFILE, DISABLE_O11Y_PROFILE environment + // variables may be used to disable specific subsystems. These environment variable + // names are chosen to maintain parity with the AWS and OnPrem installer environment + // variable names. + // + // Note that these are only use when using presents, i.e. "mage deploy:kindPreset". + // The "mage deploy:Kind" and "deploy: KindMinimal" targets do not use presets and + // are not affected by these environment variables. + + var err error + var disableAO bool + disableAOStr := os.Getenv("DISABLE_AO_PROFILE") + if disableAOStr != "" { + disableAO, err = strconv.ParseBool(disableAOStr) + if err != nil { + return fmt.Errorf("failed to parse DISABLE_AO_PROFILE environment variable: %w", err) + } + } + if disableAO { + presetData["enableAppOrch"] = false + } + + var disableCO bool + disableCOStr := os.Getenv("DISABLE_CO_PROFILE") + if disableCOStr != "" { + disableCO, err = strconv.ParseBool(disableCOStr) + if err != nil { + return fmt.Errorf("failed to parse DISABLE_CO_PROFILE environment variable: %w", err) + } + } + if disableCO { + presetData["enableClusterOrch"] = false + presetData["enableAppOrch"] = false + } + + var disableO11y bool + disableO11yStr := os.Getenv("DISABLE_O11Y_PROFILE") + if disableO11yStr != "" { + disableO11y, err = strconv.ParseBool(disableO11yStr) + if err != nil { + return fmt.Errorf("failed to parse DISABLE_O11Y_PROFILE environment variable: %w", err) + } + } + if disableO11y { + presetData["enableObservability"] = false + } + return nil +} + +// Create a cluster deployment configuration from a cluster template and a preset file. +func (c Config) usePreset(clusterPresetFile string) (string, error) { clusterValues, err := os.ReadFile(clusterPresetFile) if err != nil { return "", fmt.Errorf("failed to read cluster preset file: %w", err) @@ -164,6 +200,11 @@ func (Config) usePreset(clusterPresetFile string) (string, error) { presetData["proxyProfile"] = proxyProfilePath } + err = c.overrideFromEnvironment(presetData) + if err != nil { + return "", fmt.Errorf("failed to override preset data from environment: %w", err) + } + var clusterName string if clusterName, err = renderClusterTemplate(presetData); err != nil { return "", fmt.Errorf("failed to render cluster template: %w", err) diff --git a/orch-configs/templates/cluster.tpl b/orch-configs/templates/cluster.tpl index ac8b53208..100a42b43 100644 --- a/orch-configs/templates/cluster.tpl +++ b/orch-configs/templates/cluster.tpl @@ -19,8 +19,12 @@ root: {{- if .Values.enableKyverno }} - orch-configs/profiles/enable-kyverno.yaml {{- end }} +{{- if .Values.enableAppOrch }} - orch-configs/profiles/enable-app-orch.yaml +{{- end }} +{{- if .Values.enableClusterOrch }} - orch-configs/profiles/enable-cluster-orch.yaml +{{- end }} {{- if .Values.enableEdgeInfra }} - orch-configs/profiles/enable-edgeinfra.yaml {{- end }} @@ -133,7 +137,9 @@ orchestratorDeployment: targetCluster: {{ .Values.targetCluster }} enableMailpit: {{ .Values.enableMailpit }} argoServiceType: {{ .Values.argoServiceType }} +{{- if .Values.dockerCache }} dockerCache: "{{ .Values.dockerCache }}" +{{- end }} {{- if and .Values.dockerCacheCert }} dockerCacheCert: | {{ .Values.dockerCacheCert | indent 4 }}