in src/panels/TcpDumpPanel.ts [211:284]
private async handleStartDebugPod(node: NodeName, webview: MessageSink<ToWebViewMsgDef>) {
const createPodYaml = `
apiVersion: v1
kind: Pod
metadata:
name: ${getPodName(node)}
namespace: ${debugPodNamespace}
spec:
containers:
- args: ["-c", "sleep infinity"]
command: ["/bin/sh"]
image: mcr.microsoft.com/dotnet/runtime-deps:6.0
imagePullPolicy: IfNotPresent
name: debug
resources: {}
securityContext:
privileged: true
runAsUser: 0
volumeMounts:
- mountPath: /host
name: host-volume
volumes:
- name: host-volume
hostPath:
path: /
dnsPolicy: ClusterFirst
nodeSelector:
kubernetes.io/hostname: ${node}
restartPolicy: Never
securityContext: {}
hostIPC: true
hostNetwork: true
hostPID: true`;
const applyResult = await withOptionalTempFile(createPodYaml, "YAML", async (podSpecFile) => {
const command = `apply -f ${podSpecFile}`;
return await invokeKubectlCommand(this.kubectl, this.kubeConfigFilePath, command);
});
if (failed(applyResult)) {
webview.postStartDebugPodResponse({
node,
succeeded: false,
errorMessage: `Unable to create debug pod:\n${applyResult.error}`,
});
return;
}
const waitResult = await this.waitForPodReady(node);
if (failed(waitResult)) {
webview.postStartDebugPodResponse({
node,
succeeded: false,
errorMessage: `Pod ${getPodName(node)} is not ready:\n${waitResult.error}`,
});
return;
}
const installResult = await this.installDebugTools(node);
if (failed(installResult)) {
webview.postStartDebugPodResponse({
node,
succeeded: false,
errorMessage: `Installing debug tools failed on ${getPodName(node)}:\n${installResult.error}`,
});
return;
}
webview.postStartDebugPodResponse({
node,
succeeded: true,
errorMessage: null,
});
}