Files
runner-container-hooks/packages/k8s
Nikola Jokic 8ea57170d8 Fix working directory and write state for appPod to be used in run-script-step (#8)
* added initial entrypoint script

* change workingg directory working with addition to fix prepare-job state output

* added prepend path

* added run-script-step file generation, removed prepend path from container-step and prepare job

* latest changes with testing run script step

* fix the mounts real fast

* cleanup

* fix tests

* add kind test

* add kind yaml to ignore and run it during ci

* fix kind option

* remove gitignore

* lowercase pwd

* checkout first!

* ignore test file in build.yaml

* fixed wrong working directory and added test to run script step testing for the env

* handle env's/escaping better

* added single quote escape to env escapes

* surounded env value with single quote

* added spacing around run-container-step, changed examples to actually echo hello world

* refactored tests

* make sure to escape properly

* set addition mounts for container steps

* fixup container action mounts

Co-authored-by: Thomas Boop <thboop@github.com>
Co-authored-by: Thomas Boop <52323235+thboop@users.noreply.github.com>
2022-06-14 21:41:49 -04:00
..
2022-06-02 15:53:11 -04:00
2022-06-02 15:53:11 -04:00
2022-06-02 15:53:11 -04:00
2022-06-08 15:32:30 -04:00
2022-06-02 15:53:11 -04:00

K8s Hooks

Description

This implementation provides a way to dynamically spin up jobs to run container workflows, rather then relying on the default docker implementation. It is meant to be used when the runner itself is running in k8s, for example when using the Actions Runner Controller

Pre-requisites

Some things are expected to be set when using these hooks

  • The runner itself should be running in a pod, with a service account with the following permissions
- apiGroups: [""]
  resources: ["pods"]
  verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
- apiGroups: [""]
  resources: ["pods/exec"]
  verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
- apiGroups: [""]
  resources: ["pods/log"]
  verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
- apiGroups: ["batch"]
  resources: ["jobs"]
  verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
  • The ACTIONS_RUNNER_POD_NAME env should be set to the name of the pod
  • The ACTIONS_RUNNER_REQUIRE_JOB_CONTAINER env should be set to true to prevent the runner from running any jobs outside of a container
  • The runner pod should map a persistent volume claim into the _work directory
    • The ACTIONS_RUNNER_CLAIM_NAME env should be set to the persistent volume claim that contains the runner's working directory
  • Some actions runner env's are expected to be set. These are set automatically by the runner.
    • RUNNER_WORKSPACE is expected to be set to the workspace of the runner
    • GITHUB_WORKSPACE is expected to be set to the workspace of the job

Limitations

  • Container actions
    • Building container actions from a dockerfile is not supported at this time
    • Container actions will not have access to the services network or job container network
  • Docker create options are not supported