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

[Discovery.KubernetesApi] add option to query pods in all namespaces #2421

Conversation

brunopace-ciandt
Copy link
Contributor

@brunopace-ciandt brunopace-ciandt commented Mar 25, 2024

Changes

Adds a new option to query K8s Pods in all namespaces instead of querying in a specific namespace. It still supports to filter by podSelector

Checklist

For significant changes, please ensure that the following have been completed (delete if not relevant):

Copy link
Member

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

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

LGTM - nice work

# Enable to query pods in all namespaces
#
# If this is set to true, the pod-namespace configuration is ignored.
all-namespaces = true
Copy link
Member

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

Choose a reason for hiding this comment

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

LGTM


var cts = new CancellationTokenSource(resolveTimeout);
V1PodList podList;
try
{
#if !NET6_0_OR_GREATER
Copy link
Member

Choose a reason for hiding this comment

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

So we moved the ifdefs down into these individual methods - got it

@@ -89,27 +89,17 @@ public override async Task<Resolved> Lookup(Lookup lookup, TimeSpan resolveTimeo
var labelSelector = _settings.PodLabelSelector(lookup.ServiceName);

if(_log.IsInfoEnabled)
_log.Info("Querying for pods with label selector: [{0}]. Namespace: [{1}]. Port: [{2}]",
labelSelector, PodNamespace, lookup.PortName);
_log.Info("Querying for pods with label selector: [{0}]. Namespace: [{1}]. AllNamespaces: [{2}]. Port: [{3}]",
Copy link
Member

Choose a reason for hiding this comment

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

LGTM

@@ -177,7 +167,45 @@ public override async Task<Resolved> Lookup(Lookup lookup, TimeSpan resolveTimeo

return new Resolved(serviceName: lookup.ServiceName, addresses: addresses);
}

private async Task<V1PodList> ListNamespacedPod(string labelSelector, CancellationTokenSource cts)
Copy link
Member

Choose a reason for hiding this comment

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

LGTM - basically what we had before


private async Task<V1PodList> ListPodForAllNamespaces(string labelSelector, CancellationTokenSource cts)
Copy link
Member

Choose a reason for hiding this comment

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

LGTM

@Aaronontheweb Aaronontheweb merged commit 230e1f2 into akkadotnet:dev Mar 27, 2024
3 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