rancher v2.8.1 如何成功注册已有 k8s 集群

这篇具有很好参考价值的文章主要介绍了rancher v2.8.1 如何成功注册已有 k8s 集群。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

需要加入的集群为rke2部署的双节点集群

$ kubectl get node
NAME           STATUS   ROLES                              AGE   VERSION
rke-master01   Ready    control-plane,etcd,master,worker   94d   v1.26.8+rke2r1
rke-master02   Ready    control-plane,etcd,master,worker   93d   v1.26.8+rke2r1

登陆 rancher
rancher v2.8.1 如何成功注册已有 k8s 集群,rancher,kubernetes,rancher,kubernetes,容器,rke2,云原生

rancher v2.8.1 如何成功注册已有 k8s 集群,rancher,kubernetes,rancher,kubernetes,容器,rke2,云原生

注意:直接执行截图中的命令,不要改动yaml内容。当执行完后注册集群的agent会报错,随后,我们通过
kubectl edit deploy cattle-cluster-agent -n cattle-system命令添加hostAlias,其他方式会注册失败,例如:先修改yaml再apply执行。

格式如下:

      hostAliases:
      - hostnames:
        - rancher02.demo.com
        ip: 192.168.23.80

完整内容:

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: proxy-clusterrole-kubeapiserver
rules:
- apiGroups: [""]
  resources:
  - nodes/metrics
  - nodes/proxy
  - nodes/stats
  - nodes/log
  - nodes/spec
  verbs: ["get", "list", "watch", "create"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: proxy-role-binding-kubernetes-master
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: proxy-clusterrole-kubeapiserver
subjects:
- apiGroup: rbac.authorization.k8s.io
  kind: User
  name: kube-apiserver
---
apiVersion: v1
kind: Namespace
metadata:
  name: cattle-system

---

apiVersion: v1
kind: ServiceAccount
metadata:
  name: cattle
  namespace: cattle-system

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: cattle-admin-binding
  namespace: cattle-system
  labels:
    cattle.io/creator: "norman"
subjects:
- kind: ServiceAccount
  name: cattle
  namespace: cattle-system
roleRef:
  kind: ClusterRole
  name: cattle-admin
  apiGroup: rbac.authorization.k8s.io

---

apiVersion: v1
kind: Secret
metadata:
  name: cattle-credentials-535d46a
  namespace: cattle-system
type: Opaque
data:
  url: "aHR0cHM6Ly9yYW5jaGVyMDIuZGVtby5jb20="
  token: "Z2hwZmJkbHBzbTk1NTJ4cXZuYmQ3NW5yOXA1N3d0ZnN4bGJ2dDd6cmwyY3Zwc3BxbGc5NWY1"
  namespace: ""

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: cattle-admin
  labels:
    cattle.io/creator: "norman"
rules:
- apiGroups:
  - '*'
  resources:
  - '*'
  verbs:
  - '*'
- nonResourceURLs:
  - '*'
  verbs:
  - '*'

---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: cattle-cluster-agent
  namespace: cattle-system
  annotations:
    management.cattle.io/scale-available: "2"
spec:
  selector:
    matchLabels:
      app: cattle-cluster-agent
  template:
    metadata:
      labels:
        app: cattle-cluster-agent
    spec:
      affinity:
        nodeAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - preference:
              matchExpressions:
              - key: node-role.kubernetes.io/controlplane
                operator: In
                values:
                - "true"
            weight: 100
          - preference:
              matchExpressions:
              - key: node-role.kubernetes.io/control-plane
                operator: In
                values:
                - "true"
            weight: 100
          - preference:
              matchExpressions:
              - key: node-role.kubernetes.io/master
                operator: In
                values:
                - "true"
            weight: 100
          - preference:
              matchExpressions:
              - key: cattle.io/cluster-agent
                operator: In
                values:
                - "true"
            weight: 1
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: beta.kubernetes.io/os
                operator: NotIn
                values:
                - windows
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - podAffinityTerm:
              labelSelector:
                matchExpressions:
                - key: app
                  operator: In
                  values:
                  - cattle-cluster-agent
              topologyKey: kubernetes.io/hostname
            weight: 100
      serviceAccountName: cattle
      hostAliases:
      - hostnames:
        - rancher02.demo.com
        ip: 192.168.23.80
      tolerations:
      # No taints or no controlplane nodes found, added defaults
      - effect: NoSchedule
        key: node-role.kubernetes.io/controlplane
        value: "true"
      - effect: NoSchedule
        key: "node-role.kubernetes.io/control-plane"
        operator: "Exists"
      - effect: NoSchedule
        key: "node-role.kubernetes.io/master"
        operator: "Exists"
      containers:
        - name: cluster-register
          imagePullPolicy: IfNotPresent
          env:
          - name: CATTLE_IS_RKE
            value: "false"
          - name: CATTLE_SERVER
            value: "https://rancher02.demo.com"
          - name: CATTLE_CA_CHECKSUM
            value: "d818528e6c91a42ed9573c1cbe4b6e3df067d3ebca8b57efccb8e463306e3760"
          - name: CATTLE_CLUSTER
            value: "true"
          - name: CATTLE_K8S_MANAGED
            value: "true"
          - name: CATTLE_CLUSTER_REGISTRY
            value: ""
          - name: CATTLE_SERVER_VERSION
            value: v2.8.1
          - name: CATTLE_INSTALL_UUID
            value: 26c8f3d4-ad4d-4412-87e6-2f4ecb3ce63c
          - name: CATTLE_INGRESS_IP_DOMAIN
            value: sslip.io
          image: rancher/rancher-agent:v2.8.1
          volumeMounts:
          - name: cattle-credentials
            mountPath: /cattle-credentials
            readOnly: true
      volumes:
      - name: cattle-credentials
        secret:
          secretName: cattle-credentials-535d46a
          defaultMode: 320
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 1

---
apiVersion: v1
kind: Service
metadata:
  name: cattle-cluster-agent
  namespace: cattle-system
spec:
  ports:
  - port: 80
    targetPort: 80
    protocol: TCP
    name: http
  - port: 443
    targetPort: 444
    protocol: TCP
    name: https-internal
  selector:
    app: cattle-cluster-agent

注册成功。如图:
rancher v2.8.1 如何成功注册已有 k8s 集群,rancher,kubernetes,rancher,kubernetes,容器,rke2,云原生文章来源地址https://www.toymoban.com/news/detail-833317.html

到了这里,关于rancher v2.8.1 如何成功注册已有 k8s 集群的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 使用kubekey部署k8s集群和kubesphere、在已有k8s集群上部署kubesphere

    环境: centos 7.6、k8s 1.22.17、kubesphere v3.3.0 本篇以kubesphere v3.3.0版本讲解。 kubesphere 愿景是打造一个以 kubernetes 为内核的云原生分布式操作系统,它的架构可以非常方便地使第三方应用与云原生生态组件进行即插即用(plug-and-play)的集成,支持云原生应用在多云与多集群的统一

    2024年02月04日
    浏览(52)
  • Rancher部署k8s集群

    Rancher是一个开源的企业级容器管理平台。通过Rancher,企业再也不必自己使用一系列的开源软件去从头搭建容器服务平台。Rancher提供了在生产环境中使用的管理Docker和Kubernetes的全栈化容器部署与管理平台。 首先所有节点部署docker 安装docker依赖 yum install wget expect vim net-tools

    2024年02月11日
    浏览(33)
  • 使用 Rancher 安装 K8s 集群

    Ubuntu 22.04.2 LTS Docker 24.0.2 2GB RAM或者更多 CPU 2核心或者更多 Rancher 2.6.9 测试环境中,我准备了两台 Ubuntu 服务器,IP分别是 192.168.10.43 和 192.168.10.42,一台用做 k8s 的 master 节点,一台 note 节点,Rancher 和 master 节点公用一台主机。另外,服务器之间的时间一定要 精准同步 。可以

    2024年02月11日
    浏览(32)
  • K8S:Rancher管理 Kubernetes 集群

    Rancher 是一个开源的企业级多集群 Kubernetes 管理平台,实现了 Kubernetes 集群在混合云+本地数据中心的集中部署与管理, 以确保集群的安全性,加速企业数字化转型。超过 40000 家企业每天使用 Rancher 快速创新。 官网:https://docs.rancher.cn/ Rancher 和 k8s 都是用来作为容器的调度与

    2024年02月07日
    浏览(37)
  • 使用rancher rke快速安装k8s集群

    Rancher Kubernetes Engine(RKE)是一个用于部署、管理和运行Kubernetes集群的开源工具。旨在简化Kubernetes集群的部署和操作。 RKE具有以下特点和功能: 简化的部署过程 RKE提供了一个简单的命令行界面,使您可以轻松地部署一个完整的Kubernetes集群。您只需提供少量的配置信息,RK

    2024年02月05日
    浏览(32)
  • rancher2.6部署k8s集群示例

    博客主页:https://tomcat.blog.csdn.net 博主昵称:农民工老王 主要领域:Java、Linux、K8S 期待大家的关注💖点赞👍收藏⭐留言💬 rancher 2.6已经发布一段时间,与2.5还是有不少变动,而且目前只有英语文档。为了方便大家顺利使用,在此演示下rancher2.6部署k8s集群。 本文是 如何通过

    2023年04月11日
    浏览(24)
  • k8s~RKE的方式升级Rancher集群

    在主机或者远程访问的笔记本上安装kubectl命令行工具 通过RKE创建kubernetes集群,需要预先设置rancher-cluster.yml配置文件,通过这个配置文件安装kubernetes集群,同时可以指定kubernetes的版本。 RKE安装kubernetes集群后,会在RKE二进制文件相同目录下生成kube_config_rancher-cluster.yml文件,

    2024年02月08日
    浏览(34)
  • Rancher创建arm架构的下游k8s集群

    费了些时间在成功在华为云arm架构的服务器上搭建了k8s集群,期间问题不断,以下是三个关键点: 确保网络能正常拉取所需镜像 拉取的镜像需支持arm架构 否则报错:exec /pause: exec format error 集群网络驱动要选择flannel Rancher版本:v2.5.15 Rancher上的具体操作就不细说了,不懂的参

    2024年02月10日
    浏览(31)
  • 使用docker部署rancher并导入k8s集群

    前言:鉴于我已经部署了k8s集群,那就在部署rancher一台用于管理k8s,这是一台单独的虚拟环境,之前在k8s的master节点上进行部署并未成功,有可能端口冲突了,这个问题我并没有深究,如果非要通过修改端口等操作部署上去后续可能带来的问题我处理不了,也很浪费时间,所

    2024年02月09日
    浏览(32)
  • 安装部署rancher2.7.0,然后导入K8S集群,管理集群

    centos系统请参考博客 ubuntu系统请参考博客 默认用户是admin 浏览器打开:https://IP:443 回车后就出现了如下图 利用刚才查到的密码登录 登录后直接修改密码,点击继续。 上图就是进入后的默认页面 不同版本调整中文的页面不一样,具体请根据自己的版本可以百度或者去官网查

    2024年02月11日
    浏览(32)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包