Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion .github/build-and-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
npm run build
git add .
git commit -m update
git push origin2 feature/expose-ports
git push origin2 fix/check-default-sa-ready
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: debianmaster/actions-k3s@v1.0.3
- uses: debianmaster/actions-k3s@fix/check-default-sa-ready
id: k3s
with:
version: 'latest'
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ inputs:
version:
description: 'Version of k3s'
required: true
default: 'v1.0.0'
default: 'v1.0.3'
outputs:
kubeconfig: # id of output
description: 'Kubeconfig location'
Expand Down
27 changes: 23 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1875,25 +1875,44 @@ var __webpack_exports__ = {};
const core = __nccwpck_require__(964);
const exec = __nccwpck_require__(188);
const wait = __nccwpck_require__(110);
const fs = __nccwpck_require__(747);

async function run() {
try {
const version = core.getInput('version');
const kubeconfig_location="/tmp/output/kubeconfig-"+version+".yaml";
console.log(`storing kubeconfig here ${kubeconfig_location}!`);

await exec.exec('docker', ["run","-d","--privileged","--name=k3s-"+version,
"-e","K3S_KUBECONFIG_OUTPUT="+kubeconfig_location,
"-e","K3S_KUBECONFIG_MODE=666",
"-v","/tmp/output:/tmp/output","-p","6443:6443","-p","80:80","-p","443:443","-p","8080:8080",
"-v","/tmp/images:/var/lib/rancher/k3s/server/images",
"-v","/tmp/output:/tmp/output",
"-p","6443:6443","-p","80:80",
"-p","443:443","-p","8080:8080",
"rancher/k3s:"+version,"server"]);

var healthCheck="until [ -f /tmp/output/kubeconfig-latest.yaml ]";
fs.writeFileSync("./is-cluster-ready.sh", healthCheck);
fs.chmodSync("./is-cluster-ready.sh", "755");
var command="./is-cluster-ready.sh";
await exec.exec(healthCheck);


await wait(parseInt(10000));
core.exportVariable('KUBECONFIG', kubeconfig_location);
core.setOutput("kubeconfig", kubeconfig_location);
const nodeName=await exec.getExecOutput("kubectl get nodes --no-headers -oname");
var command="kubectl wait --for=condition=Ready "+nodeName.stdout;
await exec.exec(command);
await exec.exec(command);


var healthCheck="until kubectl get serviceaccount default; do sleep 1; done";
fs.writeFileSync("./is-cluster-ready.sh", healthCheck);
fs.chmodSync("./is-cluster-ready.sh", "755");
var command="./is-cluster-ready.sh";
await exec.exec(healthCheck);


} catch (error) {
core.setFailed(error.message);
}
Expand Down
27 changes: 23 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,44 @@
const core = require('@actions/core');
const exec = require('@actions/exec');
const wait = require('./wait');
const fs = require("fs");

async function run() {
try {
const version = core.getInput('version');
const kubeconfig_location="/tmp/output/kubeconfig-"+version+".yaml";
console.log(`storing kubeconfig here ${kubeconfig_location}!`);

await exec.exec('docker', ["run","-d","--privileged","--name=k3s-"+version,
"-e","K3S_KUBECONFIG_OUTPUT="+kubeconfig_location,
"-e","K3S_KUBECONFIG_MODE=666",
"-v","/tmp/output:/tmp/output","-p","6443:6443","-p","80:80","-p","443:443","-p","8080:8080",
"-v","/tmp/images:/var/lib/rancher/k3s/server/images",
"-v","/tmp/output:/tmp/output",
"-p","6443:6443","-p","80:80",
"-p","443:443","-p","8080:8080",
"rancher/k3s:"+version,"server"]);

var healthCheck="until [ -f /tmp/output/kubeconfig-latest.yaml ]";
fs.writeFileSync("./is-cluster-ready.sh", healthCheck);
fs.chmodSync("./is-cluster-ready.sh", "755");
var command="./is-cluster-ready.sh";
await exec.exec(healthCheck);


await wait(parseInt(10000));
core.exportVariable('KUBECONFIG', kubeconfig_location);
core.setOutput("kubeconfig", kubeconfig_location);
const nodeName=await exec.getExecOutput("kubectl get nodes --no-headers -oname");
var command="kubectl wait --for=condition=Ready "+nodeName.stdout;
await exec.exec(command);
await exec.exec(command);


var healthCheck="until kubectl get serviceaccount default; do sleep 1; done";
fs.writeFileSync("./is-cluster-ready.sh", healthCheck);
fs.chmodSync("./is-cluster-ready.sh", "755");
var command="./is-cluster-ready.sh";
await exec.exec(healthCheck);


} catch (error) {
core.setFailed(error.message);
}
Expand Down
1 change: 1 addition & 0 deletions tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM tutum/hello-world
2 changes: 2 additions & 0 deletions tests/is-cluster-ready.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
n=0; until ((n >= 60)); do kubectl -n default get serviceaccount default -o name && break; n=$((n + 1)); sleep 1; done; ((n < 60))