diff --git a/insight-runners/run b/insight-runners/run new file mode 100644 index 0000000..7579371 --- /dev/null +++ b/insight-runners/run @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +# echo 'export KUBECONFIG=/etc/rancher/k3s/k3s.yaml' >> ~/.bashrc && source ~/.bashrc + +case "$1" in + install) + curl -sfL https://get.k3s.io | sh - + export KUBECONFIG=/etc/rancher/k3s/k3s.yaml && sudo chmod 644 /etc/rancher/k3s/k3s.yaml + ;; + start) + kubectl apply -f k8s/ + ;; + delete) + kubectl delete -f k8s/ + kubectl delete pvc -l app=github-runner + ;; + status) + kubectl get pods -l app=github-runner + ;; + logs) + kubectl logs "${2:-github-runner-0}" -f + ;; + restart) + kubectl rollout restart statefulset github-runner + ;; + scale) + kubectl scale statefulset github-runner --replicas="$2" + ;; + *) + echo "Usage: $0 {start|delete|status|logs|restart|scale}" + exit 1 +esac diff --git a/insight-runners/src/runner-secret.yaml b/insight-runners/src/runner-secret.yaml new file mode 100644 index 0000000..88e4b65 --- /dev/null +++ b/insight-runners/src/runner-secret.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: Secret +metadata: + name: github-runner-secret +type: Opaque +stringData: + access-token: "your_access_token" diff --git a/insight-runners/src/runner-statefulset.yaml b/insight-runners/src/runner-statefulset.yaml new file mode 100644 index 0000000..0889d01 --- /dev/null +++ b/insight-runners/src/runner-statefulset.yaml @@ -0,0 +1,67 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: github-runner +spec: + serviceName: github-runner + replicas: 7 + selector: + matchLabels: + app: github-runner + template: + metadata: + labels: + app: github-runner + spec: + containers: + - name: runner + image: myoung34/github-runner:latest + env: + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: REPO_URL + value: "your_repo" + - name: RUNNER_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: ACCESS_TOKEN + valueFrom: + secretKeyRef: + name: github-runner-secret + key: access-token + - name: RUNNER_WORKDIR + value: "/tmp/runner/work" + - name: CONFIGURED_ACTIONS_RUNNER_FILES_DIR + value: "/runner/data" + - name: RUNNER_SCOPE + value: "repo" + - name: DISABLE_AUTOMATIC_DEREGISTRATION + value: "true" + - name: LABELS + value: "linux,x64,gpu,$(POD_NAME)" + securityContext: + privileged: true + volumeMounts: + - name: runner-data + mountPath: /runner/data + - name: docker-sock + mountPath: /var/run/docker.sock + - name: tmp-runner + mountPath: /tmp/runner + volumes: + - name: docker-sock + hostPath: + path: /var/run/docker.sock + - name: tmp-runner + emptyDir: {} + volumeClaimTemplates: + - metadata: + name: runner-data + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 5Gi