云原生Kubernetes: K8S 1.29版本 部署Nexus

news/2024/5/19 21:53:45

目录

 一、实验

1.环境

2.搭建NFS

3. K8S 1.29版本 部署Nexus

二、问题

1.volumeMode有哪几种模式


 一、实验

1.环境

(1)主机

表1 主机

主机架构版本IP备注
masterK8S master节点1.29.0192.168.204.8

node1K8S node节点1.29.0192.168.204.9
node2K8S node节点1.29.0192.168.204.10已部署Kuboard

(2)master节点查看集群

1)查看node
kubectl get node2)查看node详细信息
kubectl get node -o wide

(3)查看pod

[root@master ~]# kubectl get pod -A

(4) 访问Kuboard

http://192.168.204.10:30080/kuboard/cluster

查看节点

2.搭建NFS

(1)检查并安装rpcbind和nfs-utils软件包

[root@master ~]# rpm -q rpcbind nfs-utils

(2)创建目录并授权

[root@master ~]# mkdir -p /opt/nexus

[root@master opt]# chmod 777 nexus/

(3)打开nfs的配置文件

[root@master opt]# vim /etc/exports

(4)配置文件

给所有网段用户赋予读写权限、同步内容、不压缩共享对象root用户权限

……
/opt/nexus *(rw,sync,no_root_squash)

(5)先后开启rpcbind、nfs服务并热加载配置文件内容,查看本机发布的nfs共享目录

[root@master opt]# systemctl restart nfs

(6)监听端口

[root@master opt]# ss -antp | grep rpcbind

(7)查看共享

[root@master opt]# showmount -e

其他节点查看

[root@node1 ~]# showmount -e master

3. K8S 1.29版本 部署Nexus

(1)创建名称空间

[root@master opt]# kubectl create ns nexus

(2)创建nexus的pv

[root@master ~]# vim pv-nexus.yaml

apiVersion: v1
kind: PersistentVolume
metadata:name: pv-nexus
spec:capacity:storage: 30Gi    #配置容量大小volumeMode: FilesystemaccessModes:- ReadWriteOnce     #配置访问策略为只允许一个节点读写persistentVolumeReclaimPolicy: Retain  #配置回收策略,Retain为手动回收storageClassName: "pv-nexus"       #配置为nfsnfs:path: /opt/nexus   #配置nfs服务端的共享路径server: 192.168.204.8    #配置nfs服务器地址

(3)生成资源

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

(4)查看pv

[root@master ~]# kubectl get pv

(5)拉取镜像

 node1

[root@node1 ~]# docker pull sonatype/nexus3:3.28.0

(6) 导出镜像

[root@node1 ~]# docker save -o nexus.tar sonatype/nexus3:3.28.0

(7)复制Docker镜像到node2节点

[root@node1 ~]# scp nexus.tar root@node2:~

(8)node2节点导入Docker镜像

[root@node2 ~]# docker load -i nexus.tar 

(9)部署nexus

[root@master ~]# vim nexus.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:name: nexus-pvcnamespace: nexus
spec:accessModes:- ReadWriteOncestorageClassName: "pv-nexus"resources:requests:storage: 30Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:labels:app: nexusname: nexusnamespace: nexus
spec:replicas: 1progressDeadlineSeconds: 600minReadySeconds: 30strategy:rollingUpdate:maxSurge: 1maxUnavailable: 0type: RollingUpdateselector:matchLabels:app: nexustemplate:metadata:labels:app: nexusspec:containers:- name: nexusimage: sonatype/nexus3:3.28.0imagePullPolicy: IfNotPresentports:- containerPort: 8081name: webprotocol: TCPlivenessProbe:httpGet:path: /port: 8081initialDelaySeconds: 70periodSeconds: 30failureThreshold: 6readinessProbe:httpGet:path: /port: 8081initialDelaySeconds: 60periodSeconds: 30failureThreshold: 6resources:limits:cpu: 1000mmemory: 2Girequests:cpu: 500mmemory: 512MivolumeMounts:- name: nexus-datamountPath: /nexus-datavolumes:- name: nexus-datapersistentVolumeClaim:claimName: nexus-pvc
---
apiVersion: v1
kind: Service
metadata:name: nexusnamespace: nexuslabels:app: nexus
spec:selector:app: nexustype: NodePortports:- name: webprotocol: TCPport: 8081targetPort: 8081nodePort: 30001

(11)生成资源

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

(12)查看pv,pvc

[root@master ~]# kubectl get pv

[root@master ~]# kubectl get pvc -n nexus

(13) 查看pod,svc

[root@master ~]# kubectl get pod,svc -n nexus

(14) Kuboard查看

工作负载

容器组

服务

存储

(15)部署ingress

vim ingress-nexus.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:name: ingress-nexusnamespace: nexus
spec:ingressClassName: "nginx"rules:- host: nexus.sitehttp:paths:- path: /pathType: Prefixbackend:service:name: nexusport:number: 8081

(16)生成资源

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

(17)查看ingress

[root@master ~]# kubectl get ingress -n nexus

(18)详细查看

[root@master ~]# kubectl describe ingress ingress-nexus -n nexus
Name:             ingress-nexus
Labels:           <none>
Namespace:        nexus
Address:          10.101.23.182
Ingress Class:    nginx
Default backend:  <default>
Rules:Host        Path  Backends----        ----  --------nexus.site  /   nexus:8081 (10.244.166.164:8081)
Annotations:  <none>
Events:Type    Reason  Age                From                      Message----    ------  ----               ----                      -------Normal  Sync    68s (x2 over 82s)  nginx-ingress-controller  Scheduled for syncNormal  Sync    68s (x2 over 82s)  nginx-ingress-controller  Scheduled for sync

(19)Kuboard查看

应用路由

详细信息

(20)master节点修改hosts

[root@master ~]# vim /etc/hosts

(21)curl测试

(22)物理机修改hosts

(23)访问系统

http://nexus.site:31820

(24)K8S进入容器获取nexus初始的登录密码

[root@master ~]# kubectl exec -it nexus-8498fc57cc-c82qr -n nexus /bin/bash
……
cat /nexus-data/admin.password

(25)输入用户名和密码

账号:admin
密码:上面获取的初始密码

(26)进入系统

初始化操作,下一步

修改密码

 先设置允许匿名访问

完成

(26)登录成功

(27)查看挂载情况(内容一致)

NFS

[root@master ~]# cd /opt/nexus/
[root@master nexus]# ls
blobs  db             etc                instances  karaf.pid  lock  nexus.yaml  port                 tmp
cache  elasticsearch  generated-bundles  javaprefs  keystores  log   orient      restore-from-backup

K8S容器

[root@master ~]# kubectl exec -it nexus-8498fc57cc-c82qr -n nexus /bin/bash
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
bash-4.4$ ls
bin   dev  help.1  lib	  licenses    media  nexus-data  proc  run   srv  tmp		     uid_template.sh  var
boot  etc  home    lib64  lost+found  mnt    opt	 root  sbin  sys  uid_entrypoint.sh  usr
bash-4.4$ cd nexus-data/
bash-4.4$ ls
blobs  db	      etc		 instances  karaf.pid  lock  nexus.yaml  port		      tmp
cache  elasticsearch  generated-bundles  javaprefs  keystores  log   orient	 restore-from-backup
bash-4.4$ exit
exit

(28)其他方式的nexus部署

可以参考本人博客:

持续集成交付CICD:CentOS 7 安装 Nexus 3.63-CSDN博客

二、问题

1.volumeMode有哪几种模式

(1)分类

针对 PV 持久卷,Kubernetes 支持两种卷模式(volumeModes):Filesystem(文件系统) 和 Block(块)。
volumeMode 是一个可选的 API 参数。 如果该参数被省略,默认的卷模式是 Filesystem。
volumeMode 属性设置为 Filesystem 的卷会被 Pod 挂载(Mount) 到某个目录。 如果卷的存储来自某块设备而该设备目前为空,Kuberneretes 会在第一次挂载卷之前 在设备上创建文件系统。


http://www.mrgr.cn/p/57326465

相关文章

idea2023去除方法烦人提示

如果你遇到这样的问题请看 再看 已经没有了 我的idea版本

netstat tasklist taskkill配合使用

1.查找指定的端口号:netstat -ano | findstr 端口号 2.查找指定的进程号对应的程序名:tasklist /FI "PID eq 进程号" ,/FI "筛选器 eq 对应的值 " 或者 tasklist | findstr 进程号 或者 3.杀死指定进程:taskkill /t /f /pid 进程号

Centos的一些基础命令

CentOS是一个基于开源代码构建的免费Linux发行版&#xff0c;它由Red Hat Enterprise Linux (RHEL) 的源代码重新编译而成。由于 CentOS是基于RHEL构建的&#xff0c;因此它与RHEL具有非常类似的特性和功能&#xff0c;包括稳定性、安全性和可靠性。并且大部分的 Linux 命令在C…

Github 2024-04-26 开源项目日报 Top10

根据Github Trendings的统计,今日(2024-04-26统计)共有10个项目上榜。根据开发语言中项目的数量,汇总情况如下: 开发语言项目数量Python项目5TypeScript项目2PowerShell项目1Rust项目1Jupyter Notebook项目1C++项目1系统设计指南 创建周期:2507 天开发语言:Python协议类型…

GitOps 和 DevOps 有什么区别?

GitLab 是一个全球知名的一体化 DevOps 平台&#xff0c;很多人都通过私有化部署 GitLab 来进行源代码托管。极狐GitLab &#xff1a;https://gitlab.cn/install?channelcontent&utm_sourcecsdn 是 GitLab 在中国的发行版&#xff0c;专门为中国程序员服务。可以一键式部署…

支付宝JavaScript跳转领取红包

支付宝JavaScript跳转领取红包代码如下<!DOCTYPE html> <html> <head><title>赚钱红包</title><meta charset="utf-8"><meta name="wechat-enable-text-zoom-em" content="true"><meta http-equiv…

k8s pod 无法启动一直ContainerCreating

情况如下&#xff0c;更新 pod 时&#xff0c;一直在ContainerCreating 查看详细信息如下 Failed to create pod sandbox: rpc error: code Unknown desc [failed to set up sandbox container “334d991a478b9640c66c67b46305122d7f0eefc98b2b4e671301f1981d9b9bc6” networ…

Linux网络管理

一、Docker网络概念 1、网络驱动 Docker 网络子系统使用可插拔的驱动,默认情况下有多个驱动程序,并提供核心联网功能。bridge:桥接网络,这是默认的网络驱动程序(不指定驱动程序创建的容器默认是 bridge驱动)。 host:主机网络。消除容器和主机的网络隔离,直接使用主机的…

ABS8-ASEMI新能源专用整流桥ABS8

ABS8-ASEMI新能源专用整流桥ABS8编辑:ll ABS8-ASEMI新能源专用整流桥ABS8 型号:KBL410 品牌:ASEMI 封装:ABS-4 最大重复峰值反向电压:800V 最大正向平均整流电流(Vdss):1A 功率(Pd):小功率 芯片个数:4 引脚数量:4 类型:贴片整流桥、迷你整流桥 正向浪涌电流:30A 正向…

如何通过文件下发平台,让数据发挥其真正的价值?

银行网点文件下发平台是专门设计用于银行系统内部或与外部机构之间安全、高效地传输和分发文件的系统。目前使用较多的方式是FTP、邮件、物理媒介等,但都存在一定问题: 1、物理媒介:如U盘、光盘等,通过快递服务发送给分支机构,确保物理媒介在传输过程中的安全。但容易出现…

