이번 chapter에서는 CI 의 두번째 단계인 NEXUS 설치 및 Repository 구성에 대해 기술하겠다.
아래는 KAONI CLOUD 아키텍쳐 구성도 이다.
Namespace CICD 에 NEXUS, JENKINS, ArgoCD를 구성할 것이다.
type이 cicd, cicd2인 WORKER NODE가 2개가 보일 것이다. 각각의 NODE를 NODE cicd 01, NODE cicd 02라 부르겠다.
CI 에 관련된 Pod (NEXUS, JENKINS)는 NODE cicd 02번에,
CD에 관련된 Pod (ArgoCD)는 NODE cicd 01번에
올라가도록 지정할 것이다.
1. NEXUS 설치
1) write menifest
apiVersion: v1
kind: PersistentVolume
metadata:
annotations:
finalizers:
- kubernetes.io/pv-protection
labels:
name: nexus-pv
name: nexus-pv
spec:
accessModes:
- ReadWriteMany
capacity:
storage: 450Gi
nfs:
path: /nexus/2.0/home
server: 10.0.50.20
persistentVolumeReclaimPolicy: Retain
storageClassName: rancher-storage
volumeMode: Filesystem
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
pv.kubernetes.io/bind-completed: "yes"
pv.kubernetes.io/bound-by-controller: "yes"
finalizers:
- kubernetes.io/pvc-protection
name: nexus-pvc
namespace: cicd
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 450Gi
storageClassName: rancher-storage
volumeMode: Filesystem
volumeName: nexus-pv
|
NFS 정적 프로비저닝 (static provisioning)
apiVersion: v1
kind: Service
metadata:
annotations:
labels:
app: nexus
name: nexus
namespace: cicd
spec:
externalTrafficPolicy: Cluster
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- name: http
nodePort: 30412
port: 8081
protocol: TCP
targetPort: 8081
- name: docker
nodePort: 31110
port: 5000
protocol: TCP
targetPort: 5000
- name: docker-1
nodePort: 31848
port: 5001
protocol: TCP
targetPort: 5001
selector:
app: nexus
sessionAffinity: None
type: NodePort
|
nodePort는 30000 ~ 32767 중 랜덤한 값으로 지정해도 무방하다.
type:NodePort으로 지정하면, ingress를 이용하지 않고도 nodePort를 통해 Service로 접근 가능해진다.
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
name: nexus
namespace: cicd
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: nexus
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: nexus
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: type
operator: In
values:
- cicd2
containers:
- image: sonatype/nexus3:3.42.0
imagePullPolicy: Always
name: nexus
ports:
- containerPort: 8081
protocol: TCP
- containerPort: 5000
protocol: TCP
- containerPort: 5001
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /nexus-data
name: nexus-pvc
- mountPath: /etc/localtime
name: timezone-config
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext:
fsGroup: 1000
runAsUser: 1000
terminationGracePeriodSeconds: 30
volumes:
- name: nexus-pvc
persistentVolumeClaim:
claimName: nexus-pvc
- hostPath:
path: /usr/share/zoneinfo/Asia/Seoul
type: ""
name: timezone-config
|
nodeAffinity : type=cicd2인 Node 위에만 pod가 올라가도록 지정
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
name: ingress-nexus
namespace: cicd
spec:
ingressClassName: user-ingress-class
rules:
- host: nexus-msa2.kaoni.com
http:
paths:
- backend:
service:
name: nexus
port:
number: 8081
path: /
pathType: Prefix
|
host의 값은 DNS 등록된 domain 입력.
등록된 domain이 없다면(혹은 dns를 사용 안한다면) ingress.yaml는 넘어가도 무방하다.
2) apply menifest
kubectl apply -f [menifest] |
위에서 작성한 yaml 파일을 적용
3) get NEXUS_init_password
NEXUS의 admin 계정의 초기 패스워드를 확인
kubectl get pod -n cicd |
kubectl exec -it [nexus_pod_name] -n cicd -- bash |
NEXUS container 진입
cat /nexus-data/admin.password |
NEXUS의 admin 계정의 초기 패스워드를 확인
(id : admin / password : ********)
4) access to NEXUS
http://[domain] |
ex) http://nexus-msa2.kaoni.com |
또는
http:// [IP_address]:[NodePort] |
ex) http://10.0.50.10:30412 |
NodePort는 위에서 Service.yaml 에서 지정해 준 nodePort 값을 사용.
NEXUS 설치가 완료되었다.
다음은 Repository 구성 이다.
2. Repository 구성
1) Sign in
우측 상단에 Sign in을 눌러 로그인 진행
2) create BlobStores
톱니바퀴 클릭
Blob Stores 클릭
Create Blob Store 클릭
Type = File로 지정, Name = docker 로 입력
3) create Repositories
Create Repository 클릭
docker (hosted) 클릭
Name = docker-hosted or [repo_name]
HTTP port : 5000
HTTPS port : 5001
Blob store : docker 선택
4) Repository > Proprietary Repositories
Proprietary Repositories 클릭
docker-hosted 클릭 (또는 본인이 지정한 [repo_name] 클릭)
docker-hosted가 Proprietary Hosted Repositories 영역으로 이동
5) Security > Realms
Docker Bearer Token Realm 클릭
Docker Bearer Token Realm 이 우측(Active) 영역으로 넘어감.
아래 Save 클릭
이것으로 NEXUS 설치 및 Repository 구성을 마쳤다.
다음 chapter에서는 CI의 핵심인 Jenkins 설치/구성 에 대해 다루겠다.
'1) Kaoni Cloud > CI CD' 카테고리의 다른 글
06. Kubernetes에 SonarQube 설치 (1) | 2024.06.08 |
---|---|
05. Jenkins Pipeline 구축 (0) | 2024.06.07 |
04. Kubernetes에 Jenkins 설치 (0) | 2024.06.07 |
02. Ubuntu에 GITLAB 설치 (0) | 2024.05.29 |
01. 개요 (0) | 2024.05.28 |