zoukankan      html  css  js  c++  java
  • k8s搭建web界面管理rancher

    rancher部署

    一、准备介质

    镜像v2.4.17

    docker pull rancher/rancher:v2.4.17
    

    二、使用docker安装

    点击查看代码
     docker run -d --restart=unless-stopped -p 80:80 -p 443:443 \
     -v /home/ap/aipf/rancher_home/rancher:/var/lib/rancher \
     -v /home/ap/aipf/rancher_home/auditlog:/var/log/auditlog \
     --name rancher rancher/rancher:v2.4.17
    

    访问本机ip

    三、使用k8s部署rancher

    3.1、创建namespace

    kubectl create ns rancher
    

    3.2、创建rancher的存储路径pv/pvc

    点击查看代码
    ---
    apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: pv-rancher
      namespace: rancher
    spec:
      capacity:
        storage: 20Gi
      accessModes:
      - ReadWriteMany
      persistentVolumeReclaimPolicy: Retain
      storageClassName: local-storage
      local:
        path: /home/ap/nas_b
      nodeAffinity:
        required:
          nodeSelectorTerms:
          - matchExpressions:
            - key: kubernetes.io/hostname
              operator: In
              values:
              - k8s-master
    ---
    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      name: pvc-rancher
      namespace: rancher
    spec:
      accessModes:
       - ReadWriteMany
      storageClassName: local-storage
      resources:
        requests:
          storage: 15Gi
    

    3.3、创建rancher的配置文件

    点击查看代码
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      labels:
        app: rancher
      name: rancher
      namespace: rancher
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: rancher
      template:
        metadata:
          labels:
            app: rancher
          containers:
          - image: rancher/rancher:v2.4.17
            imagePullPolicy: IfNotPresent
            name: rancher
            envFrom:
            - configMapRef:
                name: ai-platform-config
            ports:
            - containerPort: 80
            volumeMounts:
            - mountPath: /var/lib/rancher
              name: ai-rancher-volumes
              subPath: rancher_home/rancher
            - mountPath: /var/log/auditlog
              name: ai-rancher-volumes
              subPath: rancher_home/auditlog
    
          volumes:
          - name: ai-rancher-volumes
            persistentVolumeClaim:
              claimName: pvc-rancher
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: rancher
      labels:
        app: rancher
      namespace: rancher
    spec:
      type: ClusterIP
      selector:
        app: ai-admin-web
      ports:
      - port: 80
        targetPort: 80
    
    
    注意:k8s集群多的时候,配置文件可以添加标签指定rancherd pod启动到固定节点上 也可以搭建harbor 拉取镜像从harbor获取 第一次启动rancher可以挂载目录为空,需要你这边使用docker启动后,在吧数据拷贝进去,然后在重启
    点击查看代码
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      labels:
        app: rancher
      name: rancher
      namespace: rancher
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: rancher
      template:
        metadata:
          labels:
            app: rancher
        spec:
          nodeSelector:
            rancherbase: "true"
          containers:
          - image: rancher.harbor.io/rancher/rancher:v2.4.17
            imagePullPolicy: IfNotPresent
            name: rancher
            envFrom:
            - configMapRef:
                name: ai-platform-config
            ports:
            - containerPort: 80
            volumeMounts:
            - mountPath: /var/lib/rancher
              name: ai-rancher-volumes
              subPath: rancher_home/rancher
            - mountPath: /var/log/auditlog
              name: ai-rancher-volumes
              subPath: rancher_home/auditlog
    
          volumes:
          - name: ai-rancher-volumes
            persistentVolumeClaim:
              claimName: pvc-rancher
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: rancher
      labels:
        app: rancher
      namespace: rancher
    spec:
      type: ClusterIP
      selector:
        app: ai-admin-web
      ports:
      - port: 80
        targetPort: 80
    
    
    ![](https://img2020.cnblogs.com/blog/1461308/202112/1461308-20211220164832096-358264527.png)

    3.4、使用上面的配置文件启动rancher服务

    [root@k8s-master conf]# kubectl apply -f rancher-pv.yaml 
    persistentvolume/pv-rancher created
    persistentvolumeclaim/pvc-rancher created
    
    [root@k8s-master conf]# kubectl get pv,pvc -A | grep rancher
    persistentvolume/pv-rancher   20Gi       RWX            Retain           Bound    rancher/pvc-rancher     local-storage            79s
    rancher       persistentvolumeclaim/pvc-rancher   Bound    pv-rancher   20Gi       RWX            local-storage   79s
    

    3.5、启动rancher服务

    [root@k8s-master conf]# kubectl apply -f rancher.yaml 
    deployment.apps/rancher created
    service/rancher created
    
  • 相关阅读:
    微软企业库4.1学习笔记(二十六)Unity依赖注入模块3
    微软企业库4.1学习笔记(三十七)日志模块 在应用中使用日志模块
    微软企业库5.0学习笔记(三十五)数据访问模块 DataSet以及数据库事务
    微软企业库4.1学习笔记(四十一)依赖注入模块Unity 简介
    项目统一开发管理解决方案思路[项目组成员同时做很多项目的解决思路探讨]
    在moss2007WEB应用服务器上发布独立web程序时遇到的问题的解决思路
    工作流表单自定义的误区
    文档库创建的子文件夹的URL显示为 http://[机器名]/.... 导致无法正常访问的问题解决办法
    申请加入 .NET企业应用开发 博客团队请回复
    儿子照片
  • 原文地址:https://www.cnblogs.com/pythonx/p/15711816.html
Copyright © 2011-2022 走看看