ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Nexus3 迁移k8s

2021-12-30 18:02:21  阅读:236  来源: 互联网

标签:name nexus nexus3 Nexus3 others 迁移 k8s data


背景

机房搬迁,趁此时机,将 Nexus3也容器化管理

docker 容器化测试

1.复制之前数据到另一个目录进行 docker测试

cp -a  /some/dir/nexus-data/db/ /opt/nexus-data/
cp -a  /some/dir/nexus-data/blobs/ /opt/nexus-data/

docker rm -f nexus-test 
docker run -d -p 8085:8081 --name nexus-test -v /opt/nexus-data/db:/nexus-data/db -v /opt/nexus-data/blobs:/nexus-data/blobs sonatype/nexus3:3.14.0
#docker restart nexus-test  
docker logs -f nexus-test 
# 注 这里覆盖了/nexus-data/db 所以也不会有密码文件产生,服务将会沿用之前密码
#     容器版本最好也和之前服务的版本一致,不然可能会出现迁移数据不生效问题
  1. 访问 http://172.18.154.185:8085/#browse/search/maven 测试文件已都存在 ok 准备迁移k8s

k8s yaml文件

cat nex.yaml 
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    k8s-app: nexus3
  name: nexus3
  namespace: log-others
spec:
  replicas: 1
  selector:
    matchLabels:
      k8s-app: nexus3
  template:
    metadata:
      labels:
        k8s-app: nexus3
      name: nexus3
      namespace: log-others
    spec:
      containers:
      - name: nexus3
        image: sonatype/nexus3:3.14.0
        imagePullPolicy: IfNotPresent
        ports:
          - containerPort: 8081
            name: web
            protocol: TCP
        #livenessProbe:
        #  httpGet:
        #    path: /
        #    port: 8081
        #  initialDelaySeconds: 60
        #  periodSeconds: 30
        #  failureThreshold: 6
        #readinessProbe:
        #  httpGet:
        #    path: /
        #    port: 8081
        #  initialDelaySeconds: 60
        #  periodSeconds: 30
        #  failureThreshold: 6
        resources:
          limits:
            cpu: 2000m
            memory: 4Gi
          requests:
            cpu: 500m
            memory: 512Mi
        volumeMounts:
        - name: nexus-data
          mountPath: /nexus-data
      volumes:
        - name: nexus-data
          persistentVolumeClaim:
            claimName: nexus-data-pvc
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nexus-data-pvc
  namespace: log-others
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: "csi-rbd-sc"
  resources:
    requests:
      storage: 30Gi

---
apiVersion: v1
kind: Service
metadata:
  name: nexus3
  namespace: log-others
  labels:
    k8s-app: nexus3
spec:
  selector:
    k8s-app: nexus3
  type: ClusterIP
  ports:
    - name: web
      protocol: TCP
      port: 8081
      targetPort: 8081
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nexus3
  namespace: log-others
  labels:
    k8s-app: nexus3
spec:
  rules:
    - host: "xxx.com"
      http:
        paths:
          - path: /
            pathType: ImplementationSpecific
            backend:
              service:
                name: nexus3
                port:
                  number: 8081

我们这里直接访问域名进行验证 xxx.com , 测试没问题再手动迁移一下数据(这里比较着急,优雅可以写个初始化镜像)

 kubectl -n log-others   exec -it nexus3-7c7f5bcbb5-hw67s  -- sh 
#这里吧之前的文件已经压缩上传到了公司的下载服务器上 进行下载、解压目录
curl -o wj.tgz http://xxx/wj.tgz
tar xvf wj.tgz
...
#完事之后重启pod 
kubectl -n log-others   delete nexus3-7c7f5bcbb5-hw67s

参考文档

在k8s集群部署Nexus:https://www.cnblogs.com/ssgeek/p/12270079.html

标签:name,nexus,nexus3,Nexus3,others,迁移,k8s,data
来源: https://www.cnblogs.com/x602/p/15749944.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有