Skip to content

Commit cf827af

Browse files
feat(agent): add clusterName and clusterDescription support
- Add clusterName and clusterDescription Helm values and docs - Populate cluster_id and cluster_description in the rendered configmap - Update values.schema.json to include descriptions for the new values - Add ClusterDescription field to pkg/agent Config and CombinedConfig - Default MachineHub cluster ID from ARK_USERNAME env when not set - Clarify comments and add TODO about ClusterID vs ClusterName naming Signed-off-by: Richard Wall <[email protected]>
1 parent 907cc48 commit cf827af

File tree

5 files changed

+71
-7
lines changed

5 files changed

+71
-7
lines changed

deploy/charts/disco-agent/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,18 @@ Example: excludeAnnotationKeysRegex: ['^kapp\.k14s\.io/original.*']
277277
> ```yaml
278278
> []
279279
> ```
280+
#### **config.clusterName** ~ `string`
281+
282+
A human readable name for the cluster where the agent is deployed (optional).
283+
284+
This cluster name will be associated with the data that the agent uploads to the Discovery and Context service. If empty (the default), the service account name will be used instead.
285+
286+
#### **config.clusterDescription** ~ `string`
287+
288+
A short description of the cluster where the agent is deployed (optional).
289+
290+
This description will be associated with the data that the agent uploads to the Discovery and Context service. The description should include contact information such as the email address of the cluster administrator, so that any problems and risks identified by the Discovery and Context service can be communicated to the people responsible for the affected secrets.
291+
280292
#### **authentication.secretName** ~ `string`
281293
> Default value:
282294
> ```yaml

deploy/charts/disco-agent/templates/configmap.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ metadata:
77
{{- include "disco-agent.labels" . | nindent 4 }}
88
data:
99
config.yaml: |-
10+
cluster_id: {{ .Values.config.clusterName | quote }}
11+
cluster_description: {{ .Values.config.clusterDescription | quote }}
1012
period: {{ .Values.config.period | quote }}
1113
{{- with .Values.config.excludeAnnotationKeysRegex }}
1214
exclude-annotation-keys-regex:

deploy/charts/disco-agent/values.schema.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@
104104
"helm-values.config": {
105105
"additionalProperties": false,
106106
"properties": {
107+
"clusterDescription": {
108+
"$ref": "#/$defs/helm-values.config.clusterDescription"
109+
},
110+
"clusterName": {
111+
"$ref": "#/$defs/helm-values.config.clusterName"
112+
},
107113
"excludeAnnotationKeysRegex": {
108114
"$ref": "#/$defs/helm-values.config.excludeAnnotationKeysRegex"
109115
},
@@ -116,6 +122,14 @@
116122
},
117123
"type": "object"
118124
},
125+
"helm-values.config.clusterDescription": {
126+
"description": "A short description of the cluster where the agent is deployed (optional).\n\nThis description will be associated with the data that the agent uploads to the Discovery and Context service. The description should include contact information such as the email address of the cluster administrator, so that any problems and risks identified by the Discovery and Context service can be communicated to the people responsible for the affected secrets.",
127+
"type": "string"
128+
},
129+
"helm-values.config.clusterName": {
130+
"description": "A human readable name for the cluster where the agent is deployed (optional).\n\nThis cluster name will be associated with the data that the agent uploads to the Discovery and Context service. If empty (the default), the service account name will be used instead.",
131+
"type": "string"
132+
},
119133
"helm-values.config.excludeAnnotationKeysRegex": {
120134
"default": [],
121135
"description": "You can configure the agent to exclude some annotations or labels from being pushed . All Kubernetes objects are affected. The objects are still pushed, but the specified annotations and labels are removed before being pushed.\n\nDots is the only character that needs to be escaped in the regex. Use either double quotes with escaped single quotes or unquoted strings for the regex to avoid YAML parsing issues with `\\.`.\n\nExample: excludeAnnotationKeysRegex: ['^kapp\\.k14s\\.io/original.*']",

deploy/charts/disco-agent/values.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,26 @@ config:
138138
excludeAnnotationKeysRegex: []
139139
excludeLabelKeysRegex: []
140140

141+
# A human readable name for the cluster where the agent is deployed (optional).
142+
#
143+
# This cluster name will be associated with the data that the agent uploads to
144+
# the Discovery and Context service. If empty (the default), the service
145+
# account name will be used instead.
146+
#
147+
# +docs:property
148+
# clusterName: ""
149+
150+
# A short description of the cluster where the agent is deployed (optional).
151+
#
152+
# This description will be associated with the data that the agent uploads to
153+
# the Discovery and Context service. The description should include contact
154+
# information such as the email address of the cluster administrator, so that
155+
# any problems and risks identified by the Discovery and Context service can
156+
# be communicated to the people responsible for the affected secrets.
157+
#
158+
# +docs:property
159+
# clusterDescription: ""
160+
141161
authentication:
142162
secretName: agent-credentials
143163

pkg/agent/config.go

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,13 @@ type Config struct {
4949
OrganizationID string `yaml:"organization_id"`
5050

5151
// ClusterID is the cluster that the agent is scanning. Used in all modes.
52-
ClusterID string `yaml:"cluster_id"`
52+
//
53+
// TODO(wallrj): ClusterID and ClusterName have become somewhat confusing
54+
// naming-wise. We should consider renaming ClusterID to ClusterName
55+
ClusterID string `yaml:"cluster_id"`
56+
// ClusterDescription is a short description of the cluster. It should
57+
// contain contact details of the cluster administrator, so that any risks
58+
// identified by the backend can be communicated.
5359
ClusterDescription string `yaml:"cluster_description"`
5460
DataGatherers []DataGatherer `yaml:"data-gatherers"`
5561
VenafiCloud *VenafiCloudConfig `yaml:"venafi-cloud,omitempty"`
@@ -340,8 +346,8 @@ const (
340346
MachineHub OutputMode = "MachineHub"
341347
)
342348

343-
// The command-line flags and the config file are combined into this struct by
344-
// ValidateAndCombineConfig.
349+
// The command-line flags and the config file and some environment variables are
350+
// combined into this struct by ValidateAndCombineConfig.
345351
type CombinedConfig struct {
346352
DataGatherers []DataGatherer
347353
Period time.Duration
@@ -352,7 +358,10 @@ type CombinedConfig struct {
352358

353359
OutputMode OutputMode
354360

355-
// Used by all TLSPK modes.
361+
// Used by all modes.
362+
//
363+
// TODO(wallrj): ClusterID and ClusterName have become somewhat confusing
364+
// consider renaming ClusterID to ClusterName.
356365
ClusterID string
357366

358367
// Used by JetstackSecureOAuth, JetstackSecureAPIToken, and
@@ -364,7 +373,11 @@ type CombinedConfig struct {
364373
EndpointPath string // Deprecated.
365374

366375
// VenafiCloudKeypair mode only.
367-
UploadPath string
376+
UploadPath string
377+
378+
// ClusterDescription is a short description of the cluster. It should
379+
// contain contact details of the cluster administrator so that risks identified
380+
// by the backend can be communicated.
368381
ClusterDescription string
369382

370383
// VenafiCloudVenafiConnection mode only.
@@ -557,8 +570,11 @@ func ValidateAndCombineConfig(log logr.Logger, cfg Config, flags AgentCmdFlags)
557570
organizationID = cfg.OrganizationID
558571
clusterID = cfg.ClusterID
559572
case MachineHub:
560-
if cfg.ClusterID != "" {
561-
log.Info(fmt.Sprintf(`Ignoring the cluster_id field in the config file. This field is not needed in %s mode.`, res.OutputMode))
573+
clusterID = cfg.ClusterID
574+
if clusterID == "" {
575+
if arkUsername, found := os.LookupEnv("ARK_USERNAME"); found {
576+
clusterID = arkUsername
577+
}
562578
}
563579
if cfg.OrganizationID != "" {
564580
log.Info(fmt.Sprintf(`Ignoring the organization_id field in the config file. This field is not needed in %s mode.`, res.OutputMode))

0 commit comments

Comments
 (0)