YJWANG

[kubernetes] nexus3 구축 본문

60.Cloud/80.Kubernetes

[kubernetes] nexus3 구축

왕영주 2021. 1. 27. 13:13

refer to


구성


사전에 provisioner가 구축돼야합니다.

manifest

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nexus-pvc
  namespace: default
spec:
  storageClassName: jenkins-nfs
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 20Gi
---      
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nexus
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nexus
  template:
    metadata:
      labels:
        app: nexus
    spec:
      containers:
      - image: sonatype/nexus3
        name: nexus
        ports:
        - containerPort: 8081
        - containerPort: 5000
        volumeMounts:
          - mountPath: /nexus-data
            name: nexus-data-volume
      volumes:
        - name: nexus-data-volume
          persistentVolumeClaim:
            claimName: nexus-pvc
---
apiVersion: v1
kind: Service
metadata:
  name: nexus-service
  namespace: default
spec:
  type: NodePort
  ports:
  - port: 80
    targetPort: 8081
    protocol: TCP
    name: http
  - port: 5000
    targetPort: 5000
    protocol: TCP
    name: docker 
  selector:
    app: nexus

apply

[root@master01 ~]# kubectl apply -f nexus.yaml

-

[root@master01 ~]# kubectl get pod nexus-5c7d5d97cb-q877w 
NAME                     READY   STATUS    RESTARTS   AGE
nexus-5c7d5d97cb-q877w   2/2     Running   0          3m14s

이후 세팅

client 설치

[root@master01 ~]# yum -y install python3-pip; pip3 install nexus3-cli

기본 암호 추출

[root@master01 ~]# kubectl exec -it -n default nexus-5c7d5d97cb-q877w -- cat /nexus-data/admin.password
Defaulting container name to nexus.
Use 'kubectl describe pod/nexus-5c7d5d97cb-q877w -n default' to see all of the containers in this pod.
4efdfda1-8fb7-4bd9-8f6a-c5f45e4b9fda

nexus3 login

[root@master01 ~]# kubectl get svc nexus-service 
NAME            TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)                       AGE
nexus-service   NodePort   10.233.29.38   <none>        80:32677/TCP,5000:30253/TCP   9m23s

[root@master01 ~]# nexus3 login -U http://localhost:32677
Username [admin]: admin
Password: 
X509 verify [Y/n]: n

Login successful.
Configuration saved to /root/.nexus-cli, /root/.nexus-cli.env

add docker regi

docker regi secure 설정

[root@master01 default]# cat /etc/docker/daemon.json 
{
    "insecure-registries": ["10.233.29.38:5000"]
}

-

[root@master01 default]# systemctl restart docker

-

[root@master01 default]# docker info |grep -i insecure -A5
 Insecure Registries:
  10.233.29.38:5000
  127.0.0.0/8
 Live Restore Enabled: false

or

[root@master01 etc]# systemctl cat docker
...
# /etc/systemd/system/docker.service.d/docker-options.conf
[Service]
Environment="DOCKER_OPTS= --iptables=false \
--exec-opt native.cgroupdriver=systemd \
 \
 \
--data-root=/var/lib/docker \
--log-opt max-size=50m --log-opt max-file=5 \
--insecure-registry=211.xx.xx.xx:30253 --insecure-registry=10.233.29.38:5000 \
"

재시작

[root@master01 etc]# systemctl daemon-reload
[root@master01 etc]# systemctl restart docker

docker login test

[root@master01 default]# docker login 10.233.29.38:5000
Username: admin
Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

이후 kubernetes와의 연동은 아래 링크를 참조

반응형