kafka脑图总结

Kafka用途削峰于承接超出业务系统处理能力的请求缓冲作为缓冲层,解决生产消息和消费消息速度不一致的情况异步快读响应用户的操作,减少服务请求的响应时间解耦作为一个接口层,针对数据编程即可获取扩展能力冗余消息数据能够采用一对多的方式,供多个业务使用。健壮性能够堆积…

CMake+qt+Visual Studio

#使用qt Creator 创建Cmake 项目,使用Cmake Gui 生成sln 工程&#xff0c;使用Visual Studio 开发 ##使用qt Creator 创建CMake项目 和创建pro工程的步骤一致&#xff0c;只是在选择构建系统的步骤上选择CMake,接下来步骤完全相同 工程新建完成之后&#xff0c;构建cmake 项…

ClkLog实践中的挑战:如何设计和实施有效的埋点指标

埋点的学名应该叫做事件追踪(Event Tracking),它主要是针对特定用户行为或事件进行捕获、处理和发送的相关技术及其实施过程。 埋点是为了满足快捷、高效、丰富的数据应用而做的用户行为过程及结果记录。埋点所采集的数据可以分析网站/APP的使用情况,用户行为习惯等,是建立…

MyBatis 动态 SQL 最全教程,这样写 SQL 太优雅了!

一、MyBatis动态 sql 是什么 动态 SQL 是 MyBatis 的强大特性之一。在 JDBC 或其它类似的框架中,开发人员通常需要手动拼接 SQL 语句。根据不同的条件拼接 SQL 语句是一件极其痛苦的工作。 例如,拼接时要确保添加了必要的空格,还要注意去掉列表最后一个列名的逗号。而动态 S…

【Qt 专栏】Qt:SQLite数据库操作示例

转载自:https://blog.csdn.net/qq_40344790/article/details/129521573 作者:DevFrank (CSDN C/C++ 优质创作者) 1. sqlite介绍 SQLite 是一种轻量级的嵌入式关系型数据库管理系统,它是一个开源的、零配置的、自包含的、事务性的 SQL 数据库引擎。SQLite 的设计目标是简单…

SQL Server实战二:创建、修改、复制、删除数据库表并加以数据处理

本文介绍基于Microsoft SQL Server软件,实现数据库表的创建、修改、复制、删除与表数据处理的方法~本文介绍基于Microsoft SQL Server软件,实现数据库表的创建、修改、复制、删除与表数据处理的方法。 目录1 交互式创建数据库表T2 交互式创建数据库表S3 T-SQL创建数据库表C4 …

OpenStack云计算(十)——OpenStack虚拟机实例管理,增加一个计算节点并进行实例冷迁移,增加一个计算节点的步骤,实例冷迁移的操作方法

项目实训一 本实训任务对实验环境要求较高&#xff0c;而且过程比较复杂&#xff0c;涉及的步骤非常多&#xff0c;有一定难度&#xff0c;可根据需要选做。可以考虑改为直接观看相关的微课视频 【实训题目】 增加一个计算节点并进行实例冷迁移 【实训目的】 熟悉增加一个…

node学习

1 走的是commenJs的规范(模块儿化)a.js<a 每个都有自己的模块,都有作用域<b 在模块儿内modul变量都代表自己本身<c modul.exports提供对外接口require语法 /代表绝对路径,./代表相对路径默认后缀:js json noderequire(http) ——》对应node_modules 2 有一…

集池库:新时代上班族兼职的新选择

近年来,互联网的迅猛发展为个人提供了诸多机遇,使他们能够通过发掘自身技能并在网络上拓展收入渠道。在这个充满活力的数字时代,我也深感这种变革所带来的机会。首先,互联网时代提供了许多平台和机会来实现灵活的兼职工作。例如,网络直播平台是一个热门的选择。通过直播平…