RKE 集群 cluster.yml 文件完整示例說明


最小文件示例

nodes:
  - address: 1.2.3.4
    user: ubuntu
    role:
      - controlplane
      - etcd
      - worker

完整文件示例

nodes:  # 節點選項配置
  - address: 1.1.1.1  # 用於設置節點的主機名或 IP 地址。RKE 必須能夠連接到這個地址。
    user: ubuntu  # 對於每個節點,您指定連接到這個節點時要使用的user。這個用戶必須是 Docker 組的成員,或者允許向節點的 Docker 套接字寫入。
    role:  # 支持的角色有三種:controlplane、etcd和worker。controlplane、etcd和worker。節點角色不是相互排斥的。可以將任意角色組合分配給任何節點。也可以通過升級過程改變節點的角色。
      - controlplane
      - etcd
    port: 2222  # 在每個節點中,您可以指定連接到這個節點時要使用的端口。默認的端口是22。
    docker_socket: /var/run/docker.sock  # 如果 Docker 套接字和默認的不一樣,您可以設置docker_socket。默認是/var/run/docker.sock。
  - address: 2.2.2.2
    user: ubuntu
    role:
      - worker
    ssh_key_path: /home/user/.ssh/id_rsa  # 對於每個節點,您可以指定路徑,即ssh_key_path,用於連接到這個節點時要使用的 SSH 私鑰。每個節點的默認密鑰路徑是~/.ssh/id_rsa。每個節點中設置的 SSH 密鑰路徑總是優先集群級SSH密鑰的。
    ssh_key: |-  # 您可以不設置 SSH 密鑰的路徑,而是指定實際的密鑰,即ssh_key,用來連接到節點。
      -----BEGIN RSA PRIVATE KEY-----
      -----END RSA PRIVATE KEY-----
    ssh_cert_path: /home/user/.ssh/test-key-cert.pub  # 對於每個節點,您可以指定路徑,即ssh_cert_path,用於連接到這個節點時要使用的簽名 SSH 證書。
    ssh_cert: |-  # 您可以指定實際的證書,即ssh_cert,用來連接到節點,而不是設置簽名的 SSH 證書的路徑。
      ssh-rsa-cert-v01@openssh.com AAAAHHNzaC1yc2EtY2VydC12MDFAb3Bl....
  - address: example.com
    user: ubuntu
    role:
      - worker
    hostname_override: node3  # 用於能夠提供一個友好的名稱,供 RKE 在 Kubernetes 中注冊節點時使用。這個 hostname 不需要是可路由地址,但必須是一個有效的Kubernetes 資源名。如果沒有設置hostname_override,那么在 Kubernetes 中注冊節點時就會使用address指令。
    internal_address: 192.168.1.6  # 提供了讓具有多個地址的節點設置一個特定的地址用於私有網絡上的主機間通信的能力。如果沒有設置internal_address,則使用address進行主機間通信。
    labels:  # 您可以為每個節點添加一個任意的標簽映射。當使用入口控制器的node_selector選項時,可以使用它。
      app: ingress
    taints:  # 您能夠為每個節點添加污點。
      - key: test-key
        value: test-value
        effect: NoSchedule
# If set to true, RKE will not fail when unsupported Docker version
# are found
ignore_docker_version: false  # 檢查 Docker 版本

# Enable running cri-dockerd
# Up to Kubernetes 1.23, kubelet contained code called dockershim 
# to support Docker runtime. The replacement is called cri-dockerd 
# and should be enabled if you want to keep using Docker as your
# container runtime
# Only available to enable in Kubernetes 1.21 and higher
enable_cri_dockerd: true  # cri-dockerd

# Cluster level SSH private key
# Used if no ssh information is set for the node
ssh_key_path: ~/.ssh/test  # 集群級 SSH 密鑰路徑
# Enable use of SSH agent to use SSH private keys with passphrase
# This requires the environment `SSH_AUTH_SOCK` configured pointing
#to your SSH agent which has the private key added
ssh_agent_auth: true  # SSH Agent
# List of registry credentials
# If you are using a Docker Hub registry, you can omit the `url`
# or set it to `docker.io`
# is_default set to `true` will override the system default
# registry set in the global settings
private_registries:  # RKE 支持在cluster.yml中配置多個私有鏡像倉庫。您可以在cluster.yml中配置私有鏡像倉庫和憑證,然后從私有鏡像倉拉取鏡像。
     - url: registry.com  # 如果您使用的是 Docker Hub 鏡像倉庫,您可以省略url,或者將url的值設置為 docker.io。
       user: Username
       password: password
       is_default: true  # 默認鏡像倉庫,所有的系統鏡像都將使用該鏡像倉庫進行拉取。
# 從 v0.1.10 開始,您必須配置您的私有鏡像倉庫憑證,但您可以指定這個鏡像倉庫為默認鏡像倉庫,這樣所有的系統鏡像都會從指定的私有鏡像倉庫中提取。您可以使用rke config --system-images命令來獲取默認系統映像的列表來填充您的私有鏡像倉庫。
# Bastion/Jump host configuration
bastion_host:  # 堡壘主機配置
    address: x.x.x.x  # address指令用於設置堡壘主機的主機名或 IP 地址。RKE 必須能夠連接到這個地址。
    user: ubuntu  # 指定連接到這個節點時要使用的用戶。
    port: 22  # 您可以指定連接到堡壘主機時要使用的 端口,如果不指定,會使用默認端口22。
    ssh_key_path: /home/user/.ssh/bastion_rsa  # 指定路徑,即ssh_key_path,用於連接堡壘主機時要使用的 SSH 私鑰。
# or
#   ssh_key: |-  # 你可以指定連接到堡壘主機使用的密鑰,即ssh_key,這樣的話就不需要設置 SSH 密鑰的路徑ssh_key_path。
#     -----BEGIN RSA PRIVATE KEY-----
#
#     -----END RSA PRIVATE KEY-----
# Set the name of the Kubernetes cluster
cluster_name: mycluster  # 集群名稱
# The Kubernetes version used. The default versions of Kubernetes
# are tied to specific versions of the system images.
#
# For RKE v0.2.x and below, the map of Kubernetes versions and their system images is
# located here:
# https://github.com/rancher/types/blob/release/v2.2/apis/management.cattle.io/v3/k8s_defaults.go
#
# For RKE v0.3.0 and above, the map of Kubernetes versions and their system images is
# located here:
# https://github.com/rancher/kontainer-driver-metadata/blob/master/rke/k8s_rke_system_images.go
#
# In case the kubernetes_version and kubernetes image in
# system_images are defined, the system_images configuration
# will take precedence over kubernetes_version.
kubernetes_version: v1.10.3-rancher2  # K8S版本
# System Images are defaulted to a tag that is mapped to a specific
# Kubernetes Version and not required in a cluster.yml.
# Each individual system image can be specified if you want to use a different tag.
#
# For RKE v0.2.x and below, the map of Kubernetes versions and their system images is
# located here:
# https://github.com/rancher/types/blob/release/v2.2/apis/management.cattle.io/v3/k8s_defaults.go
#
# For RKE v0.3.0 and above, the map of Kubernetes versions and their system images is
# located here:
# https://github.com/rancher/kontainer-driver-metadata/blob/master/rke/k8s_rke_system_images.go
#
system_images:  # 系統鏡像,優先級高於kubernetes_version
    kubernetes: rancher/hyperkube:v1.10.3-rancher2
    etcd: rancher/coreos-etcd:v3.1.12
    alpine: rancher/rke-tools:v0.1.9
    nginx_proxy: rancher/rke-tools:v0.1.9
    cert_downloader: rancher/rke-tools:v0.1.9
    kubernetes_services_sidecar: rancher/rke-tools:v0.1.9
    kubedns: rancher/k8s-dns-kube-dns-amd64:1.14.8
    dnsmasq: rancher/k8s-dns-dnsmasq-nanny-amd64:1.14.8
    kubedns_sidecar: rancher/k8s-dns-sidecar-amd64:1.14.8
    kubedns_autoscaler: rancher/cluster-proportional-autoscaler-amd64:1.0.0
    pod_infra_container: rancher/pause-amd64:3.1
services:  # 默認的K8S服務
    etcd:
      # Custom uid/guid for etcd directory and files
      uid: 52034
      gid: 52034
      # if external etcd is used  # 外部etcd
      # path: /etcdcluster
      # external_urls:
      #   - https://etcd-example.com:2379
      # ca_cert: |-
      #   -----BEGIN CERTIFICATE-----
      #   xxxxxxxxxx
      #   -----END CERTIFICATE-----
      # cert: |-
      #   -----BEGIN CERTIFICATE-----
      #   xxxxxxxxxx
      #   -----END CERTIFICATE-----
      # key: |-
      #   -----BEGIN PRIVATE KEY-----
      #   xxxxxxxxxx
      #   -----END PRIVATE KEY-----
    # Note for Rancher v2.0.5 and v2.0.6 users: If you are configuring
    # Cluster Options using a Config File when creating Rancher Launched
    # Kubernetes, the names of services should contain underscores
    # only: `kube_api`.
    kube-api:
      # IP range for any services created on Kubernetes  在Kubernetes上創建的服務的IP范圍。
      # This must match the service_cluster_ip_range in kube-controller  必須與kube-controller中的service_cluster_ip_range匹配
      service_cluster_ip_range: 10.43.0.0/16  # 這是將分配給 Kubernetes 上創建的服務的虛擬 IP 地址。默認情況下,服務集群 IP 范圍是10.43.0.0/16。如果您改變了這個值,那么也必須在 Kubernetes 控制器管理器(kube-controller)上設置相同的值。
      # Expose a different port range for NodePort services 為NodePort服務提供不同的端口范圍
      service_node_port_range: 30000-32767  # 使用type NodePort創建的 Kubernetes 服務的端口范圍。默認情況下,端口范圍是30000-32767。
      pod_security_policy: false  # 啟用Kubernetes Pod 安全策略的選項。默認情況下,我們不會啟用 pod 安全策略,因為它被設置為false。注意:如果您將pod_security_policy值設置為true,RKE 將配置一個開放的策略,允許任何 pod 在集群上工作。您需要配置您自己的策略來充分利用 PSP。
      # Encrypt secret data at Rest
      # Available as of v0.3.1
      secrets_encryption_config:  # 管理 Kubernetes 靜態數據加密。https://docs.rancher.cn/docs/rke/config-options/secrets-encryption/_index
        enabled: true  # 啟用加密功能
        custom_config:
          apiVersion: apiserver.config.k8s.io/v1
          kind: EncryptionConfiguration
          resources:
          - resources:
            - secrets
            providers:
            - aescbc:
                keys:
                - name: k-fw5hn
                  secret: RTczRjFDODMwQzAyMDVBREU4NDJBMUZFNDhCNzM5N0I=
            - identity: {}
      # Enable audit logging
      # Available as of v1.0.0
      audit_log:  # Kubernetes 審計提供了關於集群的安全相關的時間順序記錄集。Kube-apiserver 執行審計,每個請求都會產生一個事件,然后根據一定的策略進行預處理,並寫入后端。策略決定了記錄的內容,而后端則會將記錄持久化。為了遵守 CIS(Center for Internet Security)Kubernetes Benchmark,您需要配置審計日志。
        enabled: true  # 啟用審計日志
        configuration:
          max_age: 6  # 最大年齡,保留舊審計日志文件的最長天數。
          max_backup: 6  # 最大備份數量,保留舊審計日志文件的最大數量。
          max_size: 110  # 最大大小(兆字節),審計日志文件在被替換之前的最大大小(MB)。
          path: /var/log/kube-audit/audit-log.json  # 審計日志路徑,日志后端用於寫入審計事件的日志文件路徑。
          format: json  # 日志文件格式
          policy:
            apiVersion: audit.k8s.io/v1 # This is required.
            kind: Policy
            omitStages:
              - "RequestReceived"
            rules:
              # Log pod changes at RequestResponse level
              - level: RequestResponse  # 在RequestResponse級別記錄pod變化
                resources:
                - group: ""
                  # Resource "pods" doesn't match requests to any subresource of pods,  資源 "pods "不匹配對pods的任何子資源的請求
                  # which is consistent with the RBAC policy.  與RBAC策略是一致的
                  resources: ["pods"]

              # 在元數據層記錄 "pods/log"、"pods/status"
              - level: Metadata
                resources:
                  - group: ""
                    resources: ["pods/log", "pods/status"]

              # 不要將請求記錄到名為 "controller-leader "的配置圖上
              - level: None
                resources:
                  - group: ""
                    resources: ["configmaps"]
                    resourceNames: ["controller-leader"]

              # 不要在端點或服務上記錄 "system:keube-proxy "的監視請求
              - level: None
                users: ["system:kube-proxy"]
                verbs: ["watch"]
                resources:
                  - group: "" # core API group
                    resources: ["endpoints", "services"]

              # 不要記錄對某些非資源URL路徑的認證請求
              - level: None
                userGroups: ["system:authenticated"]
                nonResourceURLs:
                  - "/api*" # Wildcard matching.
                  - "/version"

              # 在kube-system中記錄configmap變更的請求體
              - level: Request
                resources:
                  - group: "" # core API group
                    resources: ["configmaps"]
                # 此規則只適用於 "kube-system "命名空間中的資源
                # 空字符串""可用於選擇非命名間隔的資源
                namespaces: ["kube-system"]

              # 在元數據級別記錄所有其他命名空間的configmap和密鑰變化
              - level: Metadata
                resources:
                  - group: "" # core API group
                    resources: ["secrets", "configmaps"]

              # 在請求層記錄核心和擴展的所有其他資源
              - level: Request
                resources:
                  - group: "" # core API group
                  - group: "extensions" # 不應包括組的版本

              # 一個全面的規則,用於記錄元數據級別的所有其他請求
              - level: Metadata
                # 在此規則下,像監控這樣的長期運行的請求不會在RequestReceived中產生審計事件
                omitStages:
                  - "RequestReceived"
      # Using the EventRateLimit admission control enforces a limit on the number of events
      # that the API Server will accept in a given time period
      # Available as of v1.0.0
      event_rate_limit:  # 使用 EventRateLimit接納控制對 API 服務器在特定時間段內接受的事件數量進行限制。在一個大型多租戶集群中,可能會有一小部分租戶用事件請求淹沒服務器,這可能會對集群的整體性能產生重大影響。因此,建議限制 API 服務器接受事件的速率。
        enabled: true
        configuration:
          apiVersion: eventratelimit.admission.k8s.io/v1alpha1
          kind: Configuration
          limits:
          - type: Server  # 默認值:Server
            qps: 6000  # 默認值:5000
            burst: 30000  # 默認值:20000
      # Enable AlwaysPullImages Admission controller plugin  啟用AlwaysPullImagesAdmission controller插件
      # Available as of v0.2.0  v0.2.0或更新版本可用
      always_pull_images: false  # 啟用AlwaysPullImages Admission 控制器插件。啟用AlwaysPullImages是一個安全的最佳實踐。它強制 Kubernetes 與遠程鏡像鏡像倉庫驗證鏡像和拉動憑證。本地鏡像層緩存仍將被使用,但它確實會在啟動容器拉取和比較鏡像哈希時增加一點開銷。注:從 v0.2.0 開始提供。
      # Add additional arguments to the kubernetes API server
      # This WILL OVERRIDE any existing defaults
      extra_args:
        # Enable audit log to stdout
        audit-log-path: "-"
        # Increase number of delete workers
        delete-collection-workers: 3
        # Set the level of log output to debug-level
        v: 4
    # Note for Rancher 2 users: If you are configuring Cluster Options
    # using a Config File when creating Rancher Launched Kubernetes,
    # the names of services should contain underscores only:
    # `kube_controller`. This only applies to Rancher v2.0.5 and v2.0.6.
    kube-controller:
      # CIDR pool used to assign IP addresses to pods in the cluster
      cluster_cidr: 10.42.0.0/16  # 用於為集群中的 pod 分配 IP 地址的 CIDR 池。默認情況下,集群中的每個節點都會從該池中分配一個/24網絡,用於分配 pod IP。該選項的默認值是10.42.0.0/16。
      # IP range for any services created on Kubernetes
      # This must match the service_cluster_ip_range in kube-api
      service_cluster_ip_range: 10.43.0.0/16  # 這是將分配給 Kubernetes 上創建的服務的虛擬 IP 地址。默認情況下,服務集群 IP 范圍是10.43.0.0/16。如果您改變了這個值,那么也必須在 Kubernetes API 服務器(kube-api)上設置相同的值。
      # Add additional arguments to the kubernetes API server
      # This WILL OVERRIDE any existing defaults
      extra_args:
        # Set the level of log output to debug-level
        v: 4
        # Enable RotateKubeletServerCertificate feature gate
        feature-gates: RotateKubeletServerCertificate=true
        # Enable TLS Certificates management
        # https://kubernetes.io/docs/tasks/tls/managing-tls-in-a-cluster/
        cluster-signing-cert-file: "/etc/kubernetes/ssl/kube-ca.pem"
        cluster-signing-key-file: "/etc/kubernetes/ssl/kube-ca-key.pem"
    kubelet:
      # Base domain for the cluster
      cluster_domain: cluster.local  # 集群的基本域。集群上創建的所有服務和 DNS 記錄。默認情況下,域被設置為cluster.local。
      # IP address for the DNS service endpoint
      cluster_dns_server: 10.43.0.10  # 分配給集群內 DNS 服務端點的 IP 地址。DNS 查詢將被發送到這個 IP 地址,該地址被 KubeDNS 使用。這個選項的默認值是10.43.0.10。
      # Fail if swap is on
      fail_swap_on: false  # 在 Kubernetes 中,如果節點上啟用了 swap,kubelet 的默認行為是失敗。RKE 不會遵循這個默認值,而是允許在啟用 swap 的節點上進行部署。默認情況下,這個值是false。如果您想恢復到默認的 kubelet 行為,請將此選項設置為 "true"。
      # Configure pod-infra-container-image argument
      pod-infra-container-image: "k8s.gcr.io/pause:3.2"
      # Generate a certificate signed by the kube-ca Certificate Authority
      # for the kubelet to use as a server certificate
      # Available as of v1.0.0
      generate_serving_certificate: true  # 為 kubelet 生成一個由kube-ca證書頒發機構簽署的證書作為服務器證書。這個選項的默認值是false。在啟用這個選項之前,請參考下文的 Kubelet Serving Certificate 需求。
