본문 바로가기
Infra System

nexus install on kubernetes

by kellis 2020. 10. 13.

How To Setup Latest Nexus OSS On Kubernetes를 참고하여 설치하였으며, 부분적으로 누락된 내용이 있어 다시 정리하였습니다. 

 

설치 방법

1. namespace 생성

kubectl create namespace devops-tool

2. Deployment.yaml 파일 생성

vi Deployment.yaml

Deployment.yaml의 내용은 아래와 같습니다. 

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nexus
  namespace: devops-tool
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: nexus-server
    spec:
      containers:
        - name: nexus
          image: sonatype/nexus3:latest
          resources:
            limits:
              memory: "4Gi"
              cpu: "1000m"
            requests:
              memory: "2Gi"
              cpu: "500m"
          ports:
            - containerPort: 8081
          volumeMounts: #
            - name: nexus-data
              mountPath: /nexus-data
      volumes: #
        - name: nexus-data
          emptyDir: {}

container port를 8081로 지정했는데, 이 포트는 외부에 오픈되는 포트가 아닙니다.

 

3. 배포 생성

kubectl create -f Deployment.yaml

 

4. 배포가 잘 되었는지 확인

kubectl get po -n devops-tool

-n 은 하기 namespace에 있는 pod를 얻기 위한 옵션

 

5. Service.yaml 파일 생성

vi Service.yaml

Service.yaml의 내용은 아래와 같습니다. 

apiVersion: v1
kind: Service
metadata:
  name: nexus-service
  namespace: devops-tool
  annotations: #
      prometheus.io/scrape: 'true'
      prometheus.io/path:   /
      prometheus.io/port:   '8081'
spec:
  selector:
    app: nexus-server
  type: LoadBalancer
  ports: #
    - port: 8081
      name: web
      targetPort: 8081
      nodePort: 32000
    - port: 12000
      name: docker-registry
      targetPort: 12000
      nodePort: 32001

 

6. Service 생성

kubectl create -f Service.yaml

 

배포 시 컨테이너 포트를 8081로 정했는데, 이를 외부 포트 32000과 매핑해주도록 설정했습니다. 즉 외부에서는 32000 포트로 접근 가능합니다. 

 


Conclusion

# 설치는 정상적으로 되었고 aws 보안그룹에 32000 포트를 오픈하여 http://{masterNodeIP}:32000/로 접속 가능합니다.

 

# 일반적으로 nexus 기본 계정이 admin password가 admin123라고 하는데 아니었음. -> 실행 중인 컨테이너에 접속하여 확인해야 합니다. 

default 계정 정보 확인하는 방법

kubectl get pods -n {namespace명} => pod의 NAME 획득

kubectl describe pod {POD NAME} => pod가 실행중인 node를 확인

# 해당 node에 접속

kubectl get pod -n devops-tool  => nexus가 실행중인 pod name 획득

kubectl exec -it {pod name} -n {namespace명} -- bash

# 해당 container에 접속

cd /nexus-data

cat admin.password # 기본 admin password 획득

http://{masterNodeIP}:32000/ 로 이동하여 admin / {admin.password} 로 로그인.

 

# 로그인 후 접속 패스워드 변경.

 

'Infra System' 카테고리의 다른 글

Common Lib Stub - Inner Architecture  (0) 2020.10.14
Application Dependency Declaration  (0) 2020.10.14
nexus install on ec2  (0) 2020.10.13
mongodb install on kubernetes  (0) 2020.10.13
mongodb install using docker(standalone)  (0) 2020.10.13

댓글