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

UD-1190: Add support for plugin pod annotations and plugin service ac… #241

Merged
merged 1 commit into from
Feb 9, 2024

Conversation

knrc
Copy link
Contributor

@knrc knrc commented Feb 8, 2024

…count annotations

Description

This PR enables annotations to be provided for each plugin pod and for the plugin service account.

One use of this would be to enable access to specific IAM roles when running in EKS, for example for Trivy to access a private ECR.

Linked Issues

How has this been tested?

  • Creation of a private ECR, an EKS cluster and a deployment of an image from the private repo
  • Helm installation of zora using the following options
    • --set scan.plugins.annotations.eks\\.amazonaws\\.com/role-arn=arn:aws:iam::127647282379:role/undistro-test-ecr-role (annotation on the ServiceAccount, must use the role created for accessing the ECR)
    • --set scan.plugins.marvin.podAnnotations.marvin-annotation="marvin-value"
    • --set scan.plugins.popeye.podAnnotations.popeye-annotation="popeye-value"
    • --set scan.plugins.trivy.podAnnotations.trivy-annotation="trivy-value"
  • check service account for annotation
    • kubectl get sa zora-plugins -o jsonpath='{.metadata.annotations}'
  • check cronjobs and executed pods for annotations
    • kubectl get cronjob -l zora.undistro.io/plugin=marvin -o jsonpath='{.items[*].spec.jobTemplate.spec.template.metadata.annotations}'
    • kubectl get cronjob -l zora.undistro.io/plugin=popeye -o jsonpath='{.items[*].spec.jobTemplate.spec.template.metadata.annotations}'
    • kubectl get cronjob -l zora.undistro.io/plugin=trivy -o jsonpath='{.items[*].spec.jobTemplate.spec.template.metadata.annotations}'
    • kubectl get pods -o jsonpath='{.items[*].metadata.annotations}'
  • check dashboard for vulnerabilities from private repo images
  • check trivy pod to ensure there are no errors for the images from a private repo

Checklist

  • I have labeled this PR with the relevant Type labels
  • I have documented my code (if applicable)
  • My changes are covered by tests

@knrc knrc added the enhancement New feature or request label Feb 8, 2024
@knrc knrc requested a review from matheusfm February 8, 2024 12:50
Copy link
Contributor

@matheusfm matheusfm left a comment

Choose a reason for hiding this comment

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

The parameters

  • scan.plugins.annotations
  • scan.plugins.trivy.podAnnotations
  • scan.plugins.marvin.podAnnotations
  • scan.plugins.popeye.podAnnotations

are not present in charts/zora/values.yaml.

It's important to ensure all parameters are included in values.yaml for users who reference to this file to understand the available options and to ensure the consistency of auto-generated chart documentation.

@knrc knrc force-pushed the UD-1190 branch 2 times, most recently from 95b6de4 to 8b7d827 Compare February 8, 2024 15:42
@knrc
Copy link
Contributor Author

knrc commented Feb 8, 2024

It's important to ensure all parameters are included in values.yaml for users who reference to this file to understand the available options and to ensure the consistency of auto-generated chart documentation.

@matheusfm I've added them into values.yaml, with examples to ensure the docs are generated appropriately

Copy link
Contributor

@matheusfm matheusfm 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 @knrc
I think the only thing missing was commenting out the annotation examples, like in the Marvin section, right?

@knrc
Copy link
Contributor Author

knrc commented Feb 8, 2024

Thank you @knrc I think the only thing missing was commenting out the annotation examples, like in the Marvin section, right?

No, I did that originally but the generated document had each as a string. I left the examples in there so they would generate the appropriate content.

@knrc
Copy link
Contributor Author

knrc commented Feb 8, 2024

Thank you @knrc I think the only thing missing was commenting out the annotation examples, like in the Marvin section, right?

No, I did that originally but the generated document had each as a string. I left the examples in there so they would generate the appropriate content.

Note I'm not convinced that the generated content is even correct, since the original content I added by hand is what you need to use for the helm command line. I'll see if there's an alternative which gives the right content.

@matheusfm
Copy link
Contributor

I would try set {} as default.

      podAnnotations: {}
#        trivy-annotation: trivy-value

@knrc
Copy link
Contributor Author

knrc commented Feb 8, 2024

I would try set {} as default.

      podAnnotations: {}
#        trivy-annotation: trivy-value

Yeah, this worked to change it to an object but wasn't really what I was looking for. I was hoping there was some way of specifying examples but couldn't find it, the only examples appear to be the assumed defaults set in the values.yaml file.

@knrc knrc merged commit 0468a96 into undistro:main Feb 9, 2024
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.

2 participants