Files
runner-container-hooks/packages/k8s/README.md
T

46 lines
2.2 KiB
Markdown
Raw Normal View History

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](https://github.com/actions-runner-controller/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
2022-06-06 00:21:44 -04:00
```
2022-06-16 09:02:55 -04:00
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: default
name: runner-role
rules:
2022-06-06 00:21:44 -04:00
- apiGroups: [""]
resources: ["pods"]
2022-06-16 09:02:55 -04:00
verbs: ["get", "list", "create", "delete"]
2022-06-06 00:21:44 -04:00
- apiGroups: [""]
resources: ["pods/exec"]
2022-06-16 09:02:55 -04:00
verbs: ["get", "create"]
2022-06-06 00:21:44 -04:00
- apiGroups: [""]
resources: ["pods/log"]
2022-06-16 09:02:55 -04:00
verbs: ["get", "list", "watch",]
2022-06-06 00:21:44 -04:00
- apiGroups: ["batch"]
resources: ["jobs"]
2022-06-16 09:02:55 -04:00
verbs: ["get", "list", "create", "delete"]
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "list", "create", "delete"]
2022-06-06 00:21:44 -04:00
```
2022-06-02 15:53:11 -04:00
- The `ACTIONS_RUNNER_POD_NAME` env should be set to the name of the pod
2022-06-06 00:21:44 -04:00
- The `ACTIONS_RUNNER_REQUIRE_JOB_CONTAINER` env should be set to true to prevent the runner from running any jobs outside of a container
2022-06-02 15:53:11 -04:00
- The runner pod should map a persistent volume claim into the `_work` directory
2022-06-20 15:09:04 -04:00
- The `ACTIONS_RUNNER_CLAIM_NAME` env should be set to the persistent volume claim that contains the runner's working directory, otherwise it defaults to `${ACTIONS_RUNNER_POD_NAME}-work`
2022-06-06 00:21:44 -04:00
- 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
2022-06-06 22:42:46 -04:00
## Limitations
2022-06-16 09:02:55 -04:00
- A [job containers](https://docs.github.com/en/actions/using-jobs/running-jobs-in-a-container) will be required for all jobs
- 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
2022-06-06 22:42:46 -04:00
- Docker [create options](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idcontaineroptions) are not supported