# 如果在cluster.yml中為一個或多個節點配置了hostname_override,請確保在address中配置了正確的 IP 地址(以及internal_address中的內部地址),以確保生成的證書包含正確的 IP 地址。
# 一個錯誤的例子是,在 EC2 實例中,如果在address中配置了公共 IP 地址,並且使用了hostname_override,那么kube-apiserver和kubelet之間的連接將失敗,因為kubelet將在私有 IP 地址上被聯系,生成的證書將無效(將看到錯誤x509:證書對 value_in_address 有效,而不是 private_ip)。解決方法是在internal_address中提供內部 IP 地址。
      extra_args:  # 自定義參數
        # Set max pods to 250 instead of default 110
        max-pods: 250
        # Enable RotateKubeletServerCertificate feature gate
        feature-gates: RotateKubeletServerCertificate=true
      # Optionally define additional volume binds to a service
      extra_binds:  # Docker 掛載綁定
        - "/usr/libexec/kubernetes/kubelet-plugins:/usr/libexec/kubernetes/kubelet-plugins"
      extra_env:  # 環境變量
        - "HTTP_PROXY=http://your_proxy"
    scheduler:  # 目前,RKE 並不支持scheduler服務的任何特定選項。
      extra_args:
        # Set the level of log output to debug-level
        v: 4
    kubeproxy:  # 目前,RKE 不支持 "kubeproxy "服務的任何特定選項。
      extra_args:
        # Set the level of log output to debug-level
        v: 4
# Currently, only authentication strategy supported is x509.
# You can optionally create additional SANs (hostnames or IPs) to
# add to the API server PKI certificate.
# This is useful if you want to use a load balancer for the
# control plane servers.
authentication:
  strategy: x509
  sans:
    - "10.18.160.10"
    - "my-loadbalancer-1234567890.us-west-2.elb.amazonaws.com"

# Kubernetes Authorization mode
# Use `mode: rbac` to enable RBAC
# Use `mode: none` to disable authorization
authorization:  # 默認情況下,RKE 會啟用 RBAC 授權策略。如果你想關閉 RBAC 授權策略,請在cluster.yml中將設置授權模式為none。雖然 RKE 支持手動關閉 RBAC 授權策略,但是關閉 RBAC 授權策略會有一定的風險,我們不建議用戶關閉 RBAC 授權策略。
  mode: rbac

# If you want to set a Kubernetes cloud provider, you specify
# the name and configuration
cloud_provider:  # RKE 支持為 Kubernetes 集群設置特定的雲服務提供商。這些雲服務提供商有特定的配置參數。RKE 支持的雲服務提供商如下:AWS、Azure、OpenStack、vSphere。
  name: aws

# Add-ons are deployed using kubernetes jobs. RKE will give
# up on trying to get the job status after this timeout in seconds..
addon_job_timeout: 30  # RKE 使用 Kubernetes job 的方式部署插件。在某些情況下,部署插件的時間會比預期時間長。從 v0.1.7 開始,RKE 提供集群層級的addon_job_timeout選項,以檢查 job 的連接是否超時,默認值為 30,單位是秒。

# Specify network plugin-in (canal, calico, flannel, weave, or none)
network:  # 網絡插件配置
  plugin: canal  # RKE 提供了以下網絡插件,作為附加組件部署:flannel、calico、canal、weave。默認情況下,RKE 使用的網絡插件是canal。
  # Specify MTU
  mtu: 1400
  options:
    # Configure interface to use for Canal
    canal_iface: eth1  # 通過設置canal_iface,可以配置主機間通信使用的接口。
    canal_flannel_backend_type: vxlan  # canal_flannel_backend_type選項允許你指定要使用的flannel backend的類型。默認情況下使用vxlan后端。
    # Available as of v1.2.6
    canal_autoscaler_priority_class_name: system-cluster-critical
    canal_priority_class_name: system-cluster-critical
  # Available as of v1.2.4
  tolerations:  # Canal 網絡插件容忍度
  - key: "node.kubernetes.io/unreachable"
    operator: "Exists"
    effect: "NoExecute"
    tolerationseconds: 300
  - key: "node.kubernetes.io/not-ready"
    operator: "Exists"
    effect: "NoExecute"
    tolerationseconds: 300
  # Available as of v1.1.0
  update_strategy:
    strategy: RollingUpdate
    rollingUpdate:
      maxUnavailable: 6

# Specify DNS provider (coredns or kube-dns)
dns:  # DNS服務配置
  provider: coredns  # 在 RKE v0.2.5 及更新版本中,使用 Kubernetes 1.14 及以上版本時,CoreDNS 是默認 DNS 提供商。
  # Available as of v1.1.0
  update_strategy:
    strategy: RollingUpdate
    rollingUpdate:
      maxUnavailable: 20%
      maxSurge: 15%
  linear_autoscaler_params:
    cores_per_replica: 0.34
    nodes_per_replica: 4
    prevent_single_point_failure: true
    min: 2
    max: 3
  node_selector:  # 如果只想在特定的節點上部署 CoreDNS pod ,可以在dns部分設置一個node_selector。node_selector中的標簽需要與要部署 CoreDNS pod 的節點上的標簽相匹配。
    app: dns
  upstreamnameservers:  # 默認情況下,CoreDNS 使用主機配置的命名服務器(通常保存在/etc/resolv.conf路徑下)來解析外部查詢。如果想配置特定的上游名稱服務器,可以使用upstreamnameservers指令。
    - 1.1.1.1
    - 8.8.4.4
  tolerations:  # 配置的容忍度適用於coredns和coredns-autoscaler部署。
    - key: "node.kubernetes.io/unreachable"
      operator: "Exists"
      effect: "NoExecute"
      tolerationseconds: 300
    - key: "node.kubernetes.io/not-ready"
      operator: "Exists"
      effect: "NoExecute"
      tolerationseconds: 300
  options:  # CoreDNS 優先級類名稱
    coredns_autoscaler_priority_class_name: system-cluster-critical
    coredns_priority_class_name: system-cluster-critical
# Specify monitoring provider (metrics-server)
monitoring:  # 默認情況下,RKE 會部署 Metrics Server來提供集群中資源的指標。RKE 會將 Metrics Server 部署為一個 Deployment。
  provider: metrics-server  # 您可以將provider的值修改為none,禁用默認控制器。
  metrics_server_priority_class_name: system-cluster-critical  # 度量衡服務器優先級類別名稱
  # Available as of v1.1.0
  update_strategy:
    strategy: RollingUpdate
    rollingUpdate:
      maxUnavailable: 8
  tolerations:  # 容忍度
    - key: "node.kubernetes.io/unreachable"
      operator: "Exists"
      effect: "NoExecute"
      tolerationseconds: 300
    - key: "node.kubernetes.io/not-ready"
      operator: "Exists"
      effect: "NoExecute"
      tolerationseconds: 300
# Currently only nginx ingress provider is supported.
# To disable ingress controller, set `provider: none`
# `node_selector` controls ingress placement and is optional
ingress:  # 默認情況下,RKE 會在所有可調度節點上部署 NGINX ingress controller。從 v0.1.8 開始,只有 worker 節點是可調度節點。RKE 將以 DaemonSet 的形式部署 Ingress Controller,並使用 hostnetwork: true,因此在部署控制器的每個節點上都會打開 80和443端口。
  provider: nginx
  node_selector:  # 如果只想在特定的節點上部署 Ingress Controller ,可以在dns部分設置一個node_selector。node_selector中的標簽需要與要部署 Ingress Controller 的節點上的標簽相匹配。
    app: ingress
  # Available as of v1.1.0
  update_strategy:
    strategy: RollingUpdate
    rollingUpdate:
      maxUnavailable: 5
  extra_envs:  # 環境變量
    - name: TZ
      value: Asia/Shanghai
  ingress_priority_class_name: system-cluster-critical  # 入站優先級類別名稱
  tolerations:  # 容忍度
    - key: "node.kubernetes.io/unreachable"
      operator: "Exists"
      effect: "NoExecute"
      tolerationseconds: 300
    - key: "node.kubernetes.io/not-ready"
      operator: "Exists"
      effect: "NoExecute"
      tolerationseconds: 300
  options:  # Kubernetes 中有 NGINX 選項:NGINX 配置圖的選項列表、命令行 extra_args和注釋。
    map-hash-bucket-size: "128"
    ssl-protocols: SSLv2
  extra_args:
    enable-ssl-passthrough: ""
    default-ssl-certificate: "ingress-nginx/ingress-default-cert"  # 默認證書由下面的自定義插件生成
  default_backend: false  # 禁用 NGINX Ingress 默認后端
  network_mode: hostNetwork  # 默認情況下,nginx ingress controller 使用 hostNetwork: true 配置,默認端口為80和443。對於 Kubernetes v1.21 及更高版本,NGINX ingress controller 不再運行在 hostNetwork: true 中,而是使用 hostPort 的端口 80 和端口 443。
# All add-on manifests MUST specify a namespace
addons: |-  # 自定義插件,直接嵌入。RKE 將 YAML 清單作為 configmap 上傳至 Kubernetes 集群。然后,它運行一個 Kubernetes job,掛載 configmap 並使用kubectl apply -f部署插件。RKE 只有在多次使用rke up時才會添加額外的插件。當使用不同的附加組件列表進行rke up時,RKE 不支持刪除集群附加組件。從 v0.1.8 開始,RKE 會更新同名的插件。如果要在 YAML 文件中直接定義一個插件,一定要使用 YAML 的 block indicator |-,因為addons指令是一個多行字符串選項。可以用---指令將多個 YAML 資源定義分開來指定。
  ---
  apiVersion: v1
  kind: Pod
  metadata:
    name: my-nginx
    namespace: default  # 說明:當使自定義的附加組件時,必須為你的所有資源定義一個命名空間,否則它們會進入kube-system命名空間。
  spec:
    containers:
    - name: my-nginx
      image: nginx
      ports:
      - containerPort: 80
  ---  # 下面清單由此命令生成:kubectl -n ingress-nginx create secret tls ingress-default-cert --cert=mycert.cert --key=mycert.key -o yaml --dry-run=true > ingress-default-cert.yaml,然后將 ingress-default-cert.yml的內容嵌入。
  apiVersion: v1
  data:
    tls.crt: [ENCODED CERT]
    tls.key: [ENCODED KEY]
  kind: Secret
  metadata:
    creationTimestamp: null
    name: ingress-default-cert
    namespace: ingress-nginx  # 說明:當使自定義的附加組件時,必須為你的所有資源定義一個命名空間,否則它們會進入kube-system命名空間。
  type: kubernetes.io/tls

addons_include:  # 引用插件的 YAML 文件。使用addons_include指令,提供自定義插件引用的本地文件路徑或 URL 地址。
  - https://raw.githubusercontent.com/rook/rook/master/cluster/examples/kubernetes/rook-operator.yaml
  - https://raw.githubusercontent.com/rook/rook/master/cluster/examples/kubernetes/rook-cluster.yaml
  - /path/to/manifest


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM