首页 > 其他分享 >k8s ratel一键部署

k8s ratel一键部署

时间:2023-01-08 21:45:19浏览次数:59  
标签:ratel Kubernetes RATEL 一键 yaml HOME k8s

Ratel是一个Kubernetes多集群资源管理平台,基于管理Kubernetes的资源开发,

可以管理Kubernetes的Deployment、DaemonSet、StatefulSet、Service、Ingress、Pods、Nodes、CronJob等。

也可以管理Kubernetes的Role、ClusterRole、Rolebinding、ClusterRoleBinding、Secret、ConfigMap、PV、PVC等。

立志于基于图形界面管理所有的Kubernetes的资源。

同时具备了一些常用的功能,比如跨集群资源复制、一键项目迁移、图形化资源编辑、资源一键回滚及更新、一键式用户权限管理等,

并且具备K8s不具备的功能,比如ConfigMap和Secret备份功能。

Ratel 持续更新GitHub

#!/bin/bash
RATEL_HOME=/root/Ratel
mkdir -p ${RATEL_HOME}
cd ${RATEL_HOME}
cp ~/.kube/config ${RATEL_HOME}/kube.conf
RATEL_ADDR=`cat ${RATEL_HOME}/kube.conf  | grep server | awk -F'[ :/]+' '{print $4}'`

cat > servers.yaml <<EOF
- serverName: 'Wk8s'
  serverAddress: 'https://${RATEL_ADDR}:8443'
  serverAdminToken: 'null'
  serverDashboardUrl: "https://k8s.Wk8s.com.cn/#"
  production: 'false'
  kubeConfigPath: "/mnt/kube.conf"
EOF

cat > ratel-rbac.yaml <<EOF
apiVersion: v1
items:
- apiVersion: rbac.authorization.k8s.io/v1
  kind: ClusterRole
  metadata:
    annotations:
      rbac.authorization.kubernetes.io/autoupdate: "true"
    labels:
      kubernetes.io/bootstrapping: rbac-defaults
      rbac.authorization.k8s.io/aggregate-to-edit: "true"
    name: ratel-namespace-readonly
  rules:
  - apiGroups:
    - ""
    resources:
    - namespaces
    verbs:
    - get
    - list
    - watch
  - apiGroups:
    - metrics.k8s.io
    resources:
    - pods
    verbs:
    - get
    - list
    - watch
- apiVersion: rbac.authorization.k8s.io/v1
  kind: ClusterRole
  metadata:
    name: ratel-pod-delete
  rules:
  - apiGroups:
    - ""
    resources:
    - pods
    verbs:
    - get
    - list
    - delete
- apiVersion: rbac.authorization.k8s.io/v1
  kind: ClusterRole
  metadata:
    name: ratel-pod-exec
  rules:
  - apiGroups:
    - ""
    resources:
    - pods
    - pods/log
    verbs:
    - get
    - list
  - apiGroups:
    - ""
    resources:
    - pods/exec
    verbs:
    - create
- apiVersion: rbac.authorization.k8s.io/v1
  kind: ClusterRole
  metadata:
    annotations:
      rbac.authorization.kubernetes.io/autoupdate: "true"
    name: ratel-resource-edit
  rules:
  - apiGroups:
    - ""
    resources:
    - configmaps
    - persistentvolumeclaims
    - services
    - services/proxy
    verbs:
    - patch
    - update
  - apiGroups:
    - apps
    resources:
    - daemonsets
    - deployments
    - deployments/rollback
    - deployments/scale
    - statefulsets
    - statefulsets/scale
    verbs:
    - patch
    - update
  - apiGroups:
    - autoscaling
    resources:
    - horizontalpodautoscalers
    verbs:
    - patch
    - update
  - apiGroups:
    - batch
    resources:
    - cronjobs
    - jobs
    verbs:
    - patch
    - update
  - apiGroups:
    - extensions
    resources:
    - daemonsets
    - deployments
    - deployments/rollback
    - deployments/scale
    - ingresses
    - networkpolicies
    verbs:
    - patch
    - update
  - apiGroups:
    - networking.k8s.io
    resources:
    - ingresses
    - networkpolicies
    verbs:
    - patch
    - update
