Skip to content

Commit

Permalink
Enable arc garbage collector
Browse files Browse the repository at this point in the history
  • Loading branch information
electrocucaracha committed Jan 9, 2025
1 parent 768879b commit ace1073
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions _chart_installers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ function _install_chart_k8sgpt-operator {

function _install_arc_controller {
KRD_CHART_VERSION=$(_get_version action_runner_controller) _install_chart arc oci://ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-set-controller
kubectl apply -f resources/arc-cleanup.yml
}

# install_arc() - Install Actions Runner
Expand Down
61 changes: 61 additions & 0 deletions resources/arc-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2025
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
apiVersion: v1
kind: ServiceAccount
metadata:
name: cleaner
namespace: arc-system
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: cleaner
rules:
- apiGroups: ["actions.github.com"]
resources: ["ephemeralrunners"]
verbs: ["delete", "get", "watch", "list"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: cleaner-to-cleaner
roleRef:
kind: ClusterRole
name: cleaner
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
name: cleaner
namespace: arc-system
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: cleanup-pipelineruns
namespace: arc-system
spec:
schedule: "*/15 * * * *"
concurrencyPolicy: Forbid
failedJobsHistoryLimit: 1
successfulJobsHistoryLimit: 3
jobTemplate:
spec:
template:
spec:
restartPolicy: OnFailure
serviceAccount: cleaner
containers:
- name: kubectl
image: alpine/k8s:1.32.0
command:
- /bin/bash
- -c
- |
kubectl get -A ephemeralrunner -o jsonpath='{range .items[?(@.status.reason=="TooManyPodFailures")]}{.metadata.namespace}{" "}{.metadata.name}{"\n"}{end}'|awk '{ print "kubectl delete ephemeralrunner" " -n " $1 " " $2 }'|xargs -P4 -I{} sh -c "{}"

0 comments on commit ace1073

Please sign in to comment.