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

Copy labels from canary to primary workloads based on prefix rules #709

Merged
merged 7 commits into from
Oct 21, 2020
Merged

Copy labels from canary to primary workloads based on prefix rules #709

merged 7 commits into from
Oct 21, 2020

Conversation

worldtiki
Copy link
Contributor

@worldtiki worldtiki commented Oct 11, 2020

Copy labels from canary to primary deployment and daemonset but exclude labels by prefix.
Copy annotations too.

Fixes #329.

Labels: map[string]string{
label: primaryLabelValue,
},
Labels: labels,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This filtering only applies to the deployment labels. Should it apply to the spec.template.metadata.labels as well?
From what I understood this is only to solve a very specific use case so I'm not sure if it should apply everywhere.

})
}

func TestMakePrimaryLabels(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unrelated but I noticed this file had not unit tests so I added this one as well.

@@ -125,6 +125,7 @@ Parameter | Description | Default
`serviceAccount.name` | The name of the service account to create or use. If not set and `serviceAccount.create` is `true`, a name is generated using the Flagger fullname | `""`
`serviceAccount.annotations` | Annotations for service account | `{}`
`ingressAnnotationsPrefix` | Annotations prefix for ingresses | `custom.ingress.kubernetes.io`
`excludedLabelsPrefixes` | List of prefixes of labels that are excluded when creating primary controllers | `"fluxcd,jenkins"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

should the name be changed to reflect that this applies only to deployment/daemonset labesls?

@worldtiki worldtiki marked this pull request as ready for review October 12, 2020 19:53
@stefanprodan
Copy link
Member

stefanprodan commented Oct 13, 2020

@worldtiki I've been searching around and seems that there are many controllers that are using labels for garbage collection and I don't see how we can maintain an exclusion list. Can you please change it to --include-label-prefix with the description: "List of prefixes of labels that are copied when creating primary deployments or daemonsets".

Thanks and sorry for this change, I should've spot it earlier.

@worldtiki
Copy link
Contributor Author

@worldtiki I've been searching around and seems that there are many controllers that are using labels for garbage collection and I don't see how we can maintain an exclusion list. Can you please change it to --include-label-prefix with the description: "List of prefixes of labels that are copied when creating primary deployments or daemonsets".

Thanks and sorry for this change, I should've spot it earlier.

Of course.

Would it make sense to have something like a "Use * to include all"?

@stefanprodan
Copy link
Member

Would it make sense to have something like a "Use * to include all"?

I think so as long it's not the default, the default should be include none e.g. string empty.

@stefanprodan stefanprodan changed the title Exclude controller labels by prefix Copy labels from canary to primary workloads based on prefix rules Oct 15, 2020
Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks @worldtiki

@DerrickMartinez
Copy link

Any update on merging this commit?

@stefanprodan stefanprodan merged commit 4d9fbc5 into fluxcd:master Oct 21, 2020
@DerrickMartinez
Copy link

Did we test this well? It's pretty broken. Nothing is working

@worldtiki
Copy link
Contributor Author

Can you expand on that? What's not working?

@worldtiki worldtiki deleted the exclude-labels branch October 30, 2020 12:47
@DerrickMartinez
Copy link

Configured with:

  • -include-label-prefix=app.kubernetes.io

Annotations and Labels of canary deployment:

annotations:
app.kubernetes.io/name: test-api
app.kubernetes.io/part-of: test-api

labels:
app.kubernetes.io/instance: test-api
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: test-api
helm.sh/chart: basic-app-flagger-0.1.7

What actually got copied over to primary's deployment.

No annotations
labels:
app.kubernetes.io/name: test-api-primary

@worldtiki
Copy link
Contributor Author

@DerrickMartinez these changes were not included in the v1.2.0 release.

Flagger shouldn't even be able to start with that option (include-label-prefix) since it doesn't exist in that version.

relu added a commit to relu/flagger that referenced this pull request Dec 8, 2020
Copying of Configmaps and Secrets managed through Flagger should now
follow the same label prefix filtering rules as for the workloads.

Extends: fluxcd#709

Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
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.

Deployment labels and annotations are not duplicated
3 participants