GitLab:Kubernetes
GitLab에 k8s 연동 방법, k8s에 gitlab 설치하기 등 ...
k8s에 gitlab 설치하기
gitlab에 k8s 사용하여 CI/CD 환경 구축
- k8s + GitLab으로 CI/CD환경 구축해보기 - 호롤리한 하루
- 깃랩(Gitlab) CI/CD 튜토리얼
- 한성이 DevOps 블로그 - Kubernetes & Gitlab Runner 연동 (.gitlab-ci.yml 스크립트)
- Kube-apiserver
입력 항목은 다음과 같이 채워라
- Kubernetes cluster name: 아무 이름이나 적어라
- Environment scope:
*
- API URL:
https://{Master
node ip}:6443
(HTTPS 가 맞다!!) - CA Certificate: 마스터 노드에서 다음 명령으로 확인할 수 있다.
*
kubectl config view --raw \ -o=jsonpath='{.clusters[0].cluster.certificate-authority-data}' \ | base64 --decode
</syntaxhighlight>
- Service Token: 서비스 토큰을 얻기 전에, 깃랩에서 사용할 서비스 어카운트를 생성해 주어야 합니다.
- A service token scoped to kube-system with cluster-admin privileges. More information
*
- gitlab-admin.yaml
apiVersion: v1 kind: ServiceAccount metadata:
name: gitlab-admin
namespace: kube-system
--- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata:
name: gitlab-admin
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects: - kind: ServiceAccount
name: gitlab-admin
namespace: kube-system
</syntaxhighlight>
-
- 저장 후 다음과 같이 실행한다:
$ kubectl apply -f gitlab-admin.yaml serviceaccount/gitlab-admin unchanged clusterrolebinding.rbac.authorization.k8s.io/gitlab-admin created
</syntaxhighlight>
문제점
- Configure Service Accounts for Pods | Kubernetes # Manually create an API token for a ServiceAccount
토큰이 얻어지지 않는다.
Troubleshooting
no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1"
kubectl apply -f gitlab-admin.yaml
했을 때 다음과 같은 에러가 출력 된다면:
serviceaccount/gitlab-admin created
error: resource mapping not found for name: "gitlab-admin" namespace: "" from "gitlab-admin.yaml": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1"
ensure CRDs are installed first
ClusterRoleBinding 의 apiVersion
을 rbac.authorization.k8s.io/v1beta
로 했다면, rbac.authorization.k8s.io/v1
로 변경해야 정상적으로 작동한다.