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 aks support #100

Merged
merged 14 commits into from
Dec 5, 2024
Merged

Add aks support #100

merged 14 commits into from
Dec 5, 2024

Conversation

boris-smidt-klarrio
Copy link
Contributor

Adding support for tagging pvc's in AKS.
We have tested this code internally to make sure it works.

@mtougeron
Copy link
Owner

Thanks for the PR! I'll take a look at it over the next few days. While I do so, can you update the version of github.com/Azure/azure-sdk-for-go/sdk/azidentity to something newer? The version used has some vulnerabilities. Thanks!

@mtougeron
Copy link
Owner

so sorry, I got distracted and totally dropped the ball on reviewing this. I'll make it a priority for the next day or two.

@boris-smidt-klarrio
Copy link
Contributor Author

boris-smidt-klarrio commented Dec 3, 2024

@mtougeron We have this change running for quite some time now and it seems to function stable.
Let me know when you have time to review.

@mtougeron
Copy link
Owner

Yes, I've been really distracted as of late. I'm really sorry for not getting this taken care of. It's a top priority for me to get this merged and released in the next day or two.

Copy link
Owner

@mtougeron mtougeron left a comment

Choose a reason for hiding this comment

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

This is great stuff. I really appreciate the addition. Again, I'm very sorry for how long this took me to review.

I have a few pieces of feedback, but the main thing of concern is the sanitization of the tags and how stripping the invalid characters can bypass other validation rules.

Otherwise, this is AWESOME!

Dockerfile Show resolved Hide resolved
aks.go Outdated
return nil, ErrAzureTooManyTags
}
for k, v := range tags {
k = sanitizeKeyForAzure(k)
Copy link
Owner

Choose a reason for hiding this comment

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

After sanitizing the key it is possible that it could end up being a duplicate key. I'm on the fence as to whether it would be better to reject the tag if the key needs to be sanitized or if the tag created a duplicate. Which approach do you think is better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We use this in AWS and Azure so we don't really want to change the tags depending on the envrionment.
But i will add an error in case there are duplicated keys, this should also tackle your other comment concerning Kubernetes/Cluster: foo

aks.go Outdated Show resolved Hide resolved
aks.go Outdated
// remove forbidden characters
if strings.ContainsAny(s, `<>%&\?/`) {
for _, c := range `<>%&\?/` {
s = strings.ReplaceAll(s, string(c), "")
Copy link
Owner

Choose a reason for hiding this comment

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

If the invalid characters are being removed from the key it is possible to bypass this logic https://github.com/mtougeron/k8s-pvc-tagger/blob/main/kubernetes.go#L327-L339 by creating a tag name of Kubernetes/Cluster: foo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its solved by rejecting duplicated tag keys during the sanitization.

kubernetes.go Outdated Show resolved Hide resolved
aks.go Outdated Show resolved Hide resolved
README.md Outdated
@@ -117,6 +117,9 @@ gcloud iam roles create CustomDiskRole \
--stage="GA"
```

#### Azure rule
The default role `Tag Contributor` can be used to configure the access rights for the pvc-tagger.
Copy link
Owner

Choose a reason for hiding this comment

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

Can you add a bit about how this only support Azure disk csi volumes?

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've documented the behaviors hopefully this description will stay up to date in the future.

@mtougeron
Copy link
Owner

@boris-smidt-klarrio btw, if these changes are too much of a pain for you, because of how long I took to get to a review, I'm okay with merging as-is and creating an RC release of the image and making the changes myself. Just let me know what you'd prefer.

@boris-smidt-klarrio
Copy link
Contributor Author

@mtougeron I'll pull it to the end, there isn't any rush to this we are running an internal version of this image in the meantime.

@boris-smidt-klarrio
Copy link
Contributor Author

One minor change I've made after reading the GCP note i changed the behavior to replace the invalid characters in azure with _ as wel.

Copy link
Owner

@mtougeron mtougeron left a comment

Choose a reason for hiding this comment

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

Looks great! thank you!

@mtougeron mtougeron merged commit 618c018 into mtougeron:main Dec 5, 2024
6 checks passed
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.

2 participants