ecsimsw / daily-notes

val contents = myDailyNotes.filter { it.isPublic }
5 stars 0 forks source link

ARC/k8s로 Github actions self hosted runners 관리하기, 오토스케일링 #7

Closed ecsimsw closed 1 year ago

ecsimsw commented 1 year ago

ref, https://github.com/actions/actions-runner-controller quick start, https://github.com/actions/actions-runner-controller/blob/master/docs/quickstart.md hpa, https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/autoscaling-with-self-hosted-runners

ecsimsw commented 1 year ago

install github actions runner controller

ref, https://github.com/actions/actions-runner-controller/blob/master/docs/quickstart.md

Install cert-manager

kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.8.2/cert-manager.yaml

Install arc with helm

helm repo add actions-runner-controller https://actions-runner-controller.github.io/actions-runner-controller
helm upgrade --install --namespace actions-runner-system --create-namespace\
  --set=authSecret.create=true\
  --set=authSecret.github_token=${GITHUB_PAT_TOKEN}\
  --wait actions-runner-controller actions-runner-controller/actions-runner-controller

Define runnerDeployment for specific repo

apiVersion: actions.summerwind.dev/v1alpha1
kind: RunnerDeployment
metadata:
  name: example-runnerdeploy
spec:
  replicas: 1
  template:
    spec:
      repository: ${USER_NAME}/${REPO_NAME}
      labels:
        - ${MY_LABEL}

HPA

ref, https://github.com/actions/actions-runner-controller/blob/master/docs/automatically-scaling-runners.md

apiVersion: actions.summerwind.dev/v1alpha1
kind: HorizontalRunnerAutoscaler
metadata:
  name: github-ations-runner-hpa
  namespace: actions-runner-system
spec:
  scaleDownDelaySecondsAfterScaleOut: 300
  scaleTargetRef:
    kind: RunnerDeployment
    name: ${RunnerDeployment_NAME}
  minReplicas: 1
  maxReplicas: 5
  metrics:
    - type: PercentageRunnersBusy
      scaleUpThreshold: '0.75'     # The percentage of busy runners at which the number of desired runners are re-evaluated to scale up
      scaleDownThreshold: '0.25'   #  The percentage of busy runners at which the number of desired runners are re-evaluated to scale down
      scaleUpFactor: '2'           # The scale up multiplier factor applied to desired count
      scaleDownFactor: '0.5'       # The scale down multiplier factor applied to desired count
ecsimsw commented 3 months ago

IMG_8743