podname logs for log service

pull/531/head
Frostebite 2023-08-02 00:28:14 +01:00
parent a275c2ec4a
commit 7d2704c3e4
4 changed files with 20 additions and 2 deletions

6
dist/index.js generated vendored
View File

@ -3742,6 +3742,12 @@ class KubernetesLogService {
cloud_runner_logger_1.default.log(`Service: ${JSON.stringify(service.body, undefined, 4)}`);
// get podname of deployment
const podname = await cloud_runner_system_1.CloudRunnerSystem.Run(`kubectl get pods -n ${namespace} -l service=http-fileserver -o jsonpath='{.items[0].metadata.name}'`, false, true);
// if status of pod is not running, then continue
const podStatus = await cloud_runner_system_1.CloudRunnerSystem.Run(`kubectl get pods -n ${namespace} ${podname} -o jsonpath='{.status.phase}'`, false, true);
if (podStatus !== 'Running') {
cloud_runner_logger_1.default.log(`Pod status: ${podStatus}`);
continue;
}
const logs = await cloud_runner_system_1.CloudRunnerSystem.Run(`kubectl logs ${podname} -f --timestamps`, false, true);
cloud_runner_logger_1.default.log(`Logs: ${logs}`);
// get cluster ip

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -113,6 +113,17 @@ status: {}
true,
);
// if status of pod is not running, then continue
const podStatus = await CloudRunnerSystem.Run(
`kubectl get pods -n ${namespace} ${podname} -o jsonpath='{.status.phase}'`,
false,
true,
);
if (podStatus !== 'Running') {
CloudRunnerLogger.log(`Pod status: ${podStatus}`);
continue;
}
const logs = await CloudRunnerSystem.Run(`kubectl logs ${podname} -f --timestamps`, false, true);
CloudRunnerLogger.log(`Logs: ${logs}`);

View File

@ -44,8 +44,9 @@ describe('Cloud Runner Kubernetes', () => {
const kubeConfig = new k8s.KubeConfig();
kubeConfig.loadFromDefault();
const kubeClient = kubeConfig.makeApiClient(k8s.CoreV1Api);
const kubeClientApps = kubeConfig.makeApiClient(k8s.AppsV1Api);
await KubernetesLogService.createLogService('test', 'default', kubeClient);
await KubernetesLogService.createLogDeployment('test', kubeClientApps, kubeClient);
CloudRunnerLogger.log(`run 1 succeeded`);
}, 1_000_000_000);