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

k8s安装并迁移jumpserver

时间:2023-07-13 14:55:30浏览次数:42  
标签:name jms redis jumpserver mysql 迁移 k8s

一、环境

二、安装依赖服务

以下操作按需操作

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

 

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.修改镜像仓库地址

3.配置SC

4.配置MySQL和Redis

5.配置ingress hosts

6.配置秘钥

其余配置按需修改

四、部署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或其他工具

七、重启服务

for i in `kubectl get deployments.apps -n jumpserver|awk '/^jms/  {print $1}'` ;do kubectl scale deployment ${i} --replicas=0 -n  jumpserver;done
for i in `kubectl get deployments.apps -n jumpserver|awk '/^jms/  {print $1}'` ;do kubectl scale deployment ${i} --replicas=1 -n  jumpserver;done

八解决报错

1.报错内容

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

2.解决方法

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

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.控制台确认并删除无效终端应用

至此所以操作完毕

参考文档:

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

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

标签:name,jms,redis,jumpserver,mysql,迁移,k8s
From: https://www.cnblogs.com/panwenbin-logs/p/17548238.html

相关文章

  • k8s集群卸载
    k8s集群卸载#重置kubeadmkubeadmresetrm-rf$HOME/kuberm-rf/etc/kubernetes/rm-rf/etc/systemd/system/kubelet.service.drm-rf/etc/systemd/systemrm-rf/etc/systemd/system/kubelet.servcerm-rf/usr/bin/kube*rm-rf/etc/cnirm-rf/opt/cnirm-rf/......
  • k8s 中的卷
    前面的文章我们分享了pod,RC,RS,DaemonSet,CJ,Service等各种资源今天我们来分享一波如何将磁盘挂载到容器中,在docker里面这种技术叫做数据卷,感兴趣的小伙伴可以查看一下文章:【Docker系列】docker学习六,探究一下数据卷容器对于一个pod,他有自己的CPU,RAM,网络接口等资源都是可......
  • Jenkins远程管理K8S集群实现自动POD部署
    Jenkins远程管理K8S集群实现自动POD部署大致思路修改.kube/config文件,增加新集群的context建立隧道将集群控制端口映射到Jenkins服务器本地端口测试jenkin切换到新context是否能控制该集群新集群配置对接Harbor仓库测试helm部署podJenkins测试配置流水线自动发版1.......
  • k8s集群node NotReady处理流程-->kubelet状态error,并伴有报错:kubelet.service has mor
    k8s集群nodeNotReady处理流程-->kubelet状态error//20230712集群有节点NotReadykubelet状态error,并伴有报错:kubelet.servicehasmorethanoneExecStart=setting,whichisonlyallowedforType=oneshotservices.Refusing在此记录一下解决流程解决流程问题定位:使......
  • DHorse v1.2.1 发布,基于k8s的发布平台
    综述DHorse是一个简单易用、以应用为中心的云原生DevOps系统,具有持续集成、持续部署、微服务治理等功能,无需安装依赖Docker、Maven、Node等环境即可发布Java、Vue、React应用,主要特点:部署简单、操作简洁、功能快速。优化内容优化jvm指标收集时dhorse接口地址错误的问题;首次配......
  • K8s概念
    k8s特点自动修复弹性伸缩自动部署和回滚服务发现和负载均衡pod的IP地址会在创建或销毁后变化,故IP地址不固定。就需要一个统一的出口暴露到外部进行访问。service作为统一的出入口,承接外部和内部pod之间的访问。提供服务发现及负载均衡到内部pod的功能......
  • 记一次openSUSE Tumbleweed下安装 k8s
    因为没有K8s基础的坑kubeadmkubelet最好指定版本安装,因为kubelet的版本需要小于等于kubeadm的版本,否则就会报错。运行kubeadminit,不用手动systemctlstartkubelet,因为会报错不满足某某条件。openSUSE的官方的kubernetes-kubelet包安装后,/usr/bin/kubelet只是一个shell脚......
  • Redhat离线安装gitlab,迁移数据,指定数据存放位置
    一、安装gitlab1、安装依赖包yuminstall-ycurlpolicycoreutils-pythonopenssh-serveropenssh-clients#开启sshd服务systemctlenablesshdsystemctlstartsshd 2、下载rpm包并安装如需迁移备份数据,新机器安装gitlab版本需跟旧机器gitlab版本保持一致查看旧机器g......
  • MySQL迁移达梦数据库注意事项
    mysql<—>dmmysql迁移到dm报错【错误消息:不支持该数据类型】mysql迁移到dm报错【错误消息:不支持该数据类型】|达梦技术社区(dameng.com)更改迁移工具DM连接驱动.这个驱动地址在安装包里面有,相对路径为:/drivers/jdbc,可以挑选最新的驱动。不支持直接comment注释创建......
  • Hadoop on k8s 快速部署进阶精简篇
    目录一、概述二、快速部署步骤如下1)安装git2)部署mysql3)创建存储目录(所有节点)4)下载hadoop-on-k8s部署包5)修改hadoopconfigmap6)修改hiveconfigmap(MySQL配置)7)安装helm8)开始部署9)测试验证一、概述前面一篇文章已经很详细的介绍了Hadooponk8s部署了,这里主要针对部署时可......