Skip to content

Commit

Permalink
clusteraddress, token and namespace of kubernetes as ENV_VAR
Browse files Browse the repository at this point in the history
  • Loading branch information
zyzyx85 committed Dec 10, 2024
1 parent dada9b7 commit d3cf799
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.util.function.Function;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.security.oauth2.jwt.JwtClaimNames;
Expand All @@ -34,6 +36,15 @@ public class KubernetesUtils implements JwtDecoder {
@SuppressWarnings("java:S5164")
private final ThreadLocal<String> callerNamespace = new ThreadLocal<>();

@Value("${entando.namespaces-to-observe:}")
private String namespacesToObserve;

@Value("${entando.cluster.address:}")
private String clusterAddress;

@Value("${entando.cluster.token:}")
private String clusterToken;

public KubernetesUtils() {
this(s -> new DefaultKubernetesClient());
}
Expand Down Expand Up @@ -71,7 +82,7 @@ public KubernetesClient getCurrentKubernetesClient() {
//If we ever require serviceAccount propagation from component-manager, reactivate this line:
//return this.kubernetesClients.get(currentToken.get());

return getCurrentKubernetesClient("https://rancher.entando.org/k8s/clusters/c-m-tlkbhgpx","kubeconfig-u-lzyzo5b3ijj7lss:6zkl29dmmsq2djk576zqflqrdrhr62z6946nv92kv4m9nxbldzwxj4", "entando73");
return getCurrentKubernetesClient(clusterAddress,clusterToken, namespacesToObserve);
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ spring.security.oauth2.client.registration.oidc.client-id=my-digital-exchange
spring.security.oauth2.client.registration.oidc.client-secret=e52c1e9a-065b-49fc-9ce8-fa6913bd87d0

# Entando
entando.namespaces.to.observe=
entando.namespaces.to.observe=${NAMESPACE:default}
entando.cluster.address=${CLUSTER_ADDRESS:http://localhost}
entando.cluster.token=${CLUSTER_TOKEN:qwe}

swagger.enabled=true
swagger.info.title=${pom.name:Entando Kubernetes Service}
Expand Down

0 comments on commit d3cf799

Please sign in to comment.