Kubernetes Runner 구성 가이드
이번 kubernetes Runner 설정 가이드를 보기 전에 Runner 구성과 GitLab Runner 로컬 설치 구성 가이드를 읽어 보시기 바랍니다.
사전조건
- 클러스터로부터 GitLab 서버의 API 호출이 가능해야 합니다.
- Beta API 가능한 1.4 버전 이상의 Kubernetes를 사용해야 합니다.
kubectl
CLI가 로컬에 설치되어 있고 클러스터에 인증되어 있어야 합니다.- Helm CLI가 PC에 설치되어 있어야 합니다.
사전준비 - (번외) Kubernetes 설정
특정 Namespace에 Runner를 사용하기 위해서는 몇 가지 설정이 필요합니다.
1. CSP(Cloud Solution Provider) 환경에 로그인
특정 Kubernetes의 Namespace 및 Service Account 생성 권한이 있는 계정으로 로그인해야 합니다
- Azure (참고)
az login
az aks get-credentials --resource-group myResourceGroup --name myAKSCluster
- AWS
aws configure (참고)
aws configure
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-west-2
Default output format [None]: json
eks에 연결(참고)
aws eks --region <region> update-kubeconfig --name <cluster_name>
- GCloud (참고)
gcloud auth login
gcloud config set compute/zone <compute-zone>
gcloud container clusters get-credentials <cluster-name>
2. Namespace 생성
- Namespace의 경우 그룹이나 팀, 혹은 파트별로 구성
- 예시: group-a, group-b, team-a, team-b, part-a, part-b, dep-a, dep-b
- 아래 명령어를 실행하여
hello-world
라는 Namespace를 생성
kubectl create namespace hello-world
- 생성된 Namespace 확인
kubectl get namespaces
- 생성된 Namespace로 이동(kubens가 설치되지 않았을 때 get 명령어에 -n 옵션으로 네임스페이스를 지정하면 됩니다)
kubens hello-world
3. Service Account 생성
- Namespace를 관리할 Service Account 생성하여 관리
- 예시: sa-group-a, sa-group-b, sa-team-a, sa-team-b
- 아래 명령어를 실행하여
hello-sa
라는 이름의 Service Account 생성- namespace를 지정(예시는 hello-world namespace를 연결)
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ServiceAccount
metadata:
name: hello-sa
namespace: hello-world
EOF
- Service Account 정보 확인
kubectl get serviceaccounts hello-sa -o yaml