首页 > 其他分享 >k8s安装并迁移jumpserver

k8s安装并迁移jumpserver

时间:2024-09-25 18:56:11浏览次数:8  
标签:name jms redis jumpserver mysql 迁移 k8s

一、环境

k8s安装并迁移jumpserver_redis

二、安装依赖服务

以下操作按需操作

1.安装Helm

wget  https://get.helm.sh/helm-v3.12.1-linux-amd64.tar.gz
tar xf  helm-v3.12.1-linux-amd64.tar.gz
mv linux-amd64/helm /usr/local/bin/
helm version
helm repo add jumpserver https://jumpserver.github.io/helm-charts  #添加jumpserver chart仓库
helm repo list

2.修改github解析

访问https://sites.ipaddress.com/github.com/#ipinfo获取github.com最新解析IP并配置部署机器hosts文件

140.82.113.3    github.com #如果不行访问该网站https://ping.chinaz.com/github.com挑选响应最快的IP

k8s安装并迁移jumpserver_redis_02

 

3.安装MySQL

namespace

kubectl create namespace jumpserver

pvc.yaml(storageClass根据实际情况修改)

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  annotations:
    volume.beta.kubernetes.io/storage-provisioner: nasplugin.csi.alibabacloud.com
  name: mysql-data
  namespace: jumpserver
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 50Gi
  storageClassName: alicloud-disk-nas

config.yaml

kind: ConfigMap
apiVersion: v1
metadata:
  name: mysql-config
  namespace: jumpserver
data:
  my.cnf: |-
    [mysqld]

    skip-host-cache
    skip-name-resolve
    datadir=/var/lib/mysql
    socket=/var/run/mysqld/mysqld.sock
    secure-file-priv=/var/lib/mysql-files
    user=mysql
    symbolic-links=0
    pid-file=/var/run/mysqld/mysqld.pid
    [client]
    socket=/var/run/mysqld/mysqld.sock

    !includedir /etc/mysql/conf.d/
    !includedir /etc/mysql/mysql.conf.d/

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: jumpserver-mysql
  namespace: jumpserver
spec:
  selector:
    matchLabels:
      app: mysql-5.7
  template:
    metadata:
      labels:
        app: mysql-5.7
    spec:
      containers:
      - name: mysql
        image: mysql:5.7.42
        env:                        
        - name: MYSQL_ROOT_PASSWORD
          value: "System@123"
        ports:
        - containerPort: 3306
        volumeMounts:
        - name: mysql-data
          mountPath: /var/lib/mysql         
          subPath: mysql
        - name: config
          mountPath:  /etc/my.cnf
          subPath: my.cnf
      volumes:
      - name: mysql-data
        persistentVolumeClaim:
          claimName: mysql-data
      - name: config
        configMap:
          name: mysql-config

svc.yaml

apiVersion: v1
kind: Service
metadata:
  labels:
    app: jumpserver-mysql-svc
  name: jumpserver-mysql-svc
  namespace: jumpserver
spec:
  ports:
  - name: tcp-mysql-3306
    nodePort: 30306
    port: 3306
    protocol: TCP
    targetPort: 3306
  selector:
    app: mysql-5.7
  type: NodePort

部署后创建数据库

kubectl get pods -n jumpserver -o wide
mysql -uroot -h 172.17.0.5 -p
CREATE DATABASE IF NOT EXISTS jumpserver DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_general_ci;

4.安装Redis

pvc.yaml 

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  annotations:
    volume.beta.kubernetes.io/storage-provisioner: nasplugin.csi.alibabacloud.com
  name: redis-data
  namespace: jumpserver
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 20Gi
  storageClassName: alicloud-disk-nas

config.yaml 

apiVersion: v1
data:
  redis.conf: |-
    bind 0.0.0.0
    port 6379
    requirepass System@123
    pidfile /var/run/redis_6379.pid
    save 900 1
    save 300 10
    save 60 10000
    rdbcompression yes
    rdbchecksum yes
    dbfilename dump.rdb
    appendonly yes
    appendfilename "appendonly.aof"
    appendfsync everysec
    dir /data
    logfile "/data/redis-6379.log"
kind: ConfigMap
metadata:
  name: redis-config
  namespace: jumpserver

deployment.yaml 

apiVersion: apps/v1
kind: Deployment
metadata:
  name: jumpserver-redis
  namespace: jumpserver
spec:
  replicas: 1
  selector:
    matchLabels:
      app: jumpserver-redis
  template:
    metadata:
      labels:
        app: jumpserver-redis
    spec:
      containers:
      - image: redis:6.0.9
        command: ["redis-server","/etc/redis/redis.conf"]
        name: redis
        ports:
        - containerPort: 6379        
        volumeMounts:
        - name: redis-config
          mountPath: /etc/redis/redis.conf
          subPath: redis.conf
        - name: redis-data
          mountPath: /data
      volumes:
      - name: redis-config
        configMap:
          name: redis-config
      - name: redis-data
        persistentVolumeClaim:
          claimName: redis-data

svc.yaml

apiVersion: v1
kind: Service
metadata:
  labels:
    app: jumpserver-redis-svc
  name: jumpserver-redis-svc
  namespace: jumpserver
spec:
  ports:
  - name: tcp-redis-6379
    port: 6379
    protocol: TCP
    targetPort: 6379
  selector:
    app: jumpserver-redis

三、修改配置

1.下载配置

wget https://raw.githubusercontent.com/jumpserver/helm-charts/main/charts/jumpserver/values.yaml

2.修改镜像仓库地址

k8s安装并迁移jumpserver_github_03

3.配置SC

k8s安装并迁移jumpserver_redis_04

k8s安装并迁移jumpserver_redis_05

4.配置MySQL和Redis

k8s安装并迁移jumpserver_mysql_06

5.配置ingress hosts

k8s安装并迁移jumpserver_mysql_07

6.配置秘钥

k8s安装并迁移jumpserver_redis_08

其余配置按需修改

四、部署jumpserver

helm install jms-k8s jumpserver/jumpserver -n jumpserver -f values.yaml

[root@iZbp10kr3w2ijv03yu6htrZ jumpserver]# helm -n jumpserver ls -a
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
jms-k8s jumpserver 1 2023-07-13 11:50:39.910210139 +0800 CST deployed jumpserver-3.4.3 v3.4.3

[root@iZbp10kr3w2ijv03yu6htrZ jumpserver]# kubectl get pods -n jumpserver
NAME READY STATUS RESTARTS AGE
jms-k8s-jumpserver-jms-celery-59d99c46b6-mg9z4 1/1 Running 0 67s
jms-k8s-jumpserver-jms-core-5c6c75c5df-c7fl7 1/1 Running 0 67s
jms-k8s-jumpserver-jms-koko-77db949f7d-cb9hk 1/1 Running 0 67s
jms-k8s-jumpserver-jms-lion-58b9f94fb8-7hmp7 1/1 Running 0 67s
jms-k8s-jumpserver-jms-magnus-6df6755469-6hml5 1/1 Running 0 67s
jms-k8s-jumpserver-jms-web-7b6c46b6c4-hsjg9 1/1 Running 0 67s
jumpserver-mysql-77656bd48-svkb9 1/1 Running 0 24h
jumpserver-redis-75898bdd9-rs8kg 1/1 Running 0 24h

五、登录验证

访问ingress域名(绑定hosts或者配置NDS解析)
登录用户密码:admin/admin
如果只是搭建那么此时就完成了

六、导入原数据库数据到新数据库

由于我的服务都在阿里云所以这里使用阿里云的DTS服务的数据迁移功能(免费),本地可以使用mysqldump或其他工具

七、重启服务

kubectl delete pods -n jumpserver  -l app.kubernetes.io/name=jumpserver

八解决报错

1.报错内容

{"error":"service account registration disabled"}

k8s安装并迁移jumpserver_mysql_09

2.解决方法

登录jumpserver(用户、密码、MFA与原jumpserver一致),系统设置--安全设置--终端注册

k8s安装并迁移jumpserver_github_10

3.重启报错应用

for i in `kubectl get deployments.apps -n jumpserver|awk '/0\/1/  {print $1}'` ;do kubectl scale deployment ${i} --replicas=0 -n  jumpserver;done
for i in `kubectl get deployments.apps -n jumpserver|awk '/0\/0/  {print $1}'` ;do kubectl scale deployment ${i} --replicas=1 -n  jumpserver;done
root@iZbp10kr3w2ijv03yu6htrZ ~]# kubectl get pods -n jumpserver -o wide
NAME                                             READY   STATUS    RESTARTS   AGE   IP             NODE                     NOMINATED NODE   READINESS GATES
jms-k8s-jumpserver-jms-celery-59d99c46b6-88r88   1/1     Running   0          14m   172.17.1.146   cn-hangzhou.10.1.6.116   <none>           <none>
jms-k8s-jumpserver-jms-core-5c6c75c5df-k7tmb     1/1     Running   0          14m   172.17.1.157   cn-hangzhou.10.1.6.116   <none>           <none>
jms-k8s-jumpserver-jms-koko-77db949f7d-dqs9v     1/1     Running   0          76s   172.17.1.160   cn-hangzhou.10.1.6.116   <none>           <none>
jms-k8s-jumpserver-jms-lion-58b9f94fb8-br54f     1/1     Running   0          76s   172.17.0.58    cn-hangzhou.10.1.8.212   <none>           <none>
jms-k8s-jumpserver-jms-magnus-6df6755469-vtc9x   1/1     Running   0          7s    172.17.0.60    cn-hangzhou.10.1.8.212   <none>           <none>
jms-k8s-jumpserver-jms-web-7b6c46b6c4-j9xnr      1/1     Running   0          14m   172.17.1.148   cn-hangzhou.10.1.6.116   <none>           <none>

4.控制台确认并删除无效终端应用

k8s安装并迁移jumpserver_redis_11

至此所以操作完毕

参考文档:

在线安装文档:https://docs.jumpserver.org/zh/v3/installation/

chart文档:https://github.com/jumpserver/helm-charts/

"一劳永逸" 的话,有是有的,而 "一劳永逸" 的事却极少



标签:name,jms,redis,jumpserver,mysql,迁移,k8s
From: https://blog.51cto.com/u_8901540/12111434

相关文章

  • jumpserver V2自动同步、更新阿里云资产
    一、注意事项1.1 注意替换资产模板中nodes值,可以通过数据库assets_node表中获取,或者使用jumpserver脚本获取资产信息查看1.2requirements.txtaliyun-python-sdk-core==2.13.36aliyun-python-sdk-ecs==4.24.30aliyunsdkcore==1.0.3requests==2.28.2urllib3==1.26.14PyMySQL......
  • jumpserver API调试
    一、获取认证token由于我是docker,这里我只演示docker方式,其他方式类似dockerexec-itjms_core/bin/bash#进入core服务cd/opt/jumpserver/appspythonmanage.pyshellfromusers.modelsimportUseru=User.objects.get(username='admin')u.create_private_token()......
  • 大模型训练:K8s 环境中数千节点存储最佳实践
    今天这篇博客来自全栈工程师朱唯唯,她在前不久举办的KubeCon中国大会上进行了该主题分享。Kubernetes已经成为事实的应用编排标准,越来越多的应用在不断的向云原生靠拢。与此同时,人工智能技术的迅速发展,尤其是大型语言模型(LLM)的推进,导致企业需要处理的数据量急剧增加,例如,Llama......
  • 作为一名测试工程师如何学习Kubernetes(k8s)技能
    前言Kubernetes(K8s)作为云原生时代的关键技术之一,对于运维工程师、开发工程师以及测试工程师来说,都是一门需要掌握的重要技术。作为一名软件测试工程师,学习Kubernetes是一个有助于提升自动化测试、容器化测试以及云原生应用测试能力的重要过程。以下是一个系统性的学习路径......
  • 腾讯通用户必看:低成本平滑迁移方案,兼容Linux与移动端
    一、腾讯通停更后用户面临的核心问题自从腾讯通(RTX)停止更新并下架官网,许多用户失去了更新和技术支持的途径,同时不得不面对以下几大难题:无法在移动端和Linux系统上使用:腾讯通仅支持Windows和Mac系统,用户无法通过移动设备或Linux系统进行办公,严重影响了日常沟通。组织架构同步不......
  • 腾讯通用户必看:低成本平滑迁移方案,兼容Linux与移动端
    一、腾讯通停更后用户面临的核心问题自从腾讯通(RTX)停止更新并下架官网,许多用户失去了更新和技术支持的途径,同时不得不面对以下几大难题:无法在移动端和Linux系统上使用:腾讯通仅支持Windows和Mac系统,用户无法通过移动设备或Linux系统进行办公,严重影响了日常沟通。组织架构同步不及时:......
  • k8s Ingress和 Ingress Controller
    一、Ingress和IngressController概述关于service四层代理介绍链接点我跳转1.1Ingressingress是k8s中的资源,主要是管理ingress-controller这个代理的配置文件。Ingress是对集群中服务的外部访问进行管理的API对象,典型的访问方式是HTTP,Ingress可以提供负载均衡、SSL终结和基......
  • k8s StorageClass 存储类
    目录一、概述1、StorageClass对象定义2、StorageClassYAML示例二、StorageClass字段1、provisioner(存储制备器)1.1、内置制备器1.2、第三方制备器2、reclaimPolicy(回收策略)3、allowVolumeExpansion(允许卷扩展)4、mountOptions(挂载选项)5、volumeBindingMode(卷绑定模式)5.1、Immedi......
  • k8s 访问一个 外部内部地址 代理到外网 作用是 k8s节点不直接开启外网ip
    nginx服务器访问本地的内网地址怎么代理访问到百度  要通过Nginx服务器代理访问到百度,你可以配置Nginx进行反向代理。以下是配置Nginx反向代理的步骤:安装Nginx:确保你的服务器上已经安装了Nginx。如果尚未安......
  • redis数据库通过dump.rdb文件恢复数据库或者数据库迁移
     环境:centos7.2软件:redis-3.2.10(yum安装)情景一:公司之前的redis没有开启aof模式,一直是rdb模式,但是数据又非常重要,数据一点也不能丢失,所以需要开启aof,但是redis默认是从appendonly.aof加载数据,systemctlstartredis的时候,数据库是空的,因为我们并没有appendonly.aof文件,而且关......