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

Add all pull secrets to all components #3365

Merged
merged 4 commits into from
Jul 10, 2024
Merged

Conversation

aorcholski
Copy link
Contributor

@aorcholski aorcholski commented Jun 27, 2024

Description

K8S-10395

All dynakube image pull secrets added to OneAgent, ActiveGate specs.

All dynakube image pull secrets used by csi.ImageInstaller.

EdgeConnect controller uses registry.Client but depends on EdgeConnect.Spec.CustomPullSecret.

dynakube.controller.registryClientBuilder is not used (registry.Client).

csiprovisioner.OneAgentProvisioner.registryClientBuilder is not used (registry.Client).

How it works:

dockerAuth(s) loaded by configFile.LoadFromReader(...) from different secrets are stored in a single instance of configFile.AuthConfigs map. configFile.LoadFromReader(...) basically does map[k] = v so it works for many secrets.

See:

How can this be tested?

Copy codemodules image to a private registry:

podman pull public.ecr.aws/dynatrace/dynatrace-codemodules:1.293.133.20240618-095559 
podman tag public.ecr.aws/dynatrace/dynatrace-codemodules:1.293.133.20240618-095559 <registry>/codemodules:1.293.133.20240618-095559 
podman push <registry>/codemodules:1.293.133.20240618-095559 

Create pull image secret:

kubectl -n dynatrace create secret docker-registry <secretname>  --docker-server=<registry> --docker-username=<username>  --docker-password=<password>

Enable DEBUG log level:

kubectl -n dynatrace set env daemonset.apps/dynatrace-oneagent-csi-driver -c provisioner --env=LOG_LEVEL=debug

Apply dynakube:

spec:
  customPullSecret: <secretname>                                                                                                                                                                                                                                                                                                                                                                      
  oneAgent:                                                                                                                                                                                                                                                                                                                                                                                   
    cloudNativeFullStack:                                                                                                                                                                                                                                                                                                                                                                     
      codeModulesImage: "<registry>/codemodules:1.293.133.20240618-095559" 

Check csi logs:

[]$ kubectl -n dynatrace logs -f pod/dynatrace-oneagent-csi-driver-<svbwp>

{"level":"debug","ts":"2024-07-04T11:52:56.889Z","logger":"docker-keychain","msg":"loaded docker configs","registries":["<registry>","<tenant>"]}
{"level":"info","ts":"2024-07-04T11:52:56.889Z","logger":"oneagent-image","msg":"installing agent from image"}
{"level":"info","ts":"2024-07-04T11:52:56.889Z","logger":"oneagent-image","msg":"installing agent","target dir":"/data/codemodules/cXVheS5pby9hZGFtX29yY2hvbHNraS9keW5vcDoxLjI5My4xMzMuMjAyNDA2MTgtMDk1NTU5"}
{"level":"info","ts":"2024-07-04T11:52:57.298Z","logger":"oneagent-image","msg":"pullOciImage","ref_identifier":"1.293.133.20240618-095559","ref.Name":"<registry>/codemodules:1.293.133.20240618-095559","ref.String":"<registry>/codemodules:1.293.133.20240618-095559"}
{"level":"info","ts":"2024-07-04T11:53:00.736Z","logger":"oneagent-image","msg":"unpackOciImage","sourcePath":"/data/cache/cXVheS5pby9hZGFtX29yY2hvbHNraS9keW5vcDoxLjI5My4xMzMuMjAyNDA2MTgtMDk1NTU5/blobs/sha256/9592808cd833be900caf7c72a18a97cc8c6c0f54077ddcca84a1030d8fec18b6"}

Check OneAgent image pull secrets:

kubectl -n dynatrace get daemonset.apps/dynakube-oneagent -o jsonpath="{.spec.template.spec.imagePullSecrets}"

there should be two secrets:

[{"name":"dynakube-pull-secret"},{"name":"<secretname>"}]

@aorcholski aorcholski force-pushed the feature/image-pull-secret branch 11 times, most recently from d298fd3 to 452ca72 Compare July 3, 2024 09:50
@codecov-commenter
Copy link

codecov-commenter commented Jul 3, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 42.62295% with 35 lines in your changes missing coverage. Please review.

Project coverage is 57.23%. Comparing base (85a60f5) to head (a9771db).

Files Patch % Lines
pkg/api/v1beta2/dynakube/properties.go 0.00% 13 Missing ⚠️
pkg/api/v1beta3/dynakube/properties.go 0.00% 13 Missing ⚠️
pkg/oci/dockerkeychain/docker_keychain.go 70.00% 6 Missing and 3 partials ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3365      +/-   ##
==========================================
- Coverage   57.26%   57.23%   -0.03%     
==========================================
  Files         344      344              
  Lines       19753    19781      +28     
==========================================
+ Hits        11311    11322      +11     
- Misses       7206     7221      +15     
- Partials     1236     1238       +2     
Flag Coverage Δ
unittests 57.23% <42.62%> (-0.03%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@aorcholski aorcholski force-pushed the feature/image-pull-secret branch 4 times, most recently from a0d10f4 to b6c318d Compare July 4, 2024 12:33
@StefanHauth
Copy link
Collaborator

I tested this PR by pulling a code module image from the Google Cloud Artifactory Repository. Worked fine!

@aorcholski aorcholski marked this pull request as ready for review July 4, 2024 15:19
@aorcholski aorcholski requested a review from a team as a code owner July 4, 2024 15:19
@aorcholski aorcholski changed the title WIP Add all pull secrets to all components Add all pull secrets to all components Jul 4, 2024
@StefanHauth
Copy link
Collaborator

I think the troubleshoot command might also need some adoption in a follow-up taking these changes into account.

@aorcholski aorcholski force-pushed the feature/image-pull-secret branch 2 times, most recently from 75f737f to a99735e Compare July 5, 2024 09:14
@aorcholski aorcholski force-pushed the feature/image-pull-secret branch 2 times, most recently from 6642ff7 to e92f0d5 Compare July 8, 2024 06:43
albertogdd

This comment was marked as outdated.

@aorcholski aorcholski force-pushed the feature/image-pull-secret branch 3 times, most recently from 4c0db2c to 3b7f99c Compare July 9, 2024 08:52
Copy link
Contributor

@albertogdd albertogdd left a comment

Choose a reason for hiding this comment

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

Code LGTM, didn't test it because I don't have a podman setup (pls anyone else, test it)

@aorcholski aorcholski merged commit 6a6099f into main Jul 10, 2024
19 checks passed
@aorcholski aorcholski deleted the feature/image-pull-secret branch July 10, 2024 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants