Skip to content

Commit

Permalink
add option to add custom agent charts url (#109)
Browse files Browse the repository at this point in the history
Signed-off-by: Milica Cvrkota <[email protected]>
  • Loading branch information
Milica-Cvrkota-IBM authored Sep 21, 2023
1 parent e89e5f2 commit a1683fd
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 1 deletion.
3 changes: 3 additions & 0 deletions api/v1/inline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ type BaseAgentSpec struct {
// Alternative to `Host` for referencing a different Maven repo.
// +kubebuilder:validation:Optional
MvnRepoUrl string `json:"instanaMvnRepoUrl,omitempty"`
// Custom agent charts url.
// +kubebuilder:validation:Optional
ChartsUrl string `json:"charts_url,omitempty"`
}

type AgentPodSpec struct {
Expand Down
3 changes: 3 additions & 0 deletions bundle/manifests/instana.io_agents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ spec:
description: Supply Agent configuration e.g. for configuring certain
Sensors.
type: string
charts_url:
description: Custom agent charts url.
type: string
downloadKey:
description: The DownloadKey, sometimes known as "sales key",
that allows you to download software from Instana. It might
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/instana.io_agents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ spec:
- key
type: object
type: array
charts_url:
description: Custom agent charts url.
type: string
configuration:
description: Mount in a ConfigMap with Agent configuration. Alternative
to the `configuration_yaml` field.
Expand Down
5 changes: 5 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ rules:
- 'namespaces'
- 'services'
- 'deployments'
- 'nodes/stats'
- 'nodes/metrics'
verbs:
- create
- delete
Expand Down Expand Up @@ -85,6 +87,9 @@ rules:
- nonResourceURLs:
- '/version'
- '/healthz'
- "/metrics"
- "/stats/summary"
- "/metrics/cadvisor"
verbs:
- 'get'
- apiGroups:
Expand Down
3 changes: 3 additions & 0 deletions config/samples/instana_v1_extended_instanaagent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ spec:
# You can leave this empty, or use this to configure your instana agent.
# See https://docs.instana.io/setup_and_manage/host_agent/on/kubernetes/

# Custom agent charts URL that can be used in air gapped envs
charts_url: some-link

# openshift specifies whether the cluster role should include openshift permissions and other tweaks to the YAML.
# The chart will try to auto-detect if the cluster is OpenShift, so you will likely not even need to set this explicitly.
# openshift: true
Expand Down
13 changes: 12 additions & 1 deletion controllers/reconciliation/helm/agent_reconciliation.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@ import (
)

const (
helmRepo = "https://agents.instana.io/helm"
agentChartName = "instana-agent"
)

var (
settings *cli.EnvSettings
helmRepo string
)

func init() {
settings = cli.New()
helmRepo = "https://agents.instana.io/helm"
settings.RepositoryConfig = helmRepo
}

Expand Down Expand Up @@ -115,6 +116,16 @@ func (h *HelmReconciliation) CreateOrUpdate(_ ctrl.Request, crdInstance *instana
return err
}

if agentConfig, ok := yamlMap["agent"]; ok {
if agentConfigMap, mapFound := agentConfig.(map[string]interface{}); mapFound {
if helmUrl, urlFound := agentConfigMap["charts_url"]; urlFound {
h.log.Info(fmt.Sprintf("Custom charts url found. Setting it to %s", helmUrl))
helmRepo = fmt.Sprintf("%v", helmUrl)
settings.RepositoryConfig = helmRepo
}
}
}

// Find out if there's an Agent chart already installed or need a fresh install
histClient := action.NewHistory(h.helmCfg)
histClient.Max = 1
Expand Down

0 comments on commit a1683fd

Please sign in to comment.