Add Gitea Actions act runner #596

Closed
dementhorr wants to merge 16 commits from gitea-actions into main
dementhorr commented 2024-01-06 17:30:45 +00:00 (Migrated from gitea.com)

Description of the change

This adds support for Gitea actions that uses act runner. It allows for automatic act runner deployment.

Benefits

Users no longer need to deploy Gitea act runners manually.

Applicable issues

Closes #459.

Additional information

Following the discussion on #459, I agree with monester comments.

As specified in this comment I have saved the runner token in a k8s secret.

For this, it was required to create the secret using the Gitea CLI command gitea actions generate-runner-token and then to use the kubectl command with a service account to create the secret. This has been implement as a Job. The other way of generating the token can be seen in the discussion (using initContainers and changing the env variable to point to the file where the token is), but in order to create the k8s secret one needs to use a job with another service account. This chart uses the same way of storing a k8s secret that was generated with a CLI command.

As specified by monester, the act-runner must be a statefulset that has persistence volumes since the .runner is different for each pod and it can't be deregistered.

Also, the upstream problems from this comment still stand:

  • the act runner doesn't have nodejs installed; in this PR it is installed using a lifecycle.postStart.exec.command;
  • can't scale the statefulset because there are no exposed metrics.
<!-- Before you open the request please review the following guidelines and tips to help it be more easily integrated: - Describe the scope of your change - i.e. what the change does. - Describe any known limitations with your change. - Please run any tests or examples that can exercise your modified code. Thank you for contributing! We will try to review, test and integrate the change as soon as we can. --> ### Description of the change This adds support for [Gitea actions](https://docs.gitea.com/usage/actions/overview) that uses [act runner](https://gitea.com/gitea/act_runner). It allows for automatic act runner deployment. ### Benefits Users no longer need to deploy Gitea act runners manually. ### Applicable issues Closes [#459](https://gitea.com/gitea/helm-chart/issues/459). ### Additional information Following the discussion on [#459](https://gitea.com/gitea/helm-chart/issues/459), I agree with [monester](https://gitea.com/monester) comments. As specified in this [comment](https://gitea.com/gitea/helm-chart/issues/459#issuecomment-750798) I have saved the runner token in a k8s secret. For this, it was required to create the secret using the Gitea CLI command `gitea actions generate-runner-token` and then to use the kubectl command with a service account to create the secret. This has been implement as a Job. The other way of generating the token can be seen in the discussion (using initContainers and changing the env variable to point to the file where the token is), but in order to create the k8s secret one needs to use a job with another service account. This [chart](https://gitlab.com/ananace/charts/-/tree/master/charts/matrix-synapse) uses the same way of storing a k8s secret that was generated with a CLI command. As specified by monester, the act-runner must be a statefulset that has persistence volumes since the .runner is different for each pod and it can't be deregistered. Also, the upstream problems from this [comment](https://gitea.com/gitea/helm-chart/issues/459#issuecomment-752443) still stand: - the act runner doesn't have nodejs installed; in this PR it is installed using a lifecycle.postStart.exec.command; - can't scale the statefulset because there are no exposed metrics.
dementhorr commented 2024-01-06 17:44:21 +00:00 (Migrated from gitea.com)

On second thought, the lifecycle.postStart.exec.command can be removed since you can install it inside the Gitea Action:

    steps:
      - name: install tools
        run: |
          apk update
          apk add --update make nodejs npm yamllint          
On second thought, the lifecycle.postStart.exec.command can be removed since you can install it inside the Gitea Action: ``` steps: - name: install tools run: | apk update apk add --update make nodejs npm yamllint ```
pat-s commented 2024-01-08 12:42:43 +00:00 (Migrated from gitea.com)

@dementhorr Thanks for contributing!

Both me and @justusbunsi are quite busy during the start of the year. I'll try to add my review within the next days so we can make some progress/get an initial discussion going.
Yet what would definitely be a requirement in getting this merged (besides all details TBD) is the addition of unit tests (see the existing ones).

@dementhorr Thanks for contributing! Both me and @justusbunsi are quite busy during the start of the year. I'll try to add my review within the next days so we can make some progress/get an initial discussion going. Yet what would definitely be a requirement in getting this merged (besides all details TBD) is the addition of unit tests (see the existing ones).
pat-s (Migrated from gitea.com) reviewed 2024-01-10 08:52:01 +00:00
pat-s (Migrated from gitea.com) left a comment

Thanks again for starting here! The effort is much appreciated.
I hope my review is not too overwhelming and you brought some resource for discussion. Some points still need discussion. We can also do so in the Gitea discord to not bloat this PR too much - feel free to ping me there.

I would suggest adding templates/act_runner and putting all new templates there instead of templates/gitea/actions/.

Open discussion points

Disclaimer: I haven't done a deep dive into act runner yet (and have no time right now), so everything I propose/state here relies on other, similar projects (GitHub self hosted runners, other charts which server external runners)

  • Do we need a statefulset? We moved from a statefuleset to a deployment (+RWX) in the chart some time ago for easier replica scaling.
    Given that there is no need for an internal leader selection in the act runner, a statefulset might not be needed or even make sense. This of course only applies if the persistent config is shared between them using a RWX. Other "runner" charts all make use of deployments, see e.g. https://github.com/actions/actions-runner-controller/blob/master/charts/gha-runner-scale-set-controller/templates/deployment.yaml.

  • Persistence: is it even needed? Or could the act runner also just live with env vars set in the deployment resource and the k8s secret for connectivity? Is it needed for logs or are they stored in the persistent dir of Gitea itself? If not, maybe we can configure it do so? Does the runner have an integrated logrotate config?

Persistence

Act runner should have it's own persistence mapping. This allows for more flexibility and less conflicts with the gitea persistence one. I wonder if it would even work this way since they would share the same PV/PVC right now AFAICS.

Images

