Skip to content

Commit

Permalink
Merge branch 'master' of github.com:yellowmegaman/k3s-gha
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowmegaman committed May 26, 2020
2 parents 4cd3e45 + db4db2b commit 6ae1aa8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ A GitHub Action for running k3s kubernetes cluster

## Optional Input parameters
* k3s_tag - k3s tag to use. (can be found at https://hub.docker.com/r/rancher/k3s/tags)
* parent_workspace - workspace path on runner, obtainer from context, no need to specify anything here, except you know what you're doing
* registries_yaml_path - relative path of registries.yaml
* kubectl_version
* install_kubectl - enabled by default, copies kubectl to bin dir in workspace to allow other steps to use kubectl
Expand Down
4 changes: 0 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ inputs:
custom_registry:
description: "whenever to use registries.yaml in your repo or not"
required: true
parent_workspace:
description: "this value is used to mount your registries.yaml file"
required: false
default: ${{github.workspace}}
registries_yaml_path:
description: "where to look for registries.yaml relative path"
required: false
Expand Down
29 changes: 11 additions & 18 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,36 @@
curl -L -s --create-dirs https://storage.googleapis.com/kubernetes-release/release/"$INPUT_KUBECTL_VERSION"/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl
chmod +x /usr/local/bin/kubectl


export KUBECONFIG=k3s.yaml
export RUNNER_HOSTNAME=$(docker info --format '{{lower .Name}}')

docker run -d --name=k3s --privileged --tmpfs /run --tmpfs /var/run -p 6443:6443 -p 80:80 $(if [ "$INPUT_CUSTOM_REGISTRY" = true ]; then echo --mount "type=bind,src=$INPUT_PARENT_WORKSPACE/$INPUT_REGISTRIES_YAML_PATH,dst=/etc/rancher/k3s/registries.yaml"; fi) rancher/k3s:$INPUT_K3S_TAG server "$INPUT_K3S_ARGUMENTS"
docker run -d --name=k3s --privileged --tmpfs /run --tmpfs /var/run -p 6443:6443 -p 80:80 $(if [ "$INPUT_CUSTOM_REGISTRY" = true ]; then echo --mount "type=bind,src=$RUNNER_WORKSPACE/$(echo $RUNNER_WORKSPACE | sed 's|.*/||')/$INPUT_REGISTRIES_YAML_PATH,dst=/etc/rancher/k3s/registries.yaml"; fi) rancher/k3s:$INPUT_K3S_TAG server "$INPUT_K3S_ARGUMENTS"

sleep 15

docker cp k3s:/etc/rancher/k3s/k3s.yaml .
sed -i "s/127.0.0.1/$RUNNER_HOSTNAME/g" k3s.yaml

### 'wait for k3s'
echo 'wait for k3s'
for attempt in {1..60}; do
if kubectl version; then
break;
elif [ "$attempt" -eq 120 ]; then
echo "timeout reached"
exit 1
else
echo "k3s is not yet up"
sleep 3
fi
done

### 'wait for traefik is READY'
for attempt in {1..60}; do
if kubectl -n kube-system get pod -o custom-columns=POD:metadata.name,READY:status.containerStatuses[*].ready | grep true | grep '^traefik'; then
break
elif [ "$attempt" -eq 60 ]; then
exit 1
else
sleep 1; echo -n '.'
fi
done

### 'wait for coredns is READY'
for attempt in {1..60}; do
echo 'wait for coredns is READY'
for attempt in {1..120}; do
if kubectl -n kube-system get pod -o custom-columns=POD:metadata.name,READY:status.containerStatuses[*].ready | grep true | grep '^coredns'; then
break
elif [ "$attempt" -eq 60 ]; then
elif [ "$attempt" -eq 120 ]; then
echo "timeout reached"
kubectl get all --all-namespaces
exit 1
else
sleep 1
Expand All @@ -49,7 +42,7 @@ for attempt in {1..60}; do
done


### 'get all resources'
echo 'get all resources'
kubectl get all --all-namespaces

chmod a+r k3s.yaml
Expand Down

0 comments on commit 6ae1aa8

Please sign in to comment.