Kubernetes refactoring
parent
045c4217d1
commit
8f79ef98f8
|
|
@ -46,10 +46,6 @@ jobs:
|
||||||
###########################
|
###########################
|
||||||
# Build #
|
# Build #
|
||||||
###########################
|
###########################
|
||||||
# - uses: frostebite/File-To-Base64@master
|
|
||||||
# id: read-base64
|
|
||||||
# with:
|
|
||||||
# filePath: ~/.kube/config
|
|
||||||
- uses: ./
|
- uses: ./
|
||||||
id: k8s-unity-build
|
id: k8s-unity-build
|
||||||
with:
|
with:
|
||||||
|
|
@ -838,9 +838,7 @@ class Kubernetes {
|
||||||
core.info('Persistent Volume created, waiting for ready state...');
|
core.info('Persistent Volume created, waiting for ready state...');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
runJob(command, image) {
|
getJobSpec(command, image) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
core.info('Creating build job');
|
|
||||||
const job = new k8s.V1Job();
|
const job = new k8s.V1Job();
|
||||||
job.apiVersion = 'batch/v1';
|
job.apiVersion = 'batch/v1';
|
||||||
job.kind = 'Job';
|
job.kind = 'Job';
|
||||||
|
|
@ -963,9 +961,14 @@ class Kubernetes {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
job.spec.backoffLimit = 1;
|
job.spec.backoffLimit = 1;
|
||||||
yield this.kubeClientBatch.createNamespacedJob(this.namespace, job);
|
return job;
|
||||||
core.info('Job created');
|
}
|
||||||
|
runJob(jobSpec) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
|
core.info('Creating build job');
|
||||||
|
yield this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec);
|
||||||
|
core.info('Job created');
|
||||||
// We watch the PVC first to allow some time for K8s to notice the job we created and setup a pod.
|
// We watch the PVC first to allow some time for K8s to notice the job we created and setup a pod.
|
||||||
yield this.watchPersistentVolumeClaimUntilReady();
|
yield this.watchPersistentVolumeClaimUntilReady();
|
||||||
// TODO: Wait for something more reliable so we don't potentially get the pod before k8s has created it based on the job.
|
// TODO: Wait for something more reliable so we don't potentially get the pod before k8s has created it based on the job.
|
||||||
|
|
@ -994,7 +997,7 @@ class Kubernetes {
|
||||||
}
|
}
|
||||||
runCloneJob() {
|
runCloneJob() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
yield this.runJob([
|
yield this.runJob(this.getJobSpec([
|
||||||
'/bin/ash',
|
'/bin/ash',
|
||||||
'-c',
|
'-c',
|
||||||
`apk update;
|
`apk update;
|
||||||
|
|
@ -1008,12 +1011,12 @@ class Kubernetes {
|
||||||
git checkout $GITHUB_SHA;
|
git checkout $GITHUB_SHA;
|
||||||
ls
|
ls
|
||||||
echo "end"`,
|
echo "end"`,
|
||||||
], 'alpine/git');
|
], 'alpine/git'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
runBuildJob() {
|
runBuildJob() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
yield this.runJob([
|
yield this.runJob(this.getJobSpec([
|
||||||
'bin/bash',
|
'bin/bash',
|
||||||
'-c',
|
'-c',
|
||||||
`ls
|
`ls
|
||||||
|
|
@ -1028,7 +1031,7 @@ class Kubernetes {
|
||||||
chmod -R +x /steps
|
chmod -R +x /steps
|
||||||
/entrypoint.sh
|
/entrypoint.sh
|
||||||
`,
|
`,
|
||||||
], this.baseImage.toString());
|
], this.baseImage.toString()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
watchPersistentVolumeClaimUntilReady() {
|
watchPersistentVolumeClaimUntilReady() {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -125,8 +125,7 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
||||||
core.info('Persistent Volume created, waiting for ready state...');
|
core.info('Persistent Volume created, waiting for ready state...');
|
||||||
}
|
}
|
||||||
|
|
||||||
async runJob(command: string[], image: string) {
|
getJobSpec(command: string[], image: string) {
|
||||||
core.info('Creating build job');
|
|
||||||
const job = new k8s.V1Job();
|
const job = new k8s.V1Job();
|
||||||
job.apiVersion = 'batch/v1';
|
job.apiVersion = 'batch/v1';
|
||||||
job.kind = 'Job';
|
job.kind = 'Job';
|
||||||
|
|
@ -249,10 +248,14 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
job.spec.backoffLimit = 1;
|
job.spec.backoffLimit = 1;
|
||||||
await this.kubeClientBatch.createNamespacedJob(this.namespace, job);
|
return job;
|
||||||
core.info('Job created');
|
}
|
||||||
|
|
||||||
|
async runJob(jobSpec: k8s.V1Job) {
|
||||||
try {
|
try {
|
||||||
|
core.info('Creating build job');
|
||||||
|
await this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec);
|
||||||
|
core.info('Job created');
|
||||||
// We watch the PVC first to allow some time for K8s to notice the job we created and setup a pod.
|
// We watch the PVC first to allow some time for K8s to notice the job we created and setup a pod.
|
||||||
await this.watchPersistentVolumeClaimUntilReady();
|
await this.watchPersistentVolumeClaimUntilReady();
|
||||||
|
|
||||||
|
|
@ -281,6 +284,7 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
||||||
|
|
||||||
async runCloneJob() {
|
async runCloneJob() {
|
||||||
await this.runJob(
|
await this.runJob(
|
||||||
|
this.getJobSpec(
|
||||||
[
|
[
|
||||||
'/bin/ash',
|
'/bin/ash',
|
||||||
'-c',
|
'-c',
|
||||||
|
|
@ -297,11 +301,13 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
||||||
echo "end"`,
|
echo "end"`,
|
||||||
],
|
],
|
||||||
'alpine/git',
|
'alpine/git',
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async runBuildJob() {
|
async runBuildJob() {
|
||||||
await this.runJob(
|
await this.runJob(
|
||||||
|
this.getJobSpec(
|
||||||
[
|
[
|
||||||
'bin/bash',
|
'bin/bash',
|
||||||
'-c',
|
'-c',
|
||||||
|
|
@ -319,6 +325,7 @@ class Kubernetes implements RemoteBuilderProviderInterface {
|
||||||
`,
|
`,
|
||||||
],
|
],
|
||||||
this.baseImage.toString(),
|
this.baseImage.toString(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue