-
Notifications
You must be signed in to change notification settings - Fork 323
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
Support annotation service-tags: $POD_NAME #931
Conversation
Support the annotation ``` consul.hashicorp.com/service-tags: $POD_NAME ``` Where $POD_NAME will be replaced with the Pod's name. This mimics support we had before the endpoints controller where environment variable were interpolated for tags. This PR only supports $POD_NAME for now because it's the only environment variable we've been asked to support.
@@ -416,15 +416,7 @@ func (r *EndpointsController) createServiceRegistrations(pod corev1.Pod, service | |||
meta[strings.TrimPrefix(k, annotationMeta)] = v | |||
} | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored this into a consulTags
function
@@ -433,9 +425,7 @@ func (r *EndpointsController) createServiceRegistrations(pod corev1.Pod, service | |||
Address: pod.Status.PodIP, | |||
Meta: meta, | |||
Namespace: r.consulNamespace(pod.Namespace), | |||
} | |||
if len(tags) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't see why we were doing this if
check rather than just assigning to the struct field.
pod1.Annotations[annotationTags] = "abc,123,$POD_NAME" | ||
pod1.Annotations[annotationConnectTags] = "def,456,$POD_NAME" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testing both the supported and deprecated tags just for completeness
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great!
Support the annotation
Where $POD_NAME will be replaced with the Pod's name.
This mimics support we had before the endpoints controller
where environment variable were interpolated for tags.
This PR only supports $POD_NAME for now because it's the only
environment variable we've been asked to support.
How I've tested this PR: unit tests
How I expect reviewers to test this PR: code
Checklist: