🚑️ Fix kubeconfig flag for logs and env

This commit is contained in:
andreas.dinauer 2025-11-01 21:08:40 +01:00
parent 64216c6401
commit 49129b5f48
2 changed files with 5 additions and 2 deletions

View File

@ -51,7 +51,7 @@ public class LogResource
public List<KubernetesLog> getLogs(Pod pod, LocalDateTime from)
{
String command = String.format("kubectl logs %s -n %s --timestamps", pod.getMetadata().getName(), pod.getMetadata().getNamespace());
String command = String.format("kubectl --kubeconfig=%s logs %s -n %s --timestamps", clientProvider.pathToKubeconfig(), pod.getMetadata().getName(), pod.getMetadata().getNamespace());
List<KubernetesLog> result = new ArrayList<>();
List<String> logs = processRunner.runToLines(command);
for (String log : logs)

View File

@ -28,6 +28,9 @@ public class PodResource
@Inject
ProcessRunner processRunner;
@Inject
ClientProvider clientProvider;
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes
@ -41,7 +44,7 @@ public class PodResource
private List<EnvVar> getVars(Pod pod)
{
List<EnvVar> result = new ArrayList<>();
List<String> lines = processRunner.runToLines(String.format("kubectl exec -it %s -n %s -- env", pod.getMetadata().getName(), pod.getMetadata().getNamespace()));
List<String> lines = processRunner.runToLines(String.format("kubectl --kubeconfig=%s exec -it %s -n %s -- env", clientProvider.pathToKubeconfig(), pod.getMetadata().getName(), pod.getMetadata().getNamespace()));
for (String line : lines)
{
int indexOfFirstEquals = line.indexOf("=");