Skip to content

Commit 853a3be

Browse files
committed
Server-side apply of ceph CRDs + wait until ready
1 parent 536a13d commit 853a3be

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

.werft/vm/vm.ts

+17-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { HARVESTER_KUBECONFIG_PATH, PREVIEW_K3S_KUBECONFIG_PATH } from "../jobs/build/const";
2-
import { exec } from "../util/shell";
3-
import { getGlobalWerftInstance } from "../util/werft";
1+
import {HARVESTER_KUBECONFIG_PATH, PREVIEW_K3S_KUBECONFIG_PATH} from "../jobs/build/const";
2+
import {exec} from "../util/shell";
3+
import {getGlobalWerftInstance} from "../util/werft";
44

55
import * as Manifests from "./manifests";
66
import * as shell from "shelljs";
@@ -59,7 +59,7 @@ export function startVM(options: { name: string, cpu: number, memory: number })
5959
cpu: options.cpu,
6060
memory: options.memory
6161
}),
62-
{ validate: false },
62+
{validate: false},
6363
);
6464

6565
kubectlApplyManifest(
@@ -171,7 +171,7 @@ export function waitForVMReadiness(options: { name: string; timeoutSeconds: numb
171171
const startTime = Date.now();
172172
const ready = exec(
173173
`kubectl --kubeconfig ${HARVESTER_KUBECONFIG_PATH} -n ${namespace} wait --for=condition=ready --timeout=${options.timeoutSeconds}s pod -l kubevirt.io=virt-launcher -l harvesterhci.io/vmName=${options.name}`,
174-
{ dontCheckRc: true, silent: true },
174+
{dontCheckRc: true, silent: true},
175175
);
176176

177177
if (ready.code == 0) {
@@ -196,13 +196,13 @@ export function copyk3sKubeconfig(options: { name: string; timeoutMS: number; sl
196196
while (true) {
197197
const status = exec(
198198
`ssh -i /workspace/.ssh/id_rsa_harvester_vm [email protected] -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no 'sudo cat /etc/rancher/k3s/k3s.yaml' > ${PREVIEW_K3S_KUBECONFIG_PATH}`,
199-
{ silent: true, dontCheckRc: true, slice: options.slice },
199+
{silent: true, dontCheckRc: true, slice: options.slice},
200200
);
201201

202202
if (status.code == 0) {
203203
exec(
204204
`kubectl --kubeconfig ${PREVIEW_K3S_KUBECONFIG_PATH} config set clusters.default.server https://${options.name}.kube.gitpod-dev.com:6443`,
205-
{ silent: true, slice: options.slice },
205+
{silent: true, slice: options.slice},
206206
);
207207
return;
208208
}
@@ -215,7 +215,7 @@ export function copyk3sKubeconfig(options: { name: string; timeoutMS: number; sl
215215
}
216216

217217
werft.log(options.slice, `Wasn't able to copy out kubeconfig yet. Sleeping 5 seconds`);
218-
exec("sleep 5", { silent: true, slice: options.slice });
218+
exec("sleep 5", {silent: true, slice: options.slice});
219219
}
220220
}
221221

@@ -244,7 +244,12 @@ export function stopKubectlPortForwards() {
244244
*/
245245
export function installRookCeph(options: { kubeconfig: string }) {
246246
exec(
247-
`kubectl --kubeconfig ${options.kubeconfig} apply -f .werft/vm/manifests/rook-ceph/crds.yaml -f .werft/vm/manifests/rook-ceph/common.yaml -f .werft/vm/manifests/rook-ceph/operator.yaml`,
247+
`kubectl --kubeconfig ${options.kubeconfig} apply -f .werft/vm/manifests/rook-ceph/crds.yaml --server-side --force-conflicts`
248+
);
249+
exec(
250+
`kubectl --kubeconfig ${options.kubeconfig} wait --for condition=established --timeout=120s crd/cephclusters.ceph.rook.io`
251+
);
252+
exec(`kubectl --kubeconfig ${options.kubeconfig} apply -f .werft/vm/manifests/rook-ceph/common.yaml -f .werft/vm/manifests/rook-ceph/operator.yaml`
248253
);
249254
exec(`kubectl --kubeconfig ${options.kubeconfig} apply -f .werft/vm/manifests/rook-ceph/cluster-test.yaml`);
250255
exec(`kubectl --kubeconfig ${options.kubeconfig} apply -f .werft/vm/manifests/rook-ceph/storageclass-test.yaml`);
@@ -257,15 +262,15 @@ export function installRookCeph(options: { kubeconfig: string }) {
257262
export function installFluentBit(options: { namespace: string; kubeconfig: string; slice: string }) {
258263
exec(
259264
`kubectl --kubeconfig ${options.kubeconfig} create secret generic fluent-bit-external --save-config --dry-run=client --from-file=credentials.json=/mnt/fluent-bit-external/credentials.json -o yaml | kubectl --kubeconfig ${options.kubeconfig} apply -n ${options.namespace} -f -`,
260-
{ slice: options.slice, dontCheckRc: true },
265+
{slice: options.slice, dontCheckRc: true},
261266
);
262267
exec(`helm3 --kubeconfig ${options.kubeconfig} repo add fluent https://fluent.github.io/helm-charts`, {
263268
slice: options.slice,
264269
dontCheckRc: true,
265270
});
266-
exec(`helm3 --kubeconfig ${options.kubeconfig} repo update`, { slice: options.slice, dontCheckRc: true });
271+
exec(`helm3 --kubeconfig ${options.kubeconfig} repo update`, {slice: options.slice, dontCheckRc: true});
267272
exec(
268273
`helm3 --kubeconfig ${options.kubeconfig} upgrade --install fluent-bit fluent/fluent-bit -n ${options.namespace} -f .werft/vm/charts/fluentbit/values.yaml`,
269-
{ slice: options.slice, dontCheckRc: true },
274+
{slice: options.slice, dontCheckRc: true},
270275
);
271276
}

0 commit comments

Comments
 (0)