Nexus3-Helm3部署Nexus3

image

一、创建单独的ns

# /xx/conf/nexus/sonatype-nexus/namespace.yaml

apiVersion: v1
kind: Namespace
metadata:
  name: nexus

# kubectl apply -f namespace.yaml

二、Node创建label

# kubectl label  node xx-dev-k8s-worker-jenkins-worker-02-ningxia nexus="true"

# kubectl get nodes --show-labels
xx-dev-k8s-worker-jenkins-worker-02-ningxia             Ready    <none>   175d   v1.17.11   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,env=test,kubernetes.io/arch=amd64,kubernetes.io/hostname=yc-dev-k8s-worker-jenkins-worker-02-ningxia,kubernetes.io/os=linux,nexus=true,prometheus-node-exporter=true,prometheus-operator=true,service_role=harbor,skywalking_role=true

三、helm3部署nexus3

# helm search repo nexus
# helm  pull  stable/sonatype-nexus
# tar  xvf  sonatype-nexus-1.21.2.tgz
  • 调整value.yaml

image
image

  • 创建 pv
/yc/conf/nexus# cat pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
  name: nexus-pv
spec:
  capacity:
    storage: 10Gi
  volumeMode: Filesystem
  accessModes:
  -  ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: /yc/data/nexus
    
# kubectl get pv
NAME                                CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                                                                                                 STORAGECLASS                             REASON   AGE
nexus-pv                            10Gi       RWO            Retain           Bound    nexus/nexus-sonatype-nexus-data
  • 创建完成,检查组件正常
# helm3 list
NAME 	NAMESPACE	REVISION	UPDATED                                	STATUS  	CHART               	APP VERSION
nexus	default  	1       	2021-03-05 09:59:44.075473028 +0000 UTC	deployed	sonatype-nexus-3.4.0	3.4.0

# kubectl get pods -n nexus
NAME                                    READY   STATUS    RESTARTS   AGE
nexus-sonatype-nexus-6595c648b7-dqffh   2/2     Running   0          3d16h

# kubectl  get pvc -n nexus
NAME                        STATUS   VOLUME     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
nexus-sonatype-nexus-data   Bound    nexus-pv   10Gi       RWO                           3d16h

# kubectl get service -n nexus
NAME                   TYPE       CLUSTER-IP    EXTERNAL-IP   PORT(S)          AGE
nexus-sonatype-nexus   NodePort   10.0.98.188   <none>        8080:30490/TCP   3d16h

四、nginx代理service

# cat nexus.xx.live.conf
server {
    listen 80;
    server_name nexus.xx.live;
    charset utf-8;
    client_body_buffer_size 10M;
    proxy_redirect     off;
    proxy_set_header   Host             $host:$server_port;
    proxy_set_header   X-Real-IP        $remote_addr;
    proxy_set_header X-Forwarded-Host $host:$server_port;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_next_upstream error timeout invalid_header http_502 http_503 http_504;
    proxy_ignore_client_abort on;
    proxy_read_timeout  180;
    proxy_buffering on;
    proxy_buffer_size 8k;
    proxy_buffers 8 8M;
    gzip                on;
    gzip_min_length     1000;
    gzip_types          text/plain text/css application/json text/xml application/xml application/xml+rss text/javascript;
    set $upstream_nexus  http://nexus-sonatype-nexus.nexus.svc.cluster.local:8080;	# service
       location / {
        proxy_pass $upstream_nexus;
        proxy_set_header   Host             $host:$server_port;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header X-Forwarded-Host $host:$server_port;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        # include sites-available/xx/white-list.conf;
    }

}
posted @ 2021-06-03 17:37  SRE运维充电站  阅读(854)  评论(0编辑  收藏  举报