当前位置: 首页 > news >正文

nexus on k8s最佳实战

nexus on k8s最佳实战

1、helm 安装包

 #添加 helm 仓库
 helm repo add sonatype https://sonatype.github.io/helm3-charts/
# 下载 chart 到本地
 helm pull sonatype/nexus-repository-manager
#copy 到文件服务器方便下载
scp nexus-repository-manager-41.1.2.tgz 10.50.10.25:/www/pigsty

在这里插入图片描述

2、修改关键参数

  • image
docker pull ninesun0318/sonatype.nexus3:3.41.1
docker tag ninesun0318/sonatype.nexus3:3.41.1 myharbor.com/nexus/sonatype.nexus3:3.41.1
  • 存储
  storageClass: "managed-nfs-storage"
  storageSize: 50Gi
  • service 暴露方式

    需要外部可访问nexus,建议使用nexus.

    service:
      name: nexus3
      enabled: true
      labels: {}
      annotations: {}
      type: NodePort
      port: 31712
    

3、安装nexus

[root@master2 /opt/helm/nexus-repository-manager]#helm install chot-nexus -n nexus  /opt/helm/nexus-repository-manager
NAME: chot-nexus
LAST DEPLOYED: Fri Sep  2 15:01:33 2022
NAMESPACE: nexus
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL by running these commands:
  export NODE_PORT=$(kubectl get --namespace nexus -o jsonpath="{.spec.ports[0].nodePort}" services chot-nexus-nexus-repository-manager)
  export NODE_IP=$(kubectl get nodes --namespace nexus -o jsonpath="{.items[0].status.addresses[0].address}")
  Your application is available at http://$NODE_IP:$NODE_PORT

4、检查

[root@master1 /opt/ansible]#k get all -n nexus
NAME                                                       READY   STATUS    RESTARTS   AGE
pod/chot-nexus-nexus-repository-manager-6595d7c79b-q7znf   1/1     Running   0          64m

NAME                                          TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
service/chot-nexus-nexus-repository-manager   NodePort   10.96.11.171   <none>        8081:31712/TCP   64m

NAME                                                  READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/chot-nexus-nexus-repository-manager   1/1     1            1           64m

NAME                                                             DESIRED   CURRENT   READY   AGE
replicaset.apps/chot-nexus-nexus-repository-manager-6595d7c79b   1         1         1       64m

5、报错处理

### k8s pod has unbound immediate PersistentVolumeClaims

安装nexus,使用nfs sc pod一直报这个错误?

原因:使用kuboard 托管的sc限制了ns在kube-system,因此再nexus中的无法使用. 后面改用managed-nfs-storage解决问题。

### pod readiness probe端口探测失败原因调查?

安装nexus仓库时pod 的8081 端口一直访问不通

​```bash
Readiness probe failed: Get "http://10.244.166.156:8081/": dial tcp 10.244.166.156:8081: connect: connection refused
​```

探测的yaml

​```yaml
 readinessProbe:
            failureThreshold: 6
            httpGet:
              path: /
              port: 8081
              scheme: HTTP
            initialDelaySeconds: 30
            periodSeconds: 30
            successThreshold: 1
            timeoutSeconds: 10```

这个问题的原因是超过了initialDelaySeconds的时间导致探测失败,适当调大这个参数,或者重启一下就好了。

6、访问

在这里插入图片描述
默认密码会在首次登录提示,按照提示修改密码。

7、批量上传本地jar包

之前物理机上安装的nexus由于每次打包都有问题,花了好多时间。这次干脆直接搭建一个nexus,并使用脚本把本地的包都上传到仓库中。

报错如下:

[ERROR] Failed to execute goal on project chot-configs: Could not resolve dependencies for project com.lichkin.chot:chot-configs:jar:2.0.0-CHOT: Failure to find javax.interceptor:javax.i
nterceptor-api:jar:1.2 in http://ip:8081/repository/maven-releases/ was cached in the local repository, resolution will not be reattempted until the update interval of nexus has
 elapsed or updates are forced -> [Help 1]
#!/bin/bash
# @date 2022年9月2日11:26:51
# @author ninesun
# nexushttp: http://ip:31712/repository/maven-releases/
# 使用方式: bash uploadJarWithscripts.sh -u admin -p chot123  -r http://ip:31712/repository/maven-releases/

while getopts ":r:u:p:" opt; do
	case $opt in
		r) REPO_URL="$OPTARG"
		;;
		u) USERNAME="$OPTARG"
		;;
		p) PASSWORD="$OPTARG"
		;;
	esac
done

