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 annotations to Deployment #2477

Merged
merged 1 commit into from
Jan 5, 2022
Merged

Conversation

beastob
Copy link
Contributor

@beastob beastob commented Dec 15, 2021

Description
Allow adding annotations to Deployment via Helm values.

This enables using some third-party tools which rely on adding annotations on Deployment, Statefulset, Daemonset. For example, adding annotations to external-secrets Deployment allow stakater-reloader to restart(thus reload configs) deployment upon ConfigMap or Secret modifications.

Example use case
For situations when external-dns reads from config or secret, which in my case it's the Azure configuration Secret. If I wish to restart external-dns deployment upon config change in order for that config change to be applied, I can utilize the ability of stakater-reloader to do it by adding annotations to external-dns' Deployment.

Fixes #ISSUE(none)

Checklist

  • End user documentation updated

@linux-foundation-easycla
Copy link

CLA Not Signed

@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Dec 15, 2021
@k8s-ci-robot
Copy link
Contributor

Welcome @beastob!

It looks like this is your first PR to kubernetes-sigs/external-dns 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/external-dns has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Dec 15, 2021
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Dec 15, 2021

CLA Signed

The committers are authorized under a signed CLA.

@beastob
Copy link
Contributor Author

beastob commented Dec 15, 2021

I signed it

Copy link
Contributor

@stevehipwell stevehipwell left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @beastob, you'll need to sign the CLA before this can move forward and I've added some comments on the code.

But before we look too much into the implementation could you add some documentation links to the description showing systems that require deployment level annotations over pod annotations?

@@ -26,8 +26,12 @@ rbac:
create: true
additionalPermissions: {}

# Annotations to add to the Deployment
annotations: {}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this might be better named as deploymentAnnotations unless you've got a strong idiomatic precedent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added an example use case in my PR description above. And unfortunately, some tools only look for deploymentAnnotations and not PodAnnotations.

Copy link
Contributor

Choose a reason for hiding this comment

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

@beastob have you looked at adding a kiwigrid/k8s-sidecar? This is how Grafana handles configmap reloads and it seems to be a better architecture with a single responsibility container in a pod rather than a central service? If this worked it'd be easy to add configuration to enable extra containers in the pod and documentation to show how it could be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suppose https://github.com/kiwigrid/k8s-sidecar works in a way that's similar to Spring-boot's ConfigMap/Secret watcher. My answer would be yes and no. It's because watchers like kiwigrid/k8s-sidecar would restart(I supposed?) the application container upon config changes, and if the deployment has replica>1, all pods/containers will all restart at the same time and causes short period of down time. However, for this project's I think adding an extraContainers field is a good idea, for those who would like to add sidecars.

staketer-reloader on the other hand can allow a RollingUpgrade effect to restart all deployment pods. Nevertheless, I believe allowing a common field annotations for Deployment shouldn't be a bad idea?

Copy link
Contributor

Choose a reason for hiding this comment

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

The preferred use of kiwigrid/k8s-sidecar is to hit a webhook to trigger a config reload but I think it can manually re-start a pod if a webhook isn't available.

Does ExternalDNS support running multiple replicas? I'm pretty sure you should only have a single "active" replica and I don't think having a non-leader replica would add a benefit to the ExternalDNS workflow even if possible? Even then assuming multiple pods, if configuration has changed I doubt you'd want some using old config? Finally I can't see ExternalDNS as a tier 1 service, I can't see any use case where unavailable for a restart cycle is a problem?

Nevertheless, I believe allowing a common field annotations for Deployment shouldn't be a bad idea?

It's not very idiomatic and promotes the tight coupling of controller to pod which should be avoided as much as possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does ExternalDNS support running multiple replicas? I'm pretty sure you should only have a single "active" replica and I don't think having a non-leader replica would add a benefit to the ExternalDNS workflow even if possible? Even then assuming multiple pods, if configuration has changed I doubt you'd want some using old config? Finally I can't see ExternalDNS as a tier 1 service, I can't see any use case where unavailable for a restart cycle is a problem?

I agree that ExternalDNS in particular does not need RollingUpgrade. It's just that using a centralised service like stakater-reloader we don't have to worry if a particular application out of dozens can support hot config reload or not, and we don't need config extra sidecar individually to achieve config reload. Only annotations would be needed.

And in GitOps approach of managing the kubernates cluster, we would want as little manual operations as possible. For example, changing some config in Git and then pushing it. Then the applications should reload the configs without further human interactions.

Copy link
Contributor

Choose a reason for hiding this comment

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

I can agree to disagree on this approach.

So just the CLA error to fix and then someone can enable the CI to run, the code itself looks good to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do see your concerns, but it's the lesser of two evils in our case. I will try to figure out the CLA problem later, and thanks for the discussion.

@@ -4,6 +4,10 @@ metadata:
name: {{ include "external-dns.fullname" . }}
labels:
{{- include "external-dns.labels" . | nindent 4 }}
{{- with .Values.annotations }}
annotations:
{{ toYaml . | indent 4 }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{{ toYaml . | indent 4 }}
{{- toYaml . | nindent 4 }}

This chart favours nindent for this pattern.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your suggestions. I have changed to deploymentAnnotations and now using nindent

@stevehipwell
Copy link
Contributor

@beastob you need to amend your git commit(s) with the -s flag to get the CLA to pass. I'd suggest squashing your commits into a single commit first.

Signed-off-by: beastob <beastob.mark1@gmail.com>
@beastob
Copy link
Contributor Author

beastob commented Dec 15, 2021

I signed it

@beastob
Copy link
Contributor Author

beastob commented Dec 15, 2021

@beastob you need to amend your git commit(s) with the -s flag to get the CLA to pass. I'd suggest squashing your commits into a single commit first.

Thanks alot for the help. This is my first PR to a linuxfoundation project and needs some getting use to.

@beastob
Copy link
Contributor Author

beastob commented Dec 17, 2021

I signed it

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Dec 17, 2021
@stevehipwell
Copy link
Contributor

@Raffo could you enable the workflows?

@rgrebski
Copy link

rgrebski commented Dec 28, 2021

Hi, do you guys have any updates on this PR ? I would appreciate having deployment annotations as well.

Copy link
Member

@njuettner njuettner left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 5, 2022
@Raffo
Copy link
Contributor

Raffo commented Jan 5, 2022

@stevehipwell we'll leave this to you to /approve if you are fine with the change.

@stevehipwell
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: beastob, stevehipwell

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 5, 2022
@k8s-ci-robot k8s-ci-robot merged commit 7109fa8 into kubernetes-sigs:master Jan 5, 2022
@stevehipwell stevehipwell mentioned this pull request Feb 3, 2022
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants