Skip to content

Commit

Permalink
map '.' to own namespace, default to own namespace singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Apr 4, 2024
1 parent 39da2e1 commit 4e379e3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/main/java/io/cryostat/discovery/KubeApiDiscovery.java
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,12 @@ private Pair<HasMetadata, DiscoveryNode> queryForNode(

@ApplicationScoped
static final class KubeConfig {

public static final String KUBERNETES_NAMESPACE_PATH =
"/var/run/secrets/kubernetes.io/serviceaccount/namespace";

private static final String OWN_NAMESPACE = ".";

@Inject Logger logger;
@Inject FileSystem fs;

Expand All @@ -389,8 +392,17 @@ static final class KubeConfig {

private KubernetesClient kubeClient;

List<String> getWatchNamespaces() {
return watchNamespaces.orElse(List.of());
Collection<String> getWatchNamespaces() {
return watchNamespaces.orElse(List.of(OWN_NAMESPACE)).stream()
.map(
n -> {
if (OWN_NAMESPACE.equals(n)) {
return getOwnNamespace();
}
return n;
})
.filter(Objects::nonNull)
.collect(Collectors.toSet());
}

String getOwnNamespace() {
Expand Down

0 comments on commit 4e379e3

Please sign in to comment.