- apiVersion: rbac.authorization.k8s.io/v1
  kind: ClusterRole
  metadata:
    name: ratel-resource-readonly
  rules:
  - apiGroups:
    - ""
    resources:
    - configmaps
    - endpoints
    - persistentvolumeclaims
    - pods
    - replicationcontrollers
    - replicationcontrollers/scale
    - serviceaccounts
    - services
    verbs:
    - get
    - list
    - watch
  - apiGroups:
    - ""
    resources:
    - bindings
    - events
    - limitranges
    - namespaces/status
    - pods/log
    - pods/status
    - replicationcontrollers/status
    - resourcequotas
    - resourcequotas/status
    verbs:
    - get
    - list
    - watch
  - apiGroups:
    - ""
    resources:
    - namespaces
    verbs:
    - get
    - list
    - watch
  - apiGroups:
    - apps
    resources:
    - controllerrevisions
    - daemonsets
    - deployments
    - deployments/scale
    - replicasets
    - replicasets/scale
    - statefulsets
    - statefulsets/scale
    verbs:
    - get
    - list
    - watch
  - apiGroups:
    - autoscaling
    resources:
    - horizontalpodautoscalers
    verbs:
    - get
    - list
    - watch
  - apiGroups:
    - batch
    resources:
    - cronjobs
    - jobs
    verbs:
    - get
    - list
    - watch
  - apiGroups:
    - extensions
    resources:
    - daemonsets
    - deployments
    - deployments/scale
    - ingresses
    - networkpolicies
    - replicasets
    - replicasets/scale
    - replicationcontrollers/scale
    verbs:
    - get
    - list
    - watch
  - apiGroups:
    - policy
    resources:
    - poddisruptionbudgets
    verbs:
    - get
    - list
    - watch
  - apiGroups:
    - networking.k8s.io
    resources:
    - networkpolicies
    - ingresses
    verbs:
    - get
    - list
    - watch
  - apiGroups:
    - metrics.k8s.io
    resources:
    - pods
    verbs:
    - get
    - list
    - watch
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""
EOF

cat > ratel-rbac-binding.yaml <<EOF
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: ratel-namespace-readonly-sa
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: ratel-namespace-readonly
subjects:
- apiGroup: rbac.authorization.k8s.io
  kind: Group
  name: system:serviceaccounts:kube-users
EOF

cat > ratel.yaml <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: ratel
  name: ratel
  namespace: kube-system
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ratel
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: ratel
    spec:
      containers:
        - command:
            - sh
            - -c
            - ./ratel -c /mnt/servers.yaml
          env:
            - name: TZ
              value: Asia/Shanghai
            - name: LANG
              value: C.UTF-8
            - name: ProRunMode
              value: prod
            - name: ADMIN_USERNAME
              value: admin
            - name: ADMIN_PASSWORD
              value: ratel_password
          image: registry.cn-beijing.aliyuncs.com/dotbalo/ratel:latest
          imagePullPolicy: Always
          livenessProbe:
            failureThreshold: 2
            initialDelaySeconds: 10
            periodSeconds: 60
            successThreshold: 1
            tcpSocket:
              port: 8888
            timeoutSeconds: 2
          name: ratel
          ports:
            - containerPort: 8888
              name: web
              protocol: TCP
          readinessProbe:
            failureThreshold: 2
            initialDelaySeconds: 10
            periodSeconds: 60
            successThreshold: 1
            tcpSocket:
              port: 8888
            timeoutSeconds: 2
          resources:
            limits:
              cpu: 500m
              memory: 512Mi
            requests:
              cpu: 500m
              memory: 512Mi
          volumeMounts:
            - mountPath: /mnt
              name: ratel-config
      dnsPolicy: ClusterFirst
      imagePullSecrets:
        - name: myregistrykey
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
        - name: ratel-config
          secret:
            defaultMode: 420
            secretName: ratel-config
EOF

cat > service.yaml <<EOF
apiVersion: v1
kind: Service
metadata:
  labels:
    app: ratel
  name: ratel
  namespace: kube-system
