nexus on k8s最佳实战

本文涉及的产品
容器服务 Serverless 版 ACK Serverless,952元额度 多规格
容器服务 Serverless 版 ACK Serverless,317元额度 多规格
简介: 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

e6702cf73dc7430bae2c9ae92e9c7971.png

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、访问


b4b265f9a6074d698b707280eaf022f7.png

默认密码会在首次登录提示,按照提示修改密码。

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

31e97ce6fb02468691cce5911121bbc1.png

打包方式的尝试

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中使用。


相关实践学习
通过Ingress进行灰度发布
本场景您将运行一个简单的应用,部署一个新的应用用于新的发布,并通过Ingress能力实现灰度发布。
容器应用与集群管理
欢迎来到《容器应用与集群管理》课程,本课程是“云原生容器Clouder认证“系列中的第二阶段。课程将向您介绍与容器集群相关的概念和技术,这些概念和技术可以帮助您了解阿里云容器服务ACK/ACK Serverless的使用。同时,本课程也会向您介绍可以采取的工具、方法和可操作步骤,以帮助您了解如何基于容器服务ACK Serverless构建和管理企业级应用。 学习完本课程后,您将能够: 掌握容器集群、容器编排的基本概念 掌握Kubernetes的基础概念及核心思想 掌握阿里云容器服务ACK/ACK Serverless概念及使用方法 基于容器服务ACK Serverless搭建和管理企业级网站应用
目录
相关文章
|
4月前
|
Kubernetes 监控 安全
Kubernetes实战:集群管理与自动化技术详解
【6月更文挑战第27天】Kubernetes实战聚焦集群自动化管理,涵盖核心概念如主从架构、API Server及工作节点,强调自动扩缩容、RBAC安全控制与日志监控。通过IaC工具如Helm实现配置自动化,结合Prometheus等进行持续监控,强调安全策略与资源优化,展现K8s在现代应用管理中的威力。
|
1月前
|
存储 Kubernetes 负载均衡
CentOS 7.9二进制部署K8S 1.28.3+集群实战
本文详细介绍了在CentOS 7.9上通过二进制方式部署Kubernetes 1.28.3+集群的全过程,包括环境准备、组件安装、证书生成、高可用配置以及网络插件部署等关键步骤。
261 3
CentOS 7.9二进制部署K8S 1.28.3+集群实战
|
1月前
|
Kubernetes 负载均衡 前端开发
二进制部署Kubernetes 1.23.15版本高可用集群实战
使用二进制文件部署Kubernetes 1.23.15版本高可用集群的详细教程,涵盖了从环境准备到网络插件部署的完整流程。
76 2
二进制部署Kubernetes 1.23.15版本高可用集群实战
|
16天前
|
Kubernetes 网络协议 Docker
Kubernetes入门到进阶实战
Kubernetes入门到进阶实战
53 0
|
29天前
|
存储 Kubernetes Docker
深入探索容器化技术:Docker 实战与 Kubernetes 管理
深入探索容器化技术:Docker 实战与 Kubernetes 管理
57 0
|
1月前
|
Kubernetes Ubuntu 网络安全
Ubuntu基于kubeadm快速部署K8S实战
关于如何在Ubuntu系统上使用kubeadm工具快速部署Kubernetes集群的详细实战指南。
143 2
|
1月前
|
Kubernetes Linux API
CentOS 7.6使用kubeadm部署k8s 1.17.2测试集群实战篇
该博客文章详细介绍了在CentOS 7.6操作系统上使用kubeadm工具部署kubernetes 1.17.2版本的测试集群的过程,包括主机环境准备、安装Docker、配置kubelet、初始化集群、添加节点、部署网络插件以及配置k8s node节点管理api server服务器。
91 0
CentOS 7.6使用kubeadm部署k8s 1.17.2测试集群实战篇
|
1月前
|
Kubernetes 容器
Kubernetes附加组件Dashboard部署实战篇
关于如何在Kubernetes集群中部署和配置Dashboard组件的详细实战指南,涵盖了从创建证书、部署Dashboard、设置服务访问到登录认证的完整流程。
195 0
Kubernetes附加组件Dashboard部署实战篇
|
2月前
|
Kubernetes Cloud Native Docker
云原生入门:Docker容器化部署实战
【8月更文挑战第31天】在数字化浪潮中,云原生技术成为企业转型的助推器。本文通过Docker容器化部署的实践案例,引导读者从零基础到掌握基础的云原生应用部署技能。我们将一起探索Docker的魅力,学习如何将一个应用容器化,并在云平台上运行起来,为深入云原生世界打下坚实基础。