YJWANG

[kubernetes] gitlab-ce 설치 본문

60.Cloud/80.Kubernetes

[kubernetes] gitlab-ce 설치

왕영주 2021. 1. 27. 15:12

refer to


구성


storage provisioner가 구축된 상태가 전제이다.
내용을 모르겠다면 아래 포스팅을 참고하여 provisioner를 구축하고 진행해야한다.

https://yjwang.tistory.com/entry/Jenkins-on-Kubernetes-NFS-Dynamic-PV

manifest

 

volume 매핑은 위 참고 사이트에서보고 작성했다.

Local locationContainer locationUsage

$GITLAB_HOME/data /var/opt/gitlab For storing application data.
$GITLAB_HOME/logs /var/log/gitlab For storing logs.
$GITLAB_HOME/config /etc/gitlab For storing the GitLab configuration files.
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gitlab-data
  namespace: default
spec:
  storageClassName: jenkins-nfs
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gitlab-config
  namespace: default
spec:
  storageClassName: jenkins-nfs
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10Gi
---      
apiVersion: apps/v1
kind: Deployment
metadata:
  name: gitlab
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: gitlab
  template:
    metadata:
      labels:
        app: gitlab
    spec:
      containers:
      - image: gitlab/gitlab-ce
        name: gitlab
        ports:
        - containerPort: 80
        - containerPort: 443
        - containerPort: 22
        volumeMounts:
          - mountPath: /etc/gitlab
            name: gitlab-config-volume
          - mountPath: /var/opt/gitlab
            name: gitlab-data-volume
      volumes:
        - name: gitlab-config-volume
          persistentVolumeClaim:
            claimName: gitlab-config
        - name: gitlab-data-volume
          persistentVolumeClaim:
            claimName: gitlab-data
---
apiVersion: v1
kind: Service
metadata:
  name: gitlab-service
  namespace: default
spec:
  type: NodePort
  ports:
  - port: 80
    targetPort: 80
    protocol: TCP
    name: http
  - port: 443
    targetPort: 443
    protocol: TCP
    name: httpd
  - port: 22
    targetPort: 22
    protocol: TCP
    name: ssh 
  selector:
    app: gitlab

확인

[root@master01 gitlab]# kubectl apply -f gitlab.yaml 
persistentvolumeclaim/gitlab-data created
persistentvolumeclaim/gitlab-config created
deployment.apps/gitlab created
service/gitlab-service created

[root@master01 gitlab]# kubectl get pvc
NAME             STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
gitlab-config    Bound    pvc-39ec7735-095b-49fc-a02b-249711974951   10Gi       RWX            jenkins-nfs    5s
gitlab-data      Bound    pvc-203b0c57-0875-4aba-947a-99ec3c09f1d1   10Gi       RWX            jenkins-nfs    5s

[root@master01 k8s]# kubectl get svc gitlab-service 
NAME             TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)                                   AGE
gitlab-service   NodePort   10.233.53.186   <none>        80:30315/TCP,443:32722/TCP,22:31205/TCP   9m55s

이후 접속했을 때 에러가 발생한다면 external url에 대해 gitlab쪽에 설정을 해야하는데 하지 않아서 발생하는 것이다.
provisioner의 data directory로 접속해서 gitlab.rb파일을 수정해준다.

[root@master01 default-gitlab-config-pvc-39ec7735-095b-49fc-a02b-249711974951]# vim gitlab.rb
[root@master01 default-gitlab-config-pvc-39ec7735-095b-49fc-a02b-249711974951]# pwd
/data/default-gitlab-config-pvc-39ec7735-095b-49fc-a02b-249711974951

# external_url 'GENERATED_EXTERNAL_URL'
external_url 'xxx.xxx.xxx.xxx:30315'

이후 재접속

 

반응형