Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
22 changes: 6 additions & 16 deletions mage/Magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,22 +464,19 @@ type Deploy mg.Namespace

// Deploy kind cluster, Argo CD, and all Orchestrator services.
func (d Deploy) KindAll() error {
return d.all("dev")
return d.KindPreset(filepath.Join(getConfigsDir(), "presets", "dev-coder.yaml"))
}

// Deploy kind cluster, Argo CD, and all Orchestrator services except o11y and kyverno.
func (d Deploy) KindMinimal() error {
return d.all("dev-minimal")
return d.KindPreset(filepath.Join(getConfigsDir(), "presets", "dev-coder-minimal.yaml"))
}

// 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.
Expand Down Expand Up @@ -1203,6 +1200,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()
}
Expand Down Expand Up @@ -1834,14 +1832,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)
Expand Down
73 changes: 55 additions & 18 deletions mage/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"io"
"os"
"path/filepath"
"strconv"
"strings"
"text/template"

Expand All @@ -22,6 +23,8 @@ var (
"targetCluster": "kind",
"clusterDomain": serviceDomain,
"argoServiceType": "LoadBalancer",
"enableAppOrch": true,
"enableClusterOrch": true,
"enableObservability": true,
"enableAuditLogging": false,
"enableKyverno": true,
Expand All @@ -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
Expand Down Expand Up @@ -139,8 +125,54 @@ func parseClusterValues(clusterConfigPath string) (map[string]interface{}, error
return clusterValues, nil
}

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.

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 values file.
func (Config) usePreset(clusterPresetFile string) (string, error) {
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)
Expand All @@ -164,6 +196,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)
Expand Down
69 changes: 0 additions & 69 deletions orch-configs/clusters/dev-minimal.yaml

This file was deleted.

79 changes: 0 additions & 79 deletions orch-configs/clusters/dev.yaml

This file was deleted.

15 changes: 15 additions & 0 deletions orch-configs/presets/dev-coder-minimal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-FileCopyrightText: 2025 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0

name: dev-coder-minimal
id: dev
enableObservability: false
enableKyverno: false
enableUiDev: true
enableAutoProvision: false
enableAutoCert: true
enableCoder: true
enableMailpit: true
targetCluster: kind
enableOsrmManualMode: true
16 changes: 16 additions & 0 deletions orch-configs/presets/dev-coder.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# SPDX-FileCopyrightText: 2025 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0

name: dev-coder
id: dev
enableObservability: true
enableAuditLogging: true
enableKyverno: true
enableAutoProvision: false
enableUiDev: true
enableAutoCert: true
enableCoder: true
enableMailpit: true
targetCluster: kind
enableOsrmManualMode: true
6 changes: 6 additions & 0 deletions orch-configs/templates/cluster.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,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 }}
Expand Down Expand Up @@ -130,7 +134,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 }}
Expand Down
Loading