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

Remove kube-rbac-proxy image #1551

Merged
merged 2 commits into from
Dec 23, 2024
Merged

Remove kube-rbac-proxy image #1551

merged 2 commits into from
Dec 23, 2024

Conversation

khewonc
Copy link
Contributor

@khewonc khewonc commented Dec 9, 2024

What does this PR do?

Removes references to image gcr.io/kubebuilder/kube-rbac-proxy

Motivation

#1545

Additional Notes

Using filters.WithAuthenticationAndAuthorization adds a dependency to k8s.io/apiserver: https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/metrics/filters#WithAuthenticationAndAuthorization

Minimum Agent Versions

Are there minimum versions of the Datadog Agent and/or Cluster Agent required?

  • Agent: vX.Y.Z
  • Cluster Agent: vX.Y.Z

Describe your test plan

  1. Uncomment the following in config/default/kustomization.yaml:
# [METRICS] Expose the controller manager metrics service.
- metrics_service.yaml

patches:
# [METRICS] The following patch will enable the metrics endpoint using HTTPS and the port :8443.
# More info: https://book.kubebuilder.io/reference/metrics
- path: manager_metrics_patch.yaml
  target:
   kind: Deployment
  1. Uncomment the following in config/rbac/kustomization.yaml:
# The following RBAC configurations are used to protect
# the metrics endpoint with authn/authz. These configurations
# ensure that only authorized users and service accounts
# can access the metrics endpoint.
- metrics_auth_role.yaml
- metrics_auth_role_binding.yaml
- metrics_reader_role.yaml
  1. Run make deploy with secureMetrics=true
  2. Create a pod to curl the metrics endpoint with the proper auth:
apiVersion: v1
kind: Pod
metadata:
  name: metrics-consumer
  namespace: system
spec:
  # Use the scaffolded service account name to allow authn/authz
  serviceAccountName: datadog-operator-controller-manager
  containers:
  - name: metrics-consumer
    image: curlimages/curl:7.78.0
    command: ["/bin/sh"]
    args:
      - "-c"
      - >
        while true;
        do
          # Note here that we are passing the token obtained from the ServiceAccount to curl the metrics endpoint
          curl -v -k -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" https://datadog-operator-controller-manager-metrics-service.system.svc.cluster.local:8443/metrics;
          sleep 60;
        done
  1. Check the pod logs to ensure the curl was successful (should see prometheus formatted metrics)

Checklist

  • PR has at least one valid label: bug, enhancement, refactoring, documentation, tooling, and/or dependencies
  • PR has a milestone or the qa/skip-qa label

@khewonc khewonc added the enhancement New feature or request label Dec 9, 2024
@khewonc khewonc added this to the v1.12.0 milestone Dec 9, 2024
@khewonc khewonc requested a review from a team as a code owner December 9, 2024 17:03
@khewonc khewonc changed the title Khewonc/kube rbac proxy Remove kube-rbac-proxy image Dec 9, 2024
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.

Project coverage is 48.64%. Comparing base (993280d) to head (93056db).

Files with missing lines Patch % Lines
cmd/main.go 0.00% 14 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1551      +/-   ##
==========================================
- Coverage   48.66%   48.64%   -0.03%     
==========================================
  Files         226      226              
  Lines       20363    20372       +9     
==========================================
  Hits         9909     9909              
- Misses       9937     9946       +9     
  Partials      517      517              
Flag Coverage Δ
unittests 48.64% <0.00%> (-0.03%) ⬇️

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

Files with missing lines Coverage Δ
cmd/main.go 0.00% <0.00%> (ø)

Continue to review full report in Codecov by Sentry.

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

@khewonc khewonc merged commit efaa4e9 into main Dec 23, 2024
23 checks passed
@khewonc khewonc deleted the khewonc/kube-rbac-proxy branch December 23, 2024 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants