This commit is contained in:
TingluoHuang
2020-09-03 01:12:46 -04:00
parent 58afa42109
commit 7da6739eae
5 changed files with 35 additions and 17 deletions

View File

@@ -40,6 +40,10 @@ COPY ./src/Misc/jobstart.sh /actions-runner/jobstart.sh
COPY ./src/Misc/jobrunning.sh /actions-runner/jobrunning.sh COPY ./src/Misc/jobrunning.sh /actions-runner/jobrunning.sh
COPY ./src/Misc/jobcomplete.sh /actions-runner/jobcomplete.sh COPY ./src/Misc/jobcomplete.sh /actions-runner/jobcomplete.sh
# Allow runner to run as root
ENV RUNNER_ALLOW_RUNASROOT=1
RUN /actions-runner/download-runner.sh RUN /actions-runner/download-runner.sh
RUN rm -f /actions-runner/download-runner.sh RUN rm -f /actions-runner/download-runner.sh

View File

@@ -4,7 +4,11 @@ metadata:
name: auto-scale-runners name: auto-scale-runners
spec: spec:
replicas: 1 replicas: 1
maxRunnerLimit: 15 maxRunnerLimit: 5
template: template:
spec: spec:
repository: monalisa/main123 configURL: https://github.com/bbq-beets/ting-test
githubTokenSecretKeyRef:
name: githubtoken
key: GITHUB_PAT

View File

@@ -4,14 +4,11 @@ metadata:
name: auto-scale-runners name: auto-scale-runners
spec: spec:
minReplicas: 1 minReplicas: 1
maxReplicas: 10 maxReplicas: 5
configURL: https://github.com/TingluoHuang/example-services
githubTokenSecretKeyRef:
name: githubtoken
key: GITHUB_PAT
template: template:
spec: spec:
organization: monalisa setupDockerInDocker: true
group: default
repository: main123
gitHubAdminToken: 62c13e14e947958516c103a9584f66227697c447
imagePullPolicy: Always
env:
- name: K8S_HOST_IP
value: "192.168.120.1"

View File

@@ -9,12 +9,13 @@ function fatal() {
[ -n "${GITHUB_PAT:-""}" ] || fatal "GITHUB_PAT variable must be set" [ -n "${GITHUB_PAT:-""}" ] || fatal "GITHUB_PAT variable must be set"
[ -n "${RUNNER_CONFIG_URL:-""}" ] || fatal "RUNNER_CONFIG_URL variable must be set" [ -n "${RUNNER_CONFIG_URL:-""}" ] || fatal "RUNNER_CONFIG_URL variable must be set"
[ -n "${RUNNER_NAME:-""}" ] || fatal "RUNNER_NAME variable must be set"
if [ -n "${RUNNER_NAME}" ]; then # if [ -n "${RUNNER_NAME}" ]; then
# Use container id to gen unique runner name if name not provide # # Use container id to gen unique runner name if name not provide
CONTAINER_ID=$(cat /proc/self/cgroup | head -n 1 | tr '/' '\n' | tail -1 | cut -c1-12) # CONTAINER_ID=$(cat /proc/self/cgroup | head -n 1 | tr '/' '\n' | tail -1 | cut -c1-12)
RUNNER_NAME="actions-runner-${CONTAINER_ID}" # RUNNER_NAME="actions-runner-${CONTAINER_ID}"
fi # fi
# if the scope has a slash, it's a repo runner # if the scope has a slash, it's a repo runner
# orgs_or_repos="orgs" # orgs_or_repos="orgs"

View File

@@ -140,6 +140,11 @@ namespace GitHub.Runner.Worker
executionContext.JobContext.Container["network"] = new StringContextData(containerNetwork); executionContext.JobContext.Container["network"] = new StringContextData(containerNetwork);
executionContext.Output("##[endgroup]"); executionContext.Output("##[endgroup]");
if (Environment.GetEnvironmentVariable("K8S_POD_NAME") != null)
{
IOUtil.CopyDirectory(HostContext.GetDirectory(WellKnownDirectory.Externals), Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Work), "__externals_copy"), CancellationToken.None);
}
foreach (var container in containers) foreach (var container in containers)
{ {
container.ContainerNetwork = containerNetwork; container.ContainerNetwork = containerNetwork;
@@ -236,7 +241,14 @@ namespace GitHub.Runner.Worker
#if OS_WINDOWS #if OS_WINDOWS
container.MountVolumes.Add(new MountVolume(HostContext.GetDirectory(WellKnownDirectory.Externals), container.TranslateToContainerPath(HostContext.GetDirectory(WellKnownDirectory.Externals)))); container.MountVolumes.Add(new MountVolume(HostContext.GetDirectory(WellKnownDirectory.Externals), container.TranslateToContainerPath(HostContext.GetDirectory(WellKnownDirectory.Externals))));
#else #else
if (Environment.GetEnvironmentVariable("K8S_POD_NAME") != null)
{
container.MountVolumes.Add(new MountVolume(Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Work), "__externals_copy"), container.TranslateToContainerPath(HostContext.GetDirectory(WellKnownDirectory.Externals)), true));
}
else
{
container.MountVolumes.Add(new MountVolume(HostContext.GetDirectory(WellKnownDirectory.Externals), container.TranslateToContainerPath(HostContext.GetDirectory(WellKnownDirectory.Externals)), true)); container.MountVolumes.Add(new MountVolume(HostContext.GetDirectory(WellKnownDirectory.Externals), container.TranslateToContainerPath(HostContext.GetDirectory(WellKnownDirectory.Externals)), true));
}
#endif #endif
container.MountVolumes.Add(new MountVolume(HostContext.GetDirectory(WellKnownDirectory.Temp), container.TranslateToContainerPath(HostContext.GetDirectory(WellKnownDirectory.Temp)))); container.MountVolumes.Add(new MountVolume(HostContext.GetDirectory(WellKnownDirectory.Temp), container.TranslateToContainerPath(HostContext.GetDirectory(WellKnownDirectory.Temp))));
container.MountVolumes.Add(new MountVolume(HostContext.GetDirectory(WellKnownDirectory.Actions), container.TranslateToContainerPath(HostContext.GetDirectory(WellKnownDirectory.Actions)))); container.MountVolumes.Add(new MountVolume(HostContext.GetDirectory(WellKnownDirectory.Actions), container.TranslateToContainerPath(HostContext.GetDirectory(WellKnownDirectory.Actions))));