We have the policy to use semver tags everywhere instead of latest. The repo uses renovate and all semver tags are updated in a bundled way in a specified interval. This makes it easier to control updates and inspect what could have broken something (yes, even if it's only a busybox image :))

Tests

For the tests, we should add some "meaningful" ones, i.e. we don't need to check that the configmaps/statefulsets are just existing (this is usually not an issue) but that they also "do" what they are supposed to do. I.e. if certain mappings result in certain resources/values which are created dynamically. Specifically, checking for actions of non-default values and their validity.

Thanks again for starting here! The effort is much appreciated. I hope my review is not too overwhelming and you brought some resource for discussion. Some points still need discussion. We can also do so in the Gitea discord to not bloat this PR too much - feel free to ping me there. I would suggest adding `templates/act_runner` and putting all new templates there instead of `templates/gitea/actions/`. ## Open discussion points Disclaimer: I haven't done a deep dive into act runner yet (and have no time right now), so everything I propose/state here relies on other, similar projects (GitHub self hosted runners, other charts which server external runners) - Do we need a statefulset? We moved from a statefuleset to a deployment (+RWX) in the chart some time ago for easier replica scaling. Given that there is no need for an internal leader selection in the act runner, a statefulset might not be needed or even make sense. This of course only applies if the persistent config is shared between them using a RWX. Other "runner" charts all make use of deployments, see e.g. https://github.com/actions/actions-runner-controller/blob/master/charts/gha-runner-scale-set-controller/templates/deployment.yaml. - Persistence: is it even needed? Or could the act runner also just live with env vars set in the deployment resource and the k8s secret for connectivity? Is it needed for logs or are they stored in the persistent dir of Gitea itself? If not, maybe we can configure it do so? Does the runner have an integrated logrotate config? ## Persistence Act runner should have it's own persistence mapping. This allows for more flexibility and less conflicts with the gitea persistence one. I wonder if it would even work this way since they would share the same PV/PVC right now AFAICS. ## Images We have the policy to use semver tags everywhere instead of latest. The repo uses renovate and all semver tags are updated in a bundled way in a specified interval. This makes it easier to control updates and inspect what could have broken something (yes, even if it's only a busybox image :)) ## Tests For the tests, we should add some "meaningful" ones, i.e. we don't need to check that the configmaps/statefulsets are just existing (this is usually not an issue) but that they also "do" what they are supposed to do. I.e. if certain mappings result in certain resources/values which are created dynamically. Specifically, checking for actions of non-default values and their validity.
pat-s (Migrated from gitea.com) commented 2024-01-10 08:55:04 +00:00

I think this should be way shorter. If a token doesn't exist or cannot be created for some reason, it won't resolve itself anyhow. I think 10-15 seconds would also suffice?

I think this should be way shorter. If a token doesn't exist or cannot be created for some reason, it won't resolve itself anyhow. I think 10-15 seconds would also suffice?
pat-s (Migrated from gitea.com) commented 2024-01-10 08:52:01 +00:00

echo "Timed out waiting for a token to appear."

This reminds me about the "good old days" waiting for Pokemon XY to appear 😛

Suggestion:

"Checking for an existing act runner token in secret $SECRET_NAME timed out after $time".

> echo "Timed out waiting for a token to appear." This reminds me about the "good old days" waiting for Pokemon XY to appear 😛 Suggestion: "Checking for an existing act runner token in secret $SECRET_NAME timed out after $time".
pat-s (Migrated from gitea.com) commented 2024-01-10 08:57:28 +00:00

The act runner config should be configurable in values.yml.

The act runner config should be configurable in `values.yml`.
pat-s (Migrated from gitea.com) commented 2024-01-10 08:58:45 +00:00

Scheduling it as a post-install hook makes sense. Why did you comment it out here?

Scheduling it as a post-install hook makes sense. Why did you comment it out here?
pat-s (Migrated from gitea.com) commented 2024-01-14 13:25:41 +00:00

I tried it but it didn't work. I had the chicken-egg problem, in order for the deployment to be completed it had to have the secret, but to have the secret, the deployment should have completed, so it was a deadlock.

I tried it but it didn't work. I had the chicken-egg problem, in order for the deployment to be completed it had to have the secret, but to have the secret, the deployment should have completed, so it was a deadlock.
pat-s (Migrated from gitea.com) commented 2024-01-10 09:07:01 +00:00

Instead of latest-rootless we should use a semver tag here and versionize it via renovate.

Instead of `latest-rootless` we should use a semver tag here and versionize it via `renovate`.
pat-s (Migrated from gitea.com) commented 2024-01-14 13:26:21 +00:00

Changed the tag, but didn't modify renovate config.

Changed the tag, but didn't modify renovate config.
pat-s (Migrated from gitea.com) commented 2024-01-10 09:00:43 +00:00

echo "Generating act_runner token via 'gitea actions generate-runner-token' and storing in kubernetes secret..."

echo "Generating act_runner token via 'gitea actions generate-runner-token' and storing in kubernetes secret..."
pat-s (Migrated from gitea.com) commented 2024-01-10 09:08:08 +00:00

Instead of latest we should use a semver tag here and versionize it via renovate.

Instead of `latest` we should use a semver tag here and versionize it via `renovate`.
pat-s (Migrated from gitea.com) commented 2024-01-14 13:26:50 +00:00

Changed the tag, but didn't modify renovate config.

Changed the tag, but didn't modify renovate config.
pat-s (Migrated from gitea.com) commented 2024-01-10 09:08:36 +00:00

printf "Checking rights to update kubernetes act_runner secret... "

printf "Checking rights to update kubernetes act_runner secret... "
pat-s (Migrated from gitea.com) commented 2024-01-10 09:09:35 +00:00

What are those argocd hooks needed for?

What are those argocd hooks needed for?
pat-s (Migrated from gitea.com) commented 2024-01-10 09:10:29 +00:00

Instead of latest we should use a semver tag here and versionize it via renovate.

Instead of `latest` we should use a semver tag here and versionize it via `renovate`.
pat-s (Migrated from gitea.com) commented 2024-01-14 13:27:10 +00:00

Changed the tag, but didn't modify renovate config.

Changed the tag, but didn't modify renovate config.
pat-s (Migrated from gitea.com) commented 2024-01-10 09:11:14 +00:00

The port could differ and should dynamically use the respective port of the main gitea deployment.

The port could differ and should dynamically use the respective port of the main gitea deployment.
pat-s (Migrated from gitea.com) commented 2024-01-10 09:06:31 +00:00

Instead of latest we should use a semver tag here and versionize it via renovate.

Instead of `latest` we should use a semver tag here and versionize it via `renovate`.
pat-s (Migrated from gitea.com) commented 2024-01-14 13:27:35 +00:00

Changed the tag, but didn't modify renovate config.

Changed the tag, but didn't modify renovate config.
pat-s (Migrated from gitea.com) commented 2024-01-10 09:04:08 +00:00

This should be configurable/exposed in values.yml.

This should be configurable/exposed in `values.yml`.
pat-s (Migrated from gitea.com) commented 2024-01-14 13:28:24 +00:00

Used the already defined variables from values.yml.

Used the already defined variables from `values.yml`.
pat-s (Migrated from gitea.com) commented 2024-01-10 09:04:15 +00:00

This should be configurable/exposed in values.yml.

This should be configurable/exposed in `values.yml`.
pat-s (Migrated from gitea.com) commented 2024-01-10 09:05:54 +00:00

We can expose the tag in values.yml directly and let the version be maintained by renovate.

We can expose the tag in `values.yml` directly and let the version be maintained by `renovate`.
pat-s (Migrated from gitea.com) commented 2024-01-14 13:29:08 +00:00

Changed the tag, but didn't modify renovate config.

Changed the tag, but didn't modify renovate config.
pat-s (Migrated from gitea.com) commented 2024-01-10 09:12:14 +00:00
  • it: renders a valid statefulset
- it: renders a valid statefulset
dementhorr commented 2024-01-13 15:31:56 +00:00 (Migrated from gitea.com)
  • Do we need a statefulset? We moved from a statefuleset to a deployment (+RWX) in the chart some time ago for easier replica scaling.

I haven't seen a way to unregister an act runner, only to register it. This is a problem since they are registered in the Runners Management UI. If we don't store the the .runner config file in a persistent volume, each time a new runner will start it will have another name. So that means there will be very many runners. Right now (when using StatefulSet with persistence) I get:

Idle	1 	gitea-act-runner-0 v0.2.6 	Global	ubuntu-latest	3 minutes ago
Offline	2 	gitea-act-runner-1 v0.2.6 	Global	ubuntu-latest	5 minutes ago
Offline	3 	gitea-act-runner-2 v0.2.6 	Global	ubuntu-latest	5 minutes ago
Offline	4 	gitea-act-runner-3 v0.2.6 	Global	ubuntu-latest	5 minutes ago
Offline	5 	gitea-act-runner-4 v0.2.6 	Global	ubuntu-latest	5 minutes ago

If I scale the StatefulSet to 3 replicas, I get:

Idle	1 	gitea-act-runner-0 v0.2.6 	Global	ubuntu-latest	now
Idle	2 	gitea-act-runner-1 v0.2.6 	Global	ubuntu-latest	now
Idle	3 	gitea-act-runner-2 v0.2.6 	Global	ubuntu-latest	now
Offline	4 	gitea-act-runner-3 v0.2.6 	Global	ubuntu-latest	8 minutes ago
Offline	5 	gitea-act-runner-4 v0.2.6 	Global	ubuntu-latest	8 minutes ago

With a deployment, each time I scale, I would get another act-runner instance, so if I scale up and down 5 times from 1 to 5 replicas, I would have 1 Idle gitea-act-runner-XXXXXXX and 20 Offline gitea-act-runner-XXXXXX as I didn't find a way to really delete (unregister) act runners.

So the real reason for the StatefulSet is not for a leader, but to be able to store the .runner file. If this doesn't matter (the clutter), we can easily switch to a deployment and just ignore the offline runners.

  • Persistence: is it even needed?

The act runners' logs are stored in the gitea PVC, so we only need the PVC for the .runner file. If we switch to deployments, we won't need any PVCs.

Persistence for the Gitea dir is needed in order to store the Gitea Actions Token as a Kubernetes Secret. Right now, the token is stored in the the persistent Gitea dir /data/actions/token and the Job mounts the volume such that kubectl can patch the secret. Without persistency, the Job can't access the token.

Regarding renovate, I don't exactly know how to use and test it. I have changed the tags from latest to a semver tag, configurable in values.yaml.

- Do we need a statefulset? We moved from a statefuleset to a deployment (+RWX) in the chart some time ago for easier replica scaling. I haven't seen a way to unregister an act runner, only to register it. This is a problem since they are registered in the Runners Management UI. If we don't store the the `.runner` config file in a persistent volume, each time a new runner will start it will have another name. So that means there will be very many runners. Right now (when using StatefulSet with persistence) I get: ``` Idle 1 gitea-act-runner-0 v0.2.6 Global ubuntu-latest 3 minutes ago Offline 2 gitea-act-runner-1 v0.2.6 Global ubuntu-latest 5 minutes ago Offline 3 gitea-act-runner-2 v0.2.6 Global ubuntu-latest 5 minutes ago Offline 4 gitea-act-runner-3 v0.2.6 Global ubuntu-latest 5 minutes ago Offline 5 gitea-act-runner-4 v0.2.6 Global ubuntu-latest 5 minutes ago ``` If I scale the StatefulSet to 3 replicas, I get: ``` Idle 1 gitea-act-runner-0 v0.2.6 Global ubuntu-latest now Idle 2 gitea-act-runner-1 v0.2.6 Global ubuntu-latest now Idle 3 gitea-act-runner-2 v0.2.6 Global ubuntu-latest now Offline 4 gitea-act-runner-3 v0.2.6 Global ubuntu-latest 8 minutes ago Offline 5 gitea-act-runner-4 v0.2.6 Global ubuntu-latest 8 minutes ago ``` With a deployment, each time I scale, I would get another act-runner instance, so if I scale up and down 5 times from 1 to 5 replicas, I would have 1 Idle `gitea-act-runner-XXXXXXX` and 20 Offline `gitea-act-runner-XXXXXX` as I didn't find a way to really delete (unregister) act runners. So the real reason for the StatefulSet is not for a leader, but to be able to store the `.runner` file. If this doesn't matter (the clutter), we can easily switch to a deployment and just ignore the offline runners. - Persistence: is it even needed? The act runners' logs are stored in the gitea PVC, so we only need the PVC for the `.runner` file. If we switch to deployments, we won't need any PVCs. Persistence for the Gitea dir is needed in order to store the Gitea Actions Token as a Kubernetes Secret. Right now, the token is stored in the the persistent Gitea dir `/data/actions/token` and the Job mounts the volume such that kubectl can patch the secret. Without persistency, the Job can't access the token. Regarding renovate, I don't exactly know how to use and test it. I have changed the tags from latest to a semver tag, configurable in `values.yaml`.
pat-s commented 2024-01-22 09:50:08 +00:00 (Migrated from gitea.com)

@dementhorr I don't have enough time right now to get back to this, it's on the list though!

@dementhorr I don't have enough time right now to get back to this, it's on the list though!
pat-s commented 2024-01-30 10:30:58 +00:00 (Migrated from gitea.com)

Thanks for your patience!

Deployment vs. Statefulset

So the real reason for the StatefulSet is not for a leader, but to be able to store the .runner file. If this doesn't matter (the clutter), we can easily switch to a deployment and just ignore the offline runners.

You can also attach a PV to a deployment. That's how the chart currently works. The deployment resource doesn't necessarily mean it's stateless. The resource kind also has an effect on how k8s treats the pods WRT to updating/replacement. So deployment + RWX works quite well, what doesn't work so well is deployment + RWO or statefulset + RWX.

Statefulsets vs. deployments is a bigger topic which we already discussed before making the switch. Yet this doesn't mean we are bound to only deployments now, it always a new decision to make.

If we really need distinct pods for each runner with a persistent config then I guess statefulset + RWO (with a very small size) would be the best. What do you think?

One point which is still missing is affinity + nodeSelector. These are needed to control the placement of the agents, most commonly to force a placement on arm64 or amd64 nodes. Would you mind adding these to the statefulset definition?

Dind

Do we really need it? Some months ago we removed a similar approach in the Woodpecker helm chart as dind was not needed anymore. I need to check again on the details but maybe we could also omit it here.

Thanks for your patience! ## Deployment vs. Statefulset > So the real reason for the StatefulSet is not for a leader, but to be able to store the .runner file. If this doesn't matter (the clutter), we can easily switch to a deployment and just ignore the offline runners. You can also attach a PV to a deployment. That's how the chart currently works. The `deployment` resource doesn't necessarily mean it's stateless. The resource kind also has an effect on how k8s treats the pods WRT to updating/replacement. So deployment + RWX works quite well, what doesn't work so well is deployment + RWO or statefulset + RWX. Statefulsets vs. deployments is a bigger topic which we already discussed before making the switch. Yet this doesn't mean we are bound to only deployments now, it always a new decision to make. If we really need distinct pods for each runner with a persistent config then I guess statefulset + RWO (with a very small size) would be the best. What do you think? One point which is still missing is affinity + nodeSelector. These are needed to control the placement of the agents, most commonly to force a placement on `arm64` or `amd64` nodes. Would you mind adding these to the statefulset definition? ## Dind Do we really need it? Some months ago we removed a similar approach in the Woodpecker helm chart as dind was not needed anymore. I need to check again on the details but maybe we could also omit it here.
dementhorr commented 2024-02-07 18:26:30 +00:00 (Migrated from gitea.com)

I have added affinity, tolerations and nodeSelector for the statefulset and for the job.

I don't think that using a deployment with a RWX would work since the Gitea act runner would create a .runner file in the current working directory and as soon as another pod would start it will overwrite that file. Maybe there is a way to create a new dir for each runner and change the dir with workingDir to match the hostname, but I think it would make the chart more complicated.

In my opinion we should either stick with the StatefulSet with a very small volume to accomodate the .runner file, or switch to Deployment without any volumes, and maybe in the future Gitea will do some garbage collection to delete inactive runners.

Regarding Dind, I don't think the act runners work the same way in Gitea as in Woodpecker. From my understanding, each step in Woodpecker would spawn a new container (inside a pod) that would run in the cluster (so it's like a First Citizen approach). For the act runner it seems that all the steps run in the same container and that's why we have two containers per runner (1 agent, 1 dind) (so there isn't any transparency as with Woodpecker k8s backend). I may be wrong, though.

