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

Support nested path in confd configmap #335

Merged
merged 3 commits into from
Jul 22, 2021

Conversation

clamoriniere
Copy link
Collaborator

@clamoriniere clamoriniere commented Jul 12, 2021

What does this PR do?

Support nested confd path to allow multi configuration files for a check type

  • Add Items []corev1.KeyToPath in ConfigDirSpec which allow to map a configmap key to a specific path.
type ConfigDirSpec struct {
	// ConfigMapName name of a ConfigMap used to mount a directory.
	ConfigMapName string `json:"configMapName,omitempty"`
	// items mapping between configMap data key and file path mount.
	Items []corev1.KeyToPath `json:"items,omitempty"`
}
  • Fix conflict between "kuberenetesStateCore" config and clusterAgent.conf.confd.

Motivation

Some checks that can be schedule by the cluster-agent can require to have
several instances.

Additional Notes

N/A

Describe your test plan

Two 2 examples are present in the /examples/datadogagent/ folder:

  • datadog-agent-ksm-core-custom-conf.yaml -> mount 3 differents configuration in /etc/datadog-agent/kubernetes_state_core.d/
  • datadog-agent-cluster-agent-confd.yaml -> mount a nested file in /etc/datadog-agent/conf.d/test.d/test.yaml

another extra test can be to enable "kuberenetesStateCore" with a custom config + a clusterAgent.conf.confd config.

apiVersion: datadoghq.com/v1alpha1
kind: DatadogAgent
metadata:
  name: datadog
spec:
  ClusterName: ced-test
  credentials:
    apiKey: <DATADOG_API_KEY>
    appKey: <DATADOG_APP_KEY>
  features:
    orchestratorExplorer:
      enabled: true
    kubeStateMetricsCore:
      enabled: true
      conf:
        configMap:
          name: cluster-agent-ksm-conf
  agent:
    image:
      name: "gcr.io/datadoghq/agent:latest"
  clusterAgent:
    image:
      name: "gcr.io/datadoghq/cluster-agent:latest"
    config:
      confd:
        configMapName: cluster-agent-confd
        items:
        - key: test
          path: test.d/test.yaml
      clusterChecksEnabled: true
  clusterChecksRunner:
    image:
      name: "gcr.io/datadoghq/agent:latest"
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: cluster-agent-confd
data:
  test: |-
    init_config:
    instances:
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: cluster-agent-ksm-core-conf
data:
  pods.yaml: |-
    cluster_check: true
    init_config:
    instances:
      - collectors:
        - pods
  nodes.yaml: |-
    cluster_check: true
    init_config:
    instances:
      - collectors:
        - nodes
  others.yaml: |-
    cluster_check: true
    init_config:
    instances:
      - collectors:
        - secrets
        - services
        - resourcequotas
        - replicationcontrollers
        - limitranges
        - persistentvolumeclaims
        - persistentvolumes
        - namespaces
        - endpoints
        - daemonsets
        - deployments
        - replicasets
        - statefulsets
        - cronjobs
        - jobs
        - horizontalpodautoscalers
        - poddisruptionbudgets
        - storageclasses
        - volumeattachments

@clamoriniere clamoriniere added this to the v0.7 milestone Jul 12, 2021
@clamoriniere clamoriniere requested review from a team as code owners July 12, 2021 20:25
@codecov-commenter
Copy link

codecov-commenter commented Jul 12, 2021

Codecov Report

Merging #335 (62e8d3e) into main (17299c9) will increase coverage by 0.04%.
The diff coverage is 64.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #335      +/-   ##
==========================================
+ Coverage   63.44%   63.49%   +0.04%     
==========================================
  Files          60       61       +1     
  Lines        6614     6686      +72     
==========================================
+ Hits         4196     4245      +49     
- Misses       2116     2134      +18     
- Partials      302      307       +5     
Flag Coverage Δ
unittests 63.49% <64.36%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
api/v1alpha1/datadogagent_types.go 100.00% <ø> (ø)
controllers/datadogagent/kubestatemetrics.go 85.39% <ø> (ø)
controllers/datadogagent/utils.go 83.41% <37.50%> (-0.40%) ⬇️
controllers/datadogagent/builder.go 66.10% <66.10%> (ø)
controllers/datadogagent/clusteragent.go 70.45% <70.00%> (+0.65%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 17299c9...62e8d3e. Read the comment docs.

@clamoriniere clamoriniere force-pushed the clamoriniere/nestedconfigmappath branch from 017262f to 6eb8ac3 Compare July 21, 2021 07:47
@clamoriniere clamoriniere force-pushed the clamoriniere/nestedconfigmappath branch from 6eb8ac3 to ac6dfd4 Compare July 21, 2021 10:27
@clamoriniere clamoriniere force-pushed the clamoriniere/nestedconfigmappath branch from 8a6a6f0 to 62e8d3e Compare July 22, 2021 09:36
Copy link
Contributor

@ahmed-mez ahmed-mez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you @clamoriniere !

@clamoriniere clamoriniere merged commit 8f519e8 into main Jul 22, 2021
@clamoriniere clamoriniere deleted the clamoriniere/nestedconfigmappath branch July 22, 2021 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants