diff --git a/api/v1/inline_types.go b/api/v1/inline_types.go index 17284d7a..705246ff 100644 --- a/api/v1/inline_types.go +++ b/api/v1/inline_types.go @@ -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 { diff --git a/bundle/manifests/instana.io_agents.yaml b/bundle/manifests/instana.io_agents.yaml index 9a38862e..f810e0ac 100644 --- a/bundle/manifests/instana.io_agents.yaml +++ b/bundle/manifests/instana.io_agents.yaml @@ -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 diff --git a/config/crd/bases/instana.io_agents.yaml b/config/crd/bases/instana.io_agents.yaml index 808e6ef1..e67c5b86 100644 --- a/config/crd/bases/instana.io_agents.yaml +++ b/config/crd/bases/instana.io_agents.yaml @@ -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. diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index d9808c2d..e67889ad 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -46,6 +46,8 @@ rules: - 'namespaces' - 'services' - 'deployments' + - 'nodes/stats' + - 'nodes/metrics' verbs: - create - delete @@ -85,6 +87,9 @@ rules: - nonResourceURLs: - '/version' - '/healthz' + - "/metrics" + - "/stats/summary" + - "/metrics/cadvisor" verbs: - 'get' - apiGroups: diff --git a/config/samples/instana_v1_extended_instanaagent.yaml b/config/samples/instana_v1_extended_instanaagent.yaml index 7117fe57..b9a4a631 100644 --- a/config/samples/instana_v1_extended_instanaagent.yaml +++ b/config/samples/instana_v1_extended_instanaagent.yaml @@ -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 diff --git a/controllers/reconciliation/helm/agent_reconciliation.go b/controllers/reconciliation/helm/agent_reconciliation.go index 6953e7cc..b8642659 100644 --- a/controllers/reconciliation/helm/agent_reconciliation.go +++ b/controllers/reconciliation/helm/agent_reconciliation.go @@ -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 } @@ -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