Github Action
Github Action 관련
ARC 설정
"Action Runner Controller (ARC)"
GitHub Actions를 사용하다 보면, 여러 이유로 GitHub Hosted Runner만으로는 부족한 경우가 있습니다. 이때, Self Hosted Runner를 사용하면 더 많은 제어권을 가질 수 있습니다.
Prerequesite(s)
- Kubernetes (
v1.3x) - Helm
- Github 계정
cert-manager 설치
GitHub PAT (Personal Access Token) 생성
Warning
개인 계정으로 생성한 토큰을 사용하면, 퇴사자 발생 시 Runner가 통째로 동작하지 않을수 있습니다.
관리용 계정을 생성해서 사용하시는 것을 추천드립니다.
Settings > Developer Settings > Tokens (classic)에 가서 Create new Token 을 클릭하여 토큰을 생성합니다.
Helm 배포
NAMESPACE="arc-systems";
GH_REPO="https://github.com/<저장소경로>";
GH_PAT="<Github Personal Accsss Token>";
NUM_REPLICA=4;
# (arc-runner-set 설치 전) PAT 구성
kubectl delete secret pre-defined-secret \
--namespace=${NAMESPACE} \
--ignore-not-found;
kubectl create secret generic pre-defined-secret \
--namespace=${NAMESPACE} \
--from-literal=github_token="${GH_PAT}";
# values.xml
FILENAME_VALUES="${HOME}/values.yaml"
cat << 'FILE_VALUES_EOF' > "$FILENAME_VALUES"
githubConfigUrl: VV_GH_REPO
scaleSetLabels: ["arc-runner-set"]
# githubConfigSecret
# github_token: ""
githubConfigSecret: pre-defined-secret
minRunners: 1
maxRunners: VV_NUM_REPLICA
listenerConfig:
scaler:
qps: 50
burst: 100
template:
spec:
containers:
- name: runner
image: ghcr.io/actions/actions-runner:latest
command: ["/home/runner/run.sh"]
namespaceOverride: ""
FILE_VALUES_EOF
sed -i "s@VV_GH_REPO@$GH_REPO@g" $FILENAME_VALUES
sed -i "s@VV_NUM_REPLICA@$NUM_REPLICA@g" $FILENAME_VALUES
# arc 설치
helm upgrade --install "arc" \
oci://ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-set-controller \
--namespace "${NAMESPACE}" --create-namespace;
# arc-runner-set 설치
helm upgrade --install "arc-runner-set" \
oci://ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-set \
--namespace "${NAMESPACE}" --create-namespace \
--values ${FILENAME_VALUES};
rm -f $FILENAME_VALUES;
Troubleshooting
Node의 Taint 설정 해제
<N> node(s) had taints that the pod didn't tolerate.
kubectl get pods -n arc-systems
#
# NAME READY STATUS RESTARTS AGE
# arc-gha-rs-controller-7c8d7688f5-b97zn 0/1 Pending 0 99s
Pod 상태가 계속 Pending일 경우
kubectl describe pod arc-gha-rs-controller-7c8d7688f5-b97zn -n arc-systems
#
# Name: arc-gha-rs-controller-7c8d7688f5-b97zn
# Namespace: arc-systems
# .
# ... 생략
# Events:
#
# Type Reason Age From Message
# ---- ------ ---- ---- ------- #
# Warning FailedScheduling 94s default-scheduler 0/1 nodes are available: 1 node(s) had untolerated taint {node-role.kubernetes.io/control-plane: }. preemption: 0/1 nodes are available: 1 Preemption is not helpful for scheduling.
이유
Contrl-Plane Node에 Pod를 못 올리도록 설정되어 있기 때문
kubectl get nodes
#
# NAME STATUS ROLES AGE VERSION
# k8s-gh-runner Ready control-plane 4m41s v1.30.14
kubectl describe node k8s-gh-runner | grep Taint
#
# Taints: node-role.kubernetes.io/control-plane:NoSchedule
# Taint 설정 해제
kubectl taint nodes k8s-gh-runner node-role.kubernetes.io/control-plane-
#
# 다시 Taint 상태 복구
kubectl taint nodes k8s-gh-runner node-role.kubernetes.io/control-plane:NoSchedule
참고
# .bash_profile
export KUBECONFIG=/etc/kubernetes/admin.conf
export NAMESPACE="arc-systems"
PATH_ARC="${HOME}/${NAMESPACE}"
FILENAME_VALUES="${PATH_ARC}/values.yaml"
GH_REPO=
GH_PAT=
NUM_REPLICA=4
function values() {
echo "Set impoortant values for k8s arc to work.";
mkdir -p $PATH_ARC;
if [ -n "$1" ]; then
GH_PAT="$1"
echo "Set Github PAT value!";
fi
kubectl delete secret pre-defined-secret \
--namespace=${NAMESPACE} \
--ignore-not-found;
kubectl create secret generic pre-defined-secret \
--namespace=${NAMESPACE} \
--from-literal=github_token="${GH_PAT}";
echo "GH_PAT: $GH_PAT";
cat << 'FILE_VALUES_EOF' > "$FILENAME_VALUES"
githubConfigUrl: VV_GH_REPO
scaleSetLabels: ["arc-runner-set"]
githubConfigSecret: pre-defined-secret
minRunners: 1
maxRunners: VV_NUM_REPLICA
listenerConfig:
scaler:
qps: 50
burst: 100
template:
spec:
containers:
- name: runner
image: ghcr.io/actions/actions-runner:latest
command: ["/home/runner/run.sh"]
namespaceOverride: ""
FILE_VALUES_EOF
sed -i "s@VV_GH_REPO@$GH_REPO@g" $FILENAME_VALUES
sed -i "s@VV_NUM_REPLICA@$NUM_REPLICA@g" $FILENAME_VALUES
}
function darc() {
helm upgrade --install "arc" \
oci://ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-set-controller \
--namespace "${NAMESPACE}" --create-namespace;
}
function dars() {
helm upgrade --install "arc-runner-set" \
oci://ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-set \
--namespace "${NAMESPACE}" --create-namespace \
--values "${FILENAME_VALUES}";
}