spec:
  ports:
    - name: container-1-web-1
      port: 8888
      protocol: TCP
      targetPort: 8888
  selector:
    app: ratel
  type: NodePort
EOF

kubectl create secret generic ratel-config  --from-file=kube.conf --from-file=servers.yaml -n kube-system
kubectl create ns kube-users
kubectl create -f ratel-rbac.yaml
kubectl create -f ratel-rbac-binding.yaml
kubectl create -f ratel.yaml 
kubectl create -f service.yaml

RATEL_PORT=`kubectl get svc -A | grep ratel | awk -F'[ :/]+' '{print $7}'`
RATEL_ADDR=`cat kube.conf  | grep server | awk -F'[ :/]+' '{print $4}'`
kubectl get svc -n kube-system ratel
kubectl get pod -n kube-system | grep -E 'STATUS|ratel'

echo -n "             


                      ratel login address: http://${RATEL_ADDR}${RATEL_PORT}

                      Username: admin

                      Password: ratel_password"

标签:ratel,Kubernetes,RATEL,一键,yaml,HOME,k8s
From: https://www.cnblogs.com/chuyiwang/p/17035491.html

相关文章

  • [kubernetes]二进制部署k8s集群
    0.前言采用二进制部署三主三工作节点的k8s集群,工作节点和Master节点共用服务器,因此只用到了三台服务器。master采用haproxy+keepalive实现高可用。实际生产环境中,建议......
  • k8s网络与办公网络互通
     kubernetes的网络模型中,基于官方默认的CNI网络插件Flannel,这种OverlayNetwork(覆盖网络)可以轻松的实现pod间网络的互通。当我们把基于springcloud的微服务迁移......
  • Kubernetes(k8s) kubectl config常用命令
    kubectl在$HOME/.kube目录中查找一个名为config的配置文件。可以通过设置KUBECONFIG环境变量或设置--kubeconfig参数来指定其它kubeconfig文件。本文主要介绍K......
  • .Net Core 商城微服务项目系列(十二):使用k8s部署商城服务
    原文网址:https://www.bbsmax.com/A/Ae5RRDeN5Q/一、简介本篇我们将会把商城的服务部署到k8s中,同时变化的还有以下两个地方:1.不再使用Consul做服务的注册和发现,转而使用k......
  • Kubernetes初探[1]:部署您的第一个ASP.NET Core应用到k8s集群
    原文网址:http://www.manongjc.com/detail/41-lgbqyltuzalhfxg.htmlKubernetes简介Kubernetes是Google基于Borg开源的容器编排调度引擎,作为CNCF(CloudNativeComputingFo......
  • Net Core 微服务 - 如何将.Net Core Web Api服务部署到Kubernetes (K8s)中 转载
    原文网址:https://blog.51cto.com/u_15127693/43566721.新建一个WebApi项目 默认的webapi项目包含一个默认的api:/weatherforecast  2.新建一个Dockerfile文件 ......
  • k8s教程(pod篇)-总结
    文章目录​​01引言​​​​02总结​​​​2.1定义与基本用法​​​​2.2容器共享volume​​​​2.3配置管理​​​​2.4容器获取pod信息(DownwardAPI)​​​​......
  • 【云原生】Ceph 在 k8s中应用
    目录一、概述二、CephRook介绍三、通过Rook在k8s中部署Ceph1)下载部署包2)部署RookOperator3)创建RookCeph集群4)部署RookCeph工具5)部署CephDashboard6)检查6)通过ceph......
  • K8s 为什么会抛弃 docker
    为什么K8s会抛弃docker前言CRIcontainerd参考为什么K8s会抛弃docker前言在这之前先来了解下,k8s是如何和docker进行交互的。CRIkubelet调用下层容......
  • k8s 1.22.10 Ingress-nginx 的部署
    1.创建ingressingress-nginx/index.mdatcontroller-v1.1.3·kubernetes/ingress-nginx(github.com)源文件地址:ingress-nginx/index.mdatcontroller-v1.1.3·ku......