@khal-os/cli 1.0.43 → 1.0.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +19 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14892,7 +14892,7 @@ function isInCluster() {
|
|
|
14892
14892
|
_inClusterCached = existsSync5(IN_CLUSTER_TOKEN_PATH) && !!process.env.KUBERNETES_SERVICE_HOST;
|
|
14893
14893
|
return _inClusterCached;
|
|
14894
14894
|
}
|
|
14895
|
-
var exec2, IN_CLUSTER_TOKEN_PATH = "/var/run/secrets/kubernetes.io/serviceaccount/token", _inClusterCached, DEFAULT_KUBECONFIG = "/etc/rancher/k3s/k3s.yaml", DEFAULT_NATS_URL = "nats://nats:4222", DEFAULT_RESOURCES, SANDBOX_RUNTIME_CLASS = "sysbox-runc", SANDBOX_PVC_SIZE = "20Gi", SANDBOX_STORAGE_CLASS = "local-path", SANDBOX_SSH_PORT = 22, SANDBOX_NAMESPACE = "khal-sandbox", SANDBOX_HELM_CHART, SANDBOX_RESOURCES, KubernetesRuntime;
|
|
14895
|
+
var exec2, IN_CLUSTER_TOKEN_PATH = "/var/run/secrets/kubernetes.io/serviceaccount/token", _inClusterCached, DEFAULT_KUBECONFIG = "/etc/rancher/k3s/k3s.yaml", DEFAULT_NATS_URL = "nats://nats:4222", DEFAULT_RESOURCES, SANDBOX_RUNTIME_CLASS = "sysbox-runc", SANDBOX_PVC_SIZE = "20Gi", SANDBOX_STORAGE_CLASS = "local-path", SANDBOX_SSH_PORT = 22, SANDBOX_NAMESPACE = "khal-sandbox", SANDBOX_HELM_CHART, SANDBOX_RESOURCES, SANDBOX_HELM_TIMEOUT_S, SANDBOX_POD_READY_TIMEOUT_MS, KubernetesRuntime;
|
|
14896
14896
|
var init_kubernetes = __esm(() => {
|
|
14897
14897
|
exec2 = promisify(execFile);
|
|
14898
14898
|
DEFAULT_RESOURCES = {
|
|
@@ -14901,9 +14901,11 @@ var init_kubernetes = __esm(() => {
|
|
|
14901
14901
|
};
|
|
14902
14902
|
SANDBOX_HELM_CHART = process.env.KHAL_SANDBOX_CHART_PATH ?? "helm/khal-sandbox";
|
|
14903
14903
|
SANDBOX_RESOURCES = {
|
|
14904
|
-
requests: { cpu: "
|
|
14905
|
-
limits: { cpu: "
|
|
14904
|
+
requests: { cpu: "250m", memory: "512Mi" },
|
|
14905
|
+
limits: { cpu: "1", memory: "2Gi" }
|
|
14906
14906
|
};
|
|
14907
|
+
SANDBOX_HELM_TIMEOUT_S = Number(process.env.KHAL_SANDBOX_HELM_TIMEOUT_S ?? 360);
|
|
14908
|
+
SANDBOX_POD_READY_TIMEOUT_MS = Number(process.env.KHAL_SANDBOX_POD_READY_TIMEOUT_S ?? 360) * 1000;
|
|
14907
14909
|
KubernetesRuntime = class KubernetesRuntime extends BaseRuntime {
|
|
14908
14910
|
type = "kubernetes";
|
|
14909
14911
|
kubeconfig;
|
|
@@ -14926,6 +14928,7 @@ var init_kubernetes = __esm(() => {
|
|
|
14926
14928
|
helmChart;
|
|
14927
14929
|
helmRelease;
|
|
14928
14930
|
domainSuffix;
|
|
14931
|
+
imagePullSecret;
|
|
14929
14932
|
sysboxAvailable;
|
|
14930
14933
|
constructor(config) {
|
|
14931
14934
|
super(config);
|
|
@@ -14954,9 +14957,10 @@ var init_kubernetes = __esm(() => {
|
|
|
14954
14957
|
this.podName = `sandbox-${safeUser}-0`.slice(0, 63);
|
|
14955
14958
|
this.serviceName = `sandbox-${safeUser}`.slice(0, 63);
|
|
14956
14959
|
this.helmRelease = `sandbox-${safeUser}`.slice(0, 53);
|
|
14957
|
-
this.image = kc.image ?? "khal-os/sandbox:latest";
|
|
14960
|
+
this.image = kc.image ?? process.env.KHAL_SANDBOX_IMAGE ?? "khal-os/sandbox:latest";
|
|
14958
14961
|
this.instanceId = kc.instanceId ?? `sandbox-${safeUser}`;
|
|
14959
14962
|
this.resources = kc.resources ?? SANDBOX_RESOURCES;
|
|
14963
|
+
this.imagePullSecret = kc.imagePullSecret ?? process.env.KHAL_SANDBOX_PULL_SECRET ?? "ocir-secret";
|
|
14960
14964
|
} else {
|
|
14961
14965
|
this.runtimeClassName = kc.runtimeClassName;
|
|
14962
14966
|
this.namespace = `khal-${id}`.slice(0, 63).replace(/[^a-z0-9-]/g, "-");
|
|
@@ -14966,6 +14970,7 @@ var init_kubernetes = __esm(() => {
|
|
|
14966
14970
|
this.image = kc.image ?? `khal-os/${slug}:latest`;
|
|
14967
14971
|
this.instanceId = id;
|
|
14968
14972
|
this.resources = kc.resources ?? DEFAULT_RESOURCES;
|
|
14973
|
+
this.imagePullSecret = kc.imagePullSecret;
|
|
14969
14974
|
}
|
|
14970
14975
|
}
|
|
14971
14976
|
async ensureDeps() {
|
|
@@ -15052,7 +15057,7 @@ var init_kubernetes = __esm(() => {
|
|
|
15052
15057
|
this.namespace,
|
|
15053
15058
|
"--wait",
|
|
15054
15059
|
"--timeout",
|
|
15055
|
-
|
|
15060
|
+
`${SANDBOX_HELM_TIMEOUT_S}s`,
|
|
15056
15061
|
...setArgs
|
|
15057
15062
|
];
|
|
15058
15063
|
this.emit({
|
|
@@ -15062,20 +15067,25 @@ var init_kubernetes = __esm(() => {
|
|
|
15062
15067
|
message: `helm ${helmArgs.join(" ")}`
|
|
15063
15068
|
});
|
|
15064
15069
|
try {
|
|
15065
|
-
await exec2("helm", helmArgs, { timeout:
|
|
15070
|
+
await exec2("helm", helmArgs, { timeout: (SANDBOX_HELM_TIMEOUT_S + 30) * 1000 });
|
|
15066
15071
|
} catch (err) {
|
|
15067
15072
|
const msg = err instanceof Error ? err.message : String(err);
|
|
15068
15073
|
throw new Error(`helm upgrade --install ${this.helmRelease} failed: ${msg}`);
|
|
15069
15074
|
}
|
|
15070
|
-
await this.waitForPod(
|
|
15075
|
+
await this.waitForPod(SANDBOX_POD_READY_TIMEOUT_MS);
|
|
15071
15076
|
}
|
|
15072
15077
|
buildHelmValues() {
|
|
15073
15078
|
const sets = [];
|
|
15074
15079
|
const set = (key, value) => {
|
|
15075
15080
|
sets.push("--set", `${key}=${value}`);
|
|
15076
15081
|
};
|
|
15077
|
-
|
|
15078
|
-
|
|
15082
|
+
const lastColon = this.image.lastIndexOf(":");
|
|
15083
|
+
const repo = lastColon > 0 ? this.image.slice(0, lastColon) : this.image;
|
|
15084
|
+
const tag = lastColon > 0 ? this.image.slice(lastColon + 1) : "latest";
|
|
15085
|
+
set("image.repository", repo);
|
|
15086
|
+
set("image.tag", tag);
|
|
15087
|
+
if (this.imagePullSecret)
|
|
15088
|
+
set("image.pullSecret", this.imagePullSecret);
|
|
15079
15089
|
if (this.userId)
|
|
15080
15090
|
set("user.id", this.userId);
|
|
15081
15091
|
const natsHost = this.parseNatsHost();
|