k8s

gitlab k8s 설치 및 비밀번호 설정

초이짬 2023. 4. 14. 17:33
728x90

k8s에 설치되는 에코시스들의 경우 초기 마스터 비밀번호 설정이 다 제각각이다.....ㅡ,.ㅡㅋ

 

gitlab의 경우는 gitlab-rails 를 통해 설정한다.

k8s 내부 컨테이너 콘솔로 접근후에

gitlab-rails console -e producion   => gitlab rails 접근
진입 후 아래 명령어로 수정 (비번에 ' 싱글 쿼텐션 이거 넣었음)

user 라는 변수에 1번 root 계정을 지정 후 해당 객체의 비번을 갱신하는 형태임


user = User.where(id:1).first
user.password='[원하는 비번]'
user.password_confirmation='[원하는비번]'
user.save

 

 

 

일단 gitlab을 설치 yml은 아래와 같다.

전제조건은 스토리지클래스가 준비가 되어야 되고 외부 이미지 다운이 가능해야 된다

 

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gitlab-data
  namespace: gitlab
spec:
  storageClassName: [스토리지클래스명]
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gitlab-config
  namespace: gitlab
spec:
  storageClassName: [스토리지클래스명]
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: gitlab
  namespace: gitlab
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: gitlab
spec:
  type: NodePort
  ports:
  - port: 80
    targetPort: 80
    protocol: TCP
    name: http
    nodePort: 30001
  - port: 443
    targetPort: 443
    protocol: TCP
    name: httpd
  - port: 22
    targetPort: 22
    protocol: TCP
    name: ssh
  selector:
    app: gitlab

 

 

 

728x90