I have added affinity, tolerations and nodeSelector for the statefulset and for the job. I don't think that using a deployment with a RWX would work since the Gitea act runner would create a `.runner` file in the current working directory and as soon as another pod would start it will overwrite that file. Maybe there is a way to create a new dir for each runner and change the dir with `workingDir` to match the hostname, but I think it would make the chart more complicated. In my opinion we should either stick with the **StatefulSet** with a very small volume to accomodate the `.runner` file, or switch to **Deployment** without any volumes, and maybe in the future Gitea will do some garbage collection to delete inactive runners. Regarding **Dind**, I don't think the act runners work the same way in Gitea as in Woodpecker. From my understanding, each step in Woodpecker would spawn a new container (inside a pod) that would run in the cluster (so it's like a First Citizen approach). For the act runner it seems that all the steps run in the same container and that's why we have two containers per runner (1 agent, 1 dind) (so there isn't any transparency as with Woodpecker k8s backend). I may be wrong, though.
pat-s (Migrated from gitea.com) reviewed 2024-02-11 11:38:44 +00:00
@ -1024,3 +981,3 @@
| `signing.privateKey` | Inline private gpg key for signed internal Git activity | `""` |
| `signing.privateKey` | Inline private gpg key for signed Gitea actions | `""` |
| `signing.existingSecret` | Use an existing secret to store the value of `signing.privateKey` | `""` |
pat-s (Migrated from gitea.com) commented 2024-02-11 11:38:44 +00:00

Gitea Actions

Gitea Actions
@ -1059,2 +986,2 @@
| `actions.existingSecret` | Secret that contains the token | `""` |
| `actions.existingSecretKey` | Secret key | `""` |
| Name | Description | Value |
| ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
pat-s (Migrated from gitea.com) commented 2024-02-11 11:39:58 +00:00

I'd suggest using actions.enabled as a global flag for enabling actions.

I'd suggest using `actions.enabled` as a global flag for enabling actions.
@ -1061,0 +997,4 @@
| `actions.statefulset.actRunner.pullPolicy` | The Gitea act runner pullPolicy | `IfNotPresent` |
| `actions.statefulset.actRunner.config` | Act runner custom configuration. See [Act Runner documentation](https://docs.gitea.com/usage/actions/act-runner#configuration) for details. | `Too complex. See values.yaml` |
| `actions.statefulset.dind.repository` | The Docker-in-Docker image | `docker` |
| `actions.statefulset.dind.tag` | The Docker-in-Docker image tag | `25.0.2-dind` |
pat-s (Migrated from gitea.com) commented 2024-02-11 11:40:17 +00:00

let's bump to 25.0.2

let's bump to 25.0.2
pat-s (Migrated from gitea.com) commented 2024-02-11 11:42:33 +00:00

I'd leave this comment out as it's too k8s-internal-specific and might cause more confusion than it possibly helps. We also don't have stdout comments in other places and I haven't seen any other chart doing this.

I'd leave this comment out as it's too k8s-internal-specific and might cause more confusion than it possibly helps. We also don't have stdout comments in other places and I haven't seen any other chart doing this.
@ -1,14 +1,11 @@
{{- if .Values.actions.enabled }}
{{- if and (and .Values.actions.provisioning.enabled .Values.persistence.enabled) .Values.persistence.mount }}
pat-s (Migrated from gitea.com) commented 2024-02-11 11:46:38 +00:00

Would the non-creation of this part still lead to a functional actions?
If not, I would suggest to only condition essential parts on actions.enabled.

Would the non-creation of this part still lead to a functional actions? If not, I would suggest to only condition essential parts on `actions.enabled`.
pat-s (Migrated from gitea.com) commented 2024-02-23 18:33:11 +00:00

In the current chart format, you can use the act-runner without the job and the persistence volumes if you manually generate the token (via Web UI or running a shell command into the pod) and save it to a Secret. After that you can specify actions.existingSecret and actions.existingSecretKey.

In the current chart format, you can use the `act-runner` without the job and the persistence volumes if you manually generate the `token` (via Web UI or running a shell command into the pod) and save it to a Secret. After that you can specify `actions.existingSecret` and `actions.existingSecretKey`.
@ -398,3 +379,4 @@
tag: 0.2.6
pullPolicy: IfNotPresent
config: |
pat-s (Migrated from gitea.com) commented 2024-02-11 11:52:23 +00:00

I'd remove the Image part from the name. Same for dind.

I'd remove the `Image` part from the name. Same for `dind`.
pat-s commented 2024-02-11 11:54:17 +00:00 (Migrated from gitea.com)

I don't think that using a deployment with a RWX would work since the Gitea act runner would create a .runner file in the current working directory and as soon as another pod would start it will overwrite that file. Maybe there is a way to create a new dir for each runner and change the dir with workingDir to match the hostname, but I think it would make the chart more complicated.

Yes, this would not make sense. I also didn't mean it that way, i.e. using RWX across all agents. I just explained the general "use" or deployment/statefulset and their possible combinations. E.g. for Gitea itself deployment + RWX makes a lot of sense as each deployment should share the same underlying files but can still act as an independent deployment resource.

In my opinion we should either stick with the StatefulSet with a very small volume to accomodate the .runner file, or switch to Deployment without any volumes, and maybe in the future Gitea will do some garbage collection to delete inactive runners.

I agree. Given that we don't now if the GC will ever happen, let's go with a STS and a small RWO volume.

Dind: In WP the buildx plugin is used which spawns the docker engine itself in the image, so no additional sidecar/service is needed. With GA, one needs to bring the docker engine yourself. So yes, in this case a dind sidecar is needed. So it's not about pod vs. container (btw in WP currently each step is it's own distinct pod but that will likely change) but about "who brings the docker engine". An alternative might actually be podman which could be included in the base image for the runner and then wouldn't require an additional service to boot up first. But this is another topic.

Moving forward: I assume you have tested this branch already and are likely also using it since some time? I think we are not too far from a merge, though I would definitely want to have a review from @justusbunsi too. He usually sees things I don't see 😄

> I don't think that using a deployment with a RWX would work since the Gitea act runner would create a .runner file in the current working directory and as soon as another pod would start it will overwrite that file. Maybe there is a way to create a new dir for each runner and change the dir with workingDir to match the hostname, but I think it would make the chart more complicated. Yes, this would not make sense. I also didn't mean it that way, i.e. using RWX across all agents. I just explained the general "use" or deployment/statefulset and their possible combinations. E.g. for Gitea itself deployment + RWX makes a lot of sense as each deployment should share the same underlying files but can still act as an independent deployment resource. > In my opinion we should either stick with the StatefulSet with a very small volume to accomodate the .runner file, or switch to Deployment without any volumes, and maybe in the future Gitea will do some garbage collection to delete inactive runners. I agree. Given that we don't now if the GC will ever happen, let's go with a STS and a small RWO volume. Dind: In WP the `buildx` plugin is used which spawns the docker engine itself in the image, so no additional sidecar/service is needed. With GA, [one needs to bring the docker engine yourself](https://docs.gitea.com/next/usage/actions/act-runner/#requirements). So yes, in this case a `dind` sidecar is needed. So it's not about pod vs. container (btw in WP currently each step is it's own distinct pod but that will likely change) but about "who brings the docker engine". An alternative might actually be `podman` which could be included in the base image for the runner and then wouldn't require an additional service to boot up first. But this is another topic. Moving forward: I assume you have tested this branch already and are likely also using it since some time? I think we are not too far from a merge, though I would definitely want to have a review from @justusbunsi too. He usually sees things I don't see 😄
dementhorr commented 2024-02-11 15:29:21 +00:00 (Migrated from gitea.com)

I just found a setting in the Site Administration > Runners where one can edit current runners (including deleting inactive runners). I haven't found a downside to having inactive runners (just that they clutter the UI), so there is a way to delete them for estetic purposes.

I also have change the code from StatefulSet > Deployment. I can revert the commit if you prefer the StatefulSet.

I just found a setting in the `Site Administration` > `Runners` where one can edit current runners (including deleting inactive runners). I haven't found a downside to having inactive runners (just that they clutter the UI), so there is a way to delete them for estetic purposes. I also have change the code from StatefulSet > Deployment. I can revert the commit if you prefer the StatefulSet.
pat-s commented 2024-02-13 09:14:19 +00:00 (Migrated from gitea.com)

I haven't found a downside to having inactive runners (just that they clutter the UI), so there is a way to delete them for estetic purposes.

They also clutter the DB at some point. When running in HA and frequent pod movements, the number can get quite large quickly.

I also have change the code from StatefulSet > Deployment. I can revert the commit if you prefer the StatefulSet.

I think a statefulset with a small RWO volume would be my preference right now.

> I haven't found a downside to having inactive runners (just that they clutter the UI), so there is a way to delete them for estetic purposes. They also clutter the DB at some point. When running in HA and frequent pod movements, the number can get quite large quickly. > I also have change the code from StatefulSet > Deployment. I can revert the commit if you prefer the StatefulSet. I think a statefulset with a small RWO volume would be my preference right now.
pat-s commented 2024-02-15 19:47:05 +00:00 (Migrated from gitea.com)

@dementhorr Thanks so far!

Open points:

  • Review comments

  • README documentation

  • Review from Justus

@dementhorr Did you already test this on a cluster of yours?

I think it would also be good if we would store a dev-focused tech-documentation alongside the templates, i.e. how all components play together, especially all the jobs and scripts.

@dementhorr Thanks so far! Open points: - [ ] Review comments - [ ] README documentation - [ ] Review from Justus @dementhorr Did you already test this on a cluster of yours? I think it would also be good if we would store a dev-focused tech-documentation alongside the templates, i.e. how all components play together, especially all the jobs and scripts.
CaptainMayotoast commented 2024-02-22 13:09:00 +00:00 (Migrated from gitea.com)

Hello! I am interested in testing this Actions runners addition and would be happy to share/help solve bugs that may crop up. Thanks to @dementhorr and @pat-s for your contributions to this feature - deploying runners easily and in an automated fashion would be great!

Hello! I am interested in testing this Actions runners addition and would be happy to share/help solve bugs that may crop up. Thanks to @dementhorr and @pat-s for your contributions to this feature - deploying runners easily and in an automated fashion would be great!
dementhorr commented 2024-02-23 18:56:13 +00:00 (Migrated from gitea.com)

I have added documentation for the Job. I don't know exactly where to place it.
I have tested the chart on my cluster and it works fine.

I have added documentation for the Job. I don't know exactly where to place it. I have tested the chart on my cluster and it works fine.
pat-s commented 2024-03-03 20:56:14 +00:00 (Migrated from gitea.com)

@dementhorr Great, thanks for the feedback! I'll try to finish everything up in the next weeks. The plan is to include it into the release which ships v1.22 (1.22 is currently in feature freeze).

Given that it is disabled by default, we can see which issues occur and fix them in subsequent releases.

@justusbunsi Your review is still welcome. If you can't make it in time, we can also address your comments post-merge. Given the amount of work and discussion that went into this already, I think it would be good to release this to users with the next version.

@dementhorr Great, thanks for the feedback! I'll try to finish everything up in the next weeks. The plan is to include it into the release which ships v1.22 (1.22 is currently in feature freeze). Given that it is disabled by default, we can see which issues occur and fix them in subsequent releases. @justusbunsi Your review is still welcome. If you can't make it in time, we can also address your comments post-merge. Given the amount of work and discussion that went into this already, I think it would be good to release this to users with the next version.
justusbunsi commented 2024-03-04 15:55:53 +00:00 (Migrated from gitea.com)

Apologies for not responding earlier. Even with being pinged twice. I am not sure if I have enough time until Friday but would love to give my review the upcoming weekend. Afaik this should still be within the feature freeze time slot of Gitea 1.22. Does this work for everyone?

Apologies for not responding earlier. Even with being pinged twice. I am not sure if I have enough time until Friday but would love to give my review the upcoming weekend. Afaik this should still be within the feature freeze time slot of Gitea 1.22. Does this work for everyone?
justusbunsi (Migrated from gitea.com) reviewed 2024-03-10 15:35:38 +00:00
justusbunsi (Migrated from gitea.com) left a comment

Hi everyone. First of all, thank you @dementhorr for contributing to this Chart in general, and to propose Gitea Actions in particular. 👍 I appreciate every minute you already have put into it. And @pat-s for reviewing so far.

Its much more complex than first thought, so I'll split my review into 2 parts:

  • chart user perspective (this very review below)
  • technical perspective (will follow in the next days)
Hi everyone. First of all, thank you @dementhorr for contributing to this Chart in general, and to propose Gitea Actions in particular. 👍 I appreciate every minute you already have put into it. And @pat-s for reviewing so far. Its much more complex than first thought, so I'll split my review into 2 parts: - `chart user perspective` (this very review below) - `technical perspective` (will follow in the next days)
@ -1024,3 +981,3 @@
| `signing.privateKey` | Inline private gpg key for signed internal Git activity | `""` |
| `signing.privateKey` | Inline private gpg key for signed Gitea actions | `""` |
| `signing.existingSecret` | Use an existing secret to store the value of `signing.privateKey` | `""` |
justusbunsi (Migrated from gitea.com) commented 2024-03-10 15:35:38 +00:00

This section misses a Table-of-content reference at the top of this file.

This section misses a Table-of-content reference at the top of this file.
@ -3,4 +3,3 @@
In order to use the Gitea Actions act-runner you must either:
- enable persistence (used for automatic deployment to be able to store the token in a place accessible for the Job)
- create a secret containing the act runner token and reference it as a `existingSecret`
justusbunsi (Migrated from gitea.com) commented 2024-03-10 17:24:03 +00:00
Obsolete documentation when considering https://gitea.com/gitea/helm-chart/pulls/596/files#issuecomment-811808
justusbunsi (Migrated from gitea.com) commented 2024-03-10 17:23:56 +00:00
Obsolete documentation when considering https://gitea.com/gitea/helm-chart/pulls/596/files#issuecomment-811808
justusbunsi (Migrated from gitea.com) commented 2024-03-10 15:52:25 +00:00

Let's move the default config.yaml definition into values.yaml. That way it should be more obvious what content it should contain. And we eliminate the if-else here. 🙂

Let's move the default config.yaml definition into `values.yaml`. That way it should be more obvious what content it should contain. And we eliminate the if-else here. 🙂
@ -58,3 +57,3 @@
value: {{ include "gitea.act_runner.local_root_url" . }}
value: "http://{{ include "gitea.fullname" . }}-http:{{ .Values.service.http.port }}"
- name: CONFIG_FILE
value: /actrunner/config.yaml
justusbunsi (Migrated from gitea.com) commented 2024-03-10 16:16:35 +00:00

Let's move the default value into values.yaml. Eliminates the default usage here. 🙂

As an alternative thought: I've noticed that when running act_runner generate-config, you'll get a yaml structure where you can define a list of labels for the runner via runner.labels. Was there a reason for providing the labels as environment variable instead through the config.yaml? If not - and given the fact that it works - I suggest to move ubuntu-latest into the config.yaml and drop this environment variable and its values.yaml spec entirely.

Let's move the default value into `values.yaml`. Eliminates the default usage here. 🙂 As an alternative thought: I've noticed that when running `act_runner generate-config`, you'll get a yaml structure where you can define a list of labels for the runner via `runner.labels`. Was there a reason for providing the labels as environment variable instead through the config.yaml? If not - and given the fact that it works - I suggest to move `ubuntu-latest` into the config.yaml and drop this environment variable and its values.yaml spec entirely.
@ -83,4 +80,3 @@
{{- end }}
securityContext:
privileged: true
resources:
justusbunsi (Migrated from gitea.com) commented 2024-03-10 16:43:52 +00:00

Is this comment a left-over from testing?

Is this comment a left-over from testing?
justusbunsi (Migrated from gitea.com) commented 2024-03-19 15:43:06 +00:00

yes

yes
@ -353,8 +336,6 @@ signing:
## @section Gitea Actions
justusbunsi (Migrated from gitea.com) commented 2024-03-10 17:23:10 +00:00

As mentioned for GITEA__ACTIONS__ENABLED in https://gitea.com/gitea/helm-chart/pulls/596/files#issuecomment-811807, these preconditions should be part of the templating logic.

  • Applying the chart must throw an error when actions.enabled: true and at the same time persistence.enabled: false.
  • Isn't GITEA__SERVER__LOCAL_ROOT_URL what is also dynamically built in templates/gitea/act_runner/statefulset.yaml for GITEA_INSTANCE_URL? We can define that environment variable for the user via helpers.tpl, too.
As mentioned for `GITEA__ACTIONS__ENABLED` in https://gitea.com/gitea/helm-chart/pulls/596/files#issuecomment-811807, these preconditions should be part of the templating logic. - Applying the chart must throw an error when `actions.enabled: true` and at the same time `persistence.enabled: false`. - Isn't `GITEA__SERVER__LOCAL_ROOT_URL` what is also dynamically built in `templates/gitea/act_runner/statefulset.yaml` for `GITEA_INSTANCE_URL`? We can define that environment variable for the user via [helpers.tpl](https://gitea.com/gitea/helm-chart/src/branch/main/templates/_helpers.tpl#L260), too.
justusbunsi (Migrated from gitea.com) commented 2024-03-19 15:48:10 +00:00

The chart must throw an error when actions.provisioning.enabled: true and persistence.enabled: false. Otherwise actions.enabled: true with persistence.enabled: false is valid if actions.existingSecret and actions.existingSecretKey is defined. I have modified the readme-actions-dev.md file.

I wasn't able to modify the GITEA_INSTANCE_URL using the .Values.gitea.config.actions variable from _helpers.tpl.

The chart must throw an error when `actions.provisioning.enabled: true` and `persistence.enabled: false`. Otherwise `actions.enabled: true` with `persistence.enabled: false` is valid if `actions.existingSecret` and `actions.existingSecretKey` is defined. I have modified the `readme-actions-dev.md` file. I wasn't able to modify the `GITEA_INSTANCE_URL` using the `.Values.gitea.config.actions` variable from `_helpers.tpl`.
justusbunsi (Migrated from gitea.com) commented 2024-03-19 17:08:33 +00:00

My initial comment was misleading - just realized that now. I didn't mean we should set GITEA_INSTANCE_URL via _helpers.tpl. This value is not known to the app.ini. But GITEA__SERVER__LOCAL_ROOT_URL is. And since the value for both environment variables are identical, there is no technical reason to define one but let the user define the other. 🙂
Sorry for that confusion.

My initial comment was misleading - just realized that now. I didn't mean we should set `GITEA_INSTANCE_URL` via `_helpers.tpl`. This value is not known to the `app.ini`. But `GITEA__SERVER__LOCAL_ROOT_URL` is. And since the value for both environment variables are identical, there is no technical reason to define one but let the user define the other. 🙂 Sorry for that confusion.
justusbunsi (Migrated from gitea.com) commented 2024-03-10 15:56:02 +00:00

Suggestion:

- ## @param actions.statefulset.config Act runner custom configuration.
+ ## @param actions.statefulset.config Act runner custom configuration. See [Act Runner documentation](https://docs.gitea.com/usage/actions/act-runner#configuration) for details.

Or, combined with https://gitea.com/gitea/helm-chart/pulls/596/files#issuecomment-811801 (to prevent broken README generation 😆):

- ## @param actions.statefulset.config Act runner custom configuration.
+ ## @param actions.statefulset.config [default: Too complex. See values.yaml] Act runner custom configuration. See [Act Runner documentation](https://docs.gitea.com/usage/actions/act-runner#configuration) for details.
Suggestion: ```diff - ## @param actions.statefulset.config Act runner custom configuration. + ## @param actions.statefulset.config Act runner custom configuration. See [Act Runner documentation](https://docs.gitea.com/usage/actions/act-runner#configuration) for details. ``` Or, combined with https://gitea.com/gitea/helm-chart/pulls/596/files#issuecomment-811801 (to prevent broken README generation 😆): ```diff - ## @param actions.statefulset.config Act runner custom configuration. + ## @param actions.statefulset.config [default: Too complex. See values.yaml] Act runner custom configuration. See [Act Runner documentation](https://docs.gitea.com/usage/actions/act-runner#configuration) for details. ```
justusbunsi (Migrated from gitea.com) commented 2024-03-10 16:02:41 +00:00

Suggestion:

- ## @param actions.statefulset.runnerLabels Act runner labels.
+ ## @param actions.statefulset.runnerLabels Act runner labels. See [Act Runner documentation](https://docs.gitea.com/usage/actions/act-runner#labels) for details.
Suggestion: ```diff - ## @param actions.statefulset.runnerLabels Act runner labels. + ## @param actions.statefulset.runnerLabels Act runner labels. See [Act Runner documentation](https://docs.gitea.com/usage/actions/act-runner#labels) for details. ```
justusbunsi (Migrated from gitea.com) commented 2024-03-10 17:05:51 +00:00

The current approach of only documenting what a chart user has to do manually is not ideal. Setting actions.enabled: true should automatically configure the instance to have enable Gitea Actions. Means, it should either define gitea.config.actions.enabled as provided inline values while templating, or inject the environment variable GITEA__ACTIONS__ENABLED=true to the app.ini processing.

To keep the amount of injected envs as low as possible, I would prefer we do it via inline values. There already is a method for that in helpers.tpl defining other default values. Here, we also can detect conflicting configurations (e.g. actions.enabled: true and user-defined inline gitea.config.actions.enabled: false) and fail the templating process with an appropriate error message.

Making that part of the chart logic reduces usage errors.

The current approach of only documenting what a chart user has to do manually is not ideal. Setting `actions.enabled: true` should automatically configure the instance to have enable _Gitea Actions_. Means, it should either define `gitea.config.actions.enabled` as provided inline values while templating, or inject the environment variable `GITEA__ACTIONS__ENABLED=true` to the app.ini processing. To keep the amount of injected envs as low as possible, I would prefer we do it via inline values. There already is a method for that in [helpers.tpl](https://gitea.com/gitea/helm-chart/src/branch/main/templates/_helpers.tpl#L260) defining other default values. Here, we also can detect conflicting configurations (e.g. `actions.enabled: true` and user-defined inline `gitea.config.actions.enabled: false`) and fail the templating process with an appropriate error message. Making that part of the chart logic reduces usage errors.
@ -396,3 +378,3 @@
repository: gitea/act_runner
tag: 0.2.11
tag: 0.2.6
pullPolicy: IfNotPresent
justusbunsi (Migrated from gitea.com) commented 2024-03-10 16:40:04 +00:00

Since config and runnerLabels are only used within the actRunner container, we should move those values settings into actions.statefulset.actRunner to make that clear. It also gives a better understanding for administrators.

Since `config` and `runnerLabels` are only used within the `actRunner` container, we should move those values settings into `actions.statefulset.actRunner` to make that clear. It also gives a better understanding for administrators.
@ -410,17 +392,6 @@ actions:
repository: docker
tag: 25.0.2-dind
justusbunsi (Migrated from gitea.com) commented 2024-03-10 17:40:54 +00:00

Since job.enabled: true basically means to automatically connect the runner to Gitea, I suggest renaming the object from job to provisioning or autoConnect. That makes it easier for users to understand its purpose. The fact its a Kubernetes Job is not important for users.

Since `job.enabled: true` basically means to automatically connect the runner to Gitea, I suggest renaming the object from `job` to `provisioning` or `autoConnect`. That makes it easier for users to understand its purpose. The fact its a Kubernetes Job is not important for users.
justusbunsi (Migrated from gitea.com) reviewed 2024-03-19 17:15:52 +00:00
@ -347,3 +347,2 @@
{{- end -}}
{{- if not .Values.gitea.config.actions.ENABLED -}}
{{- $_ := set .Values.gitea.config.actions "ENABLED" (ternary "true" "false" .Values.actions.enabled) -}}
{{- if not .Values.gitea.config.actions.GITEA__ACTIONS__ENABLED -}}
justusbunsi (Migrated from gitea.com) commented 2024-03-19 17:15:52 +00:00

The whole actions related app.ini block is rendered when running helm template my-release ., although it is disabled by default. Looks like this check is missing. And a test that covers this.

The whole actions related `app.ini` block is rendered when running `helm template my-release .`, although it is disabled by default. Looks like this check is missing. And a test that covers this.
vjm commented 2024-04-30 14:14:19 +00:00 (Migrated from gitea.com)

Any help needed on this? I’d be happy to contribute

Any help needed on this? I’d be happy to contribute
pat-s commented 2024-05-02 08:27:51 +00:00 (Migrated from gitea.com)

We haven't heard from @dementhorr for two months now. A lot of time was already put in. The current state is a bit unclear.

@vjm If you want to continue, maybe use a separate PR based on this one to continue. This would allow @dementhorr to eventually continue here.

We haven't heard from @dementhorr for two months now. A lot of time was already put in. The current state is a bit unclear. @vjm If you want to continue, maybe use a separate PR based on this one to continue. This would allow @dementhorr to eventually continue here.
ogdabou commented 2024-05-15 10:42:45 +00:00 (Migrated from gitea.com)

Hey 👋

What requirements are left to be achieved in order to merge it ?

From the comments I can see:

  • Renovate for busybox / publish image
  • Do not generate _helpers part related to actions when actions.enabled: false. @justusbunsi you seem to have suggested to test that, right ? I'm not familiar with unittest, does it means testing the helpers.yaml file output ?
  • Clean decommissioned runners. I don't see any API endpoint to do so, how could it be achieved ?
    If it cannot, it is required to ship this chart ?
  • Rebase with main

Is moving from statefulset to deployments a requirement ?

Hey 👋 What requirements are left to be achieved in order to merge it ? From the comments I can see: - [ ] Renovate for busybox / publish image - [ ] Do not generate _helpers part related to `actions` when `actions.enabled: false`. @justusbunsi you seem to have suggested to test that, right ? I'm not familiar with `unittest`, does it means testing the `helpers.yaml` file output ? - [ ] Clean decommissioned runners. I don't see any API endpoint to do so, how could it be achieved ? If it cannot, it is required to ship this chart ? - [ ] Rebase with main Is moving from statefulset to deployments a requirement ?
vjm commented 2024-06-11 16:27:59 +00:00 (Migrated from gitea.com)

@pat-s , @justusbunsi -- I have rebased in #666 based on this pull request. Happy to make changes if they are needed, but are we good to merge #666 in current state and make revisions as needed?

@pat-s , @justusbunsi -- I have rebased in #666 based on this pull request. Happy to make changes if they are needed, but are we good to merge #666 in current state and make revisions as needed?
pat-s commented 2024-07-13 12:10:05 +00:00 (Migrated from gitea.com)

Closed in favor of #666

Closed in favor of #666

Pull request closed

Sign in to join this conversation.
No description provided.