Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADXT-84] Add custom helm config argument for create-vm #1371

Merged
merged 9 commits into from
Jan 23, 2025
6 changes: 6 additions & 0 deletions common/config/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const (
DDAgentExtraEnvVars = "extraEnvVars" // extraEnvVars is expected in the format: <key1>=<value1>,<key2>=<value2>,...
DDAgentJMX = "jmx"
DDAgentFIPS = "fips"
DDAgentHelmConfig = "helmConfig"

// Updater Namespace
DDUpdaterParamName = "deploy"
Expand Down Expand Up @@ -125,6 +126,7 @@ type Env interface {
DogstatsdFullImagePath() string
UpdaterDeploy() bool
MajorVersion() string
AgentHelmConfig() string

GetBoolWithDefault(config *sdkconfig.Config, paramName string, defaultValue bool) bool
GetStringListWithDefault(config *sdkconfig.Config, paramName string, defaultValue []string) []string
Expand Down Expand Up @@ -445,3 +447,7 @@ func (e *CommonEnvironment) AgentFIPS() bool {
func (e *CommonEnvironment) AgentJMX() bool {
return e.GetBoolWithDefault(e.AgentConfig, DDAgentJMX, false)
}

func (e *CommonEnvironment) AgentHelmConfig() string {
return e.GetStringWithDefault(e.AgentConfig, DDAgentHelmConfig, "")
}
11 changes: 11 additions & 0 deletions components/datadog/agent/kubernetes_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package agent

import (
"fmt"
"os"

"golang.org/x/exp/maps"
"gopkg.in/yaml.v3"
Expand Down Expand Up @@ -155,6 +156,16 @@ func NewHelmInstallation(e config.Env, args HelmInstallationArgs, opts ...pulumi
valuesYAML = append(valuesYAML, buildOTelConfigWithFakeintake(args.OTelConfig, args.Fakeintake))
}

// Read and merge custom helm config if provided
if helmConfig := e.AgentHelmConfig(); helmConfig != "" {
customHelm, err := os.ReadFile(helmConfig)
if err != nil {
return nil, err
}
config := pulumi.NewStringAsset(string(customHelm))
valuesYAML = append(valuesYAML, config)
}

linux, err := helm.NewInstallation(e, helm.InstallArgs{
RepoURL: DatadogHelmRepo,
ChartName: "datadog",
Expand Down
2 changes: 2 additions & 0 deletions tasks/aws/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def deploy(
cluster_agent_full_image_path: Optional[str] = None,
agent_flavor: Optional[str] = None,
agent_env: Optional[str] = None,
helm_config: Optional[str] = None,
) -> str:
flags = extra_flags if extra_flags else {}

Expand Down Expand Up @@ -91,6 +92,7 @@ def deploy(
cluster_agent_full_image_path,
agent_flavor,
agent_env,
helm_config,
)


Expand Down
3 changes: 3 additions & 0 deletions tasks/aws/eks.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"full_image_path": doc.full_image_path,
"cluster_agent_full_image_path": doc.cluster_agent_full_image_path,
"agent_flavor": doc.agent_flavor,
"helm_config": doc.helm_config,
}
)
def create_eks(
Expand All @@ -51,6 +52,7 @@ def create_eks(
full_image_path: Optional[str] = None,
cluster_agent_full_image_path: Optional[str] = None,
agent_flavor: Optional[str] = None,
helm_config: Optional[str] = None,
):
"""
Create a new EKS environment. It lasts around 20 minutes.
Expand Down Expand Up @@ -84,6 +86,7 @@ def create_eks(
full_image_path=full_image_path,
cluster_agent_full_image_path=cluster_agent_full_image_path,
agent_flavor=agent_flavor,
helm_config=helm_config,
)

tool.notify(ctx, "Your EKS cluster is now created")
Expand Down
3 changes: 3 additions & 0 deletions tasks/aws/kind.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"full_image_path": doc.full_image_path,
"cluster_agent_full_image_path": doc.cluster_agent_full_image_path,
"agent_flavor": doc.agent_flavor,
"helm_config": doc.helm_config,
}
)
def create_kind(
Expand All @@ -45,6 +46,7 @@ def create_kind(
full_image_path: Optional[str] = None,
cluster_agent_full_image_path: Optional[str] = None,
agent_flavor: Optional[str] = None,
helm_config: Optional[str] = None,
):
"""
Create a kind environment.
Expand All @@ -71,6 +73,7 @@ def create_kind(
full_image_path=full_image_path,
cluster_agent_full_image_path=cluster_agent_full_image_path,
agent_flavor=agent_flavor,
helm_config=helm_config,
)

if interactive:
Expand Down
3 changes: 3 additions & 0 deletions tasks/azure/aks.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"agent_version": doc.container_agent_version,
"stack_name": doc.stack_name,
"agent_flavor": doc.agent_flavor,
"helm_config": doc.helm_config,
}
)
def create_aks(
Expand All @@ -39,6 +40,7 @@ def create_aks(
cluster_agent_full_image_path: Optional[str] = None,
use_fakeintake: Optional[bool] = False,
agent_flavor: Optional[str] = None,
helm_config: Optional[str] = None,
):
"""
Create a new AKS environment. It lasts around 5 minutes.
Expand Down Expand Up @@ -69,6 +71,7 @@ def create_aks(
cluster_agent_full_image_path=cluster_agent_full_image_path,
use_fakeintake=use_fakeintake,
agent_flavor=agent_flavor,
helm_config=helm_config,
)

if interactive:
Expand Down
2 changes: 2 additions & 0 deletions tasks/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def deploy(
cluster_agent_full_image_path: Optional[str] = None,
agent_flavor: Optional[str] = None,
agent_env: Optional[str] = None,
helm_config: Optional[str] = None,
) -> str:
flags = extra_flags if extra_flags else {}

Expand All @@ -54,6 +55,7 @@ def deploy(
flags["ddagent:fullImagePath"] = full_image_path
flags["ddagent:clusterAgentFullImagePath"] = cluster_agent_full_image_path
flags["ddagent:extraEnvVars"] = agent_env
flags["ddagent:helmConfig"] = helm_config

if install_agent:
flags["ddagent:apiKey"] = _get_api_key(cfg)
Expand Down
1 change: 1 addition & 0 deletions tasks/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@
add_known_host: str = "Add the host to the known_hosts file (default True)"
agent_flavor: str = "Use a specific Agent flavor (such as datadog-fips-agent, see PackageFlavor https://github.com/DataDog/agent-release-management/blob/main/generator/const.py)"
agent_env: str = "Extra environment variables to run the agent with, the format is `VAR1=val1,VAR2=val2`"
helm_config: str = "Path to a custom helm config file that will be merged with the default one"
3 changes: 3 additions & 0 deletions tasks/gcp/gke.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"agent_version": doc.container_agent_version,
"stack_name": doc.stack_name,
"agent_flavor": doc.agent_flavor,
"helm_config": doc.helm_config,
}
)
def create_gke(
Expand All @@ -39,6 +40,7 @@ def create_gke(
use_fakeintake: Optional[bool] = False,
use_autopilot: Optional[bool] = False,
agent_flavor: Optional[str] = None,
helm_config: Optional[str] = None,
) -> None:
"""
Create a new GKE environment.
Expand Down Expand Up @@ -70,6 +72,7 @@ def create_gke(
cluster_agent_full_image_path=cluster_agent_full_image_path,
use_fakeintake=use_fakeintake,
agent_flavor=agent_flavor,
helm_config=helm_config,
)

if interactive:
Expand Down
Loading