find . -type f -not -path './uploadJarWithscripts\.sh*' -not -path '*/\.*' -not -path '*/\^archetype\-catalog\.xml*' -not -path '*/\^maven\-metadata\-local*\.xml' -not -path '*/\^maven\-metadata\-deployment*\.xml' | sed "s|^\./||" | xargs -I '{}' curl -s -u "$USERNAME:$PASSWORD" -X PUT -v -T {} ${REPO_URL}/{} ;

8、编译项目

打包验证

mvn clean -U install

在这里插入图片描述

打包方式的尝试

mvn clean package -Dmaven.repo.local=E:\mavn_repo\MavenRepository
	
mvn clean package --settings D:\soft\apache-maven-3.5.2\conf\settings.xml -Dmaven.test.skip=true
	
mvn clean package --settings C:\Users\135\.m2\settings.xml -Dmaven.test.skip=true 	

不知为何已经指定本地、setting好像都会从nexus拉取,原因未知,感觉像是bug.

9、参考

https://artifacthub.io/packages/helm/sonatype/nexus-repository-manager

10、nexus 仓库说明

maven-central:maven中央库,默认从 https://repo1.maven.org/maven2/ 拉取 jar。

maven-releases:私库发行版 jar。

maven-snapshots:私库快照版(调试版本)jar。

maven-public:仓库分组,把上面三个仓库组合在一起对外提供服务,在本地 maven 基础配置 settings.xml中使用。

相关文章:

  • LeetCode 每日一题 2022/8/29-2022/9/4
  • webpack定制化 高级配置[热更新、热打包、别名、调试]
  • 外贸员需要知道的那些事儿
  • c++11 多线程支持 (std::shared_future)
  • webpack定制化 基础配置[基础、配置、初运行]
  • mysql基本语句:DQL(数据查询语言)
  • Android | 通过URL获取网络图片Bitmap格式
  • SpringCloud-01 Rest学习环境搭建笔记
  • 基于APB与I2C的多主多从架构设计 - Function Description
  • R语言 ggdendro_谱系图
  • Kafka原理及概念解释
  • Springboot-自定义Spring Boot Starter并推送到远端公服
  • 《奔跑吧,程序员:从零开始打造产品、技术和团队》 读书笔记
  • PHP - 各版本对比 - 整理
  • JAVA 常见算法(选择排序,二分查找)
  • 「面试题」如何实现一个圣杯布局?
  • 2017-08-04 前端日报
  • HTML5新特性总结
  • Idea+maven+scala构建包并在spark on yarn 运行
  • JavaScript函数式编程(一)
  • Javascript设计模式学习之Observer(观察者)模式
  • Python学习笔记 字符串拼接
  • 自制字幕遮挡器
  • PostgreSQL 快速给指定表每个字段创建索引 - 1
  • ​卜东波研究员:高观点下的少儿计算思维
  • ​草莓熊python turtle绘图代码(玫瑰花版)附源代码
  • # 数论-逆元
  • #NOIP 2014# day.1 T3 飞扬的小鸟 bird
  • #经典论文 异质山坡的物理模型 2 有效导水率
  • #在 README.md 中生成项目目录结构
  • (13)Latex:基于ΤΕΧ的自动排版系统——写论文必备
  • (32位汇编 五)mov/add/sub/and/or/xor/not
  • (附源码)springboot电竞专题网站 毕业设计 641314
  • (剑指Offer)面试题34:丑数
  • (接口自动化)Python3操作MySQL数据库
  • (十七)Flask之大型项目目录结构示例【二扣蓝图】
  • (新)网络工程师考点串讲与真题详解
  • (学习日记)2024.04.04:UCOSIII第三十二节:计数信号量实验
  • (原)Matlab的svmtrain和svmclassify
  • .NET BackgroundWorker
  • .NET Core中Emit的使用
  • .NET MVC、 WebAPI、 WebService【ws】、NVVM、WCF、Remoting
  • .NET MVC之AOP
  • .net MySql
  • .NET开源快速、强大、免费的电子表格组件
  • //解决validator验证插件多个name相同只验证第一的问题
  • @Autowired @Resource @Qualifier的区别
  • @entity 不限字节长度的类型_一文读懂Redis常见对象类型的底层数据结构
  • @Transactional 竟也能解决分布式事务?
  • [ Linux 长征路第二篇] 基本指令head,tail,date,cal,find,grep,zip,tar,bc,unname
  • []Telit UC864E 拨号上网
  • [20170705]lsnrctl status LISTENER_SCAN1
  • [AAuto]给百宝箱增加娱乐功能
  • [Android] 240204批量生成联系人,短信,通话记录的APK
  • [Android] Amazon 的 android 音视频开发文档