반응형
K8s 환경에서 Nexus3 Yaml
중요 사항
- manifest (yaml) 로 설치
- Namespace : nexus3
1. Namespace 생성
- $ vi nexus-ns.yaml
apiVersion: v1
kind: Namespace
metadata:
name: nexus3
2. PV 생성
- $ vi nexus-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: nexus-pv
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: local-storage
hostPath:
path: /k8s-data/nexus
3. PVC 생성
- $ vi nexus-pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nexus-pvc
spec:
storageClassName: local-storage
volumeName: nexus-pv
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
4. Deployment 생성
- initcontainer를 생성해서 폴더 생성 및 권한주는 작업을 해야한다.
- initcontainer는 pod 생성 전에 먼저 선행되므로 initcontainer로 위의 작업을 진행해준다.
- $ vi nexus-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nexus-deploy
spec:
replicas: 1
selector:
matchLabels:
app: nexus
template:
metadata:
labels:
app: nexus
spec:
initContainers:
- name: init-myservice
image: busybox:1.28
command: ['sh', '-c', "mkdir -p nexus-data ; chown -R 200:200 nexus-data "]
volumeMounts:
- mountPath: /nexus-data
name: nexus-data-volume
containers:
- image: sonatype/nexus3:3.41.1
name: nexus
ports:
- containerPort: 8081
- containerPort: 5000
volumeMounts:
- mountPath: /nexus-data
name: nexus-data-volume
volumes:
- name: nexus-data-volume
persistentVolumeClaim:
claimName: nexus-pvc
5. Service 생성
- 참고
- Service는 논리적인 pod의 집합이며, 어떻게 접근할지에 대한 정책을 정의해 놓은것.
Label selector 통해 어떤 pod를 포함할지 정의가 가능하고
외부접근이 가능하게끔 허용할수도 있다. - type :
ClusterIP(default) : 클러스터 내부에서만 접근 가능한 IP
NodePort : Port번호를 통해 외부에서 접근 (NAT 컨셉)
Load Balancer : 외부의 Load Balancer를 사용하는 방법
ExternalName : kube-dns 컴포넌트로 DNS를 이용하는 방법 - $ vi nexus-service.yaml
apiVersion: v1
kind: Service
metadata:
name: nexus-svc
spec:
type: NodePort
ports:
- port: 80
nodePort: 32001
targetPort: 8081
protocol: TCP
name: http
- port: 5000
nodePort: 32011
targetPort: 5000
protocol: TCP
name: docker
selector:
app: nexus
※ NodePort 추가 설명
외부 IP가 192.168.1.1 이면 31000 Port를 통해 Node에 접근할 수 있다 (NodePort)
① Node Port ② Service Port ③ Pod’s Target Port
6. Yaml 실행 및 적용
- Yaml 파일 적용 $ kubectl apply -f . —namespace=nexus3
- pod 확인 $ kubectl get pod -n nexus
7.초기 비밀번호 확인 및 로그인
1. Yaml 파일 적용
- $ kubectl apply -f . —namespace=wgh-ns
2. Pod 확인
- $ kubectl get pod -n wgh-ns
3. 웹에서 nexus 실행 & 확인
- MasterNodeIP:32001
4. 초기 아이디 및 비밀번호 확인
- 아이디 : admin
- 초기 비밀번호 확인 방법
$ kubectl **exec** -it -n wgh-ns [pod명] *-- cat /nexus-data/admin.password*
참고문헌
https://devopscube.com/setup-nexus-kubernetes/
[kubernetes] nexus3 구축
refer to https://hub.docker.com/r/sonatype/nexus3 구성 사전에 provisioner가 구축돼야합니다. manifest --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: nexus-pvc namespace: default spec: storageClassName: jenkins-nfs accessModes: -
yjwang.tistory.com
반응형
'개발인생 > Kubernetes' 카테고리의 다른 글
install) kubernetes + jenkins (yaml 파일로 배포하기) (0) | 2023.02.09 |
---|---|
install) kubernetes + GitLab (yaml 파일로 배포) (0) | 2023.02.07 |
install ) kubernetes + Elasticsearch cluster (yaml로 설치) (0) | 2023.02.02 |
install) Kubernetes + nas storage (NFS 서버) (0) | 2023.01.27 |
install) kubernetes + LoadBalancer(metal LB) 구축 (0) | 2023.01.27 |