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

[DCA] External Metrics Server Configuration #6406

Merged
merged 1 commit into from
Sep 18, 2020

Conversation

CharlyF
Copy link
Contributor

@CharlyF CharlyF commented Sep 18, 2020

What does this PR do?

The Datadog Cluster Agent implements the External Metrics Server api and its associated featureset.
Up until now, it was not possible to configure the flags of this server.
Such flags include, but are not limited to:

--requestheader-allowed-names strings                     List of client certificate common names to allow to provide usernames in headers specified by --requestheader-username-headers. If empty, any client certificate validated by the authorities in --requestheader-client-ca-file is allowed.
--requestheader-client-ca-file string                     Root certificate bundle to use to verify client certificates on incoming requests before trusting usernames in headers specified by --requestheader-username-headers. WARNING: generally do not depend on authorization being already done for incoming requests.
--requestheader-extra-headers-prefix strings              List of request header prefixes to inspect. X-Remote-Extra- is suggested. (default [x-remote-extra-])
--requestheader-group-headers strings                     List of request headers to inspect for groups. X-Remote-Group is suggested. (default [x-remote-group])
--authentication-skip-lookup                              If false, the authentication-kubeconfig will be used to lookup missing authentication configuration from the cluster.
--lister-kubeconfig string                                kubeconfig file pointing at the 'core' kubernetes server with enough rights to list any described objects

With this bit of logic, one can specify the headers required to inquire external metrics.

Motivation

Having the ability to configure the request headers, the certificates, the kubeconfig to use for out-of-clusters set ups is a security requirement.

Additional Notes

Still need to add tests (e2e ideally)

Describe your test plan

Several ways to test this:
1/

            - name: DD_EXTERNAL_METRICS_PROVIDER_CONFIG
              value: '{"cert-dir": "/etc/datadog-agent", "requestheader-group-headers": "X-Remote-Group", "secure-port": "8443"}'

Verify that:

  • The server is running and serving correctly
root@datadog-cluster-agent-XXX:/# curl -k -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" --header "X-Remote-Group: system:unauthenticated" --cert /etc/datadog-agent/apiserver.crt --key /etc/datadog-agent/apiserver.key https://127.0.0.1:8443/apis/external.metrics.k8s.io/v1beta1
{
  "kind": "APIResourceList",
  "apiVersion": "v1",
  "groupVersion": "external.metrics.k8s.io/v1beta1",
  "resources": []

2/ Soon to come: specify the certificates in the external metrics provider.
Something like

external_metrics_provider.config:
   requestheader-group-headers: X-Remote-Group
   requestheader-username-headers: X-Remote-User 
   client-ca-file: client-ca.crt
   requestheader-allowed-names: front-proxy-client
   requestheader-client-ca-file: front-proxy-ca.crt
   secure-port: 6443

and verify that you can only query the API with the proper conf (similar to the API Server).

Todo

  • Test

@CharlyF CharlyF requested review from a team as code owners September 18, 2020 00:33
@CharlyF CharlyF force-pushed the charlyf/dca-ext-ms-options branch from 9330009 to 5029879 Compare September 18, 2020 02:08
@CharlyF CharlyF force-pushed the charlyf/dca-ext-ms-options branch from 5029879 to 00a43a9 Compare September 18, 2020 03:11
Copy link
Contributor

@vboulineau vboulineau left a comment

Choose a reason for hiding this comment

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

LGTM

@CharlyF CharlyF added this to the DCA_1.9.0 milestone Sep 18, 2020
@CharlyF CharlyF merged commit 30699c9 into master Sep 18, 2020
@CharlyF CharlyF deleted the charlyf/dca-ext-ms-options branch September 18, 2020 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants