title: cluster.yml 文件示例
description: 您可通过编辑 RKE 的集群配置文件cluster.yml,完成多种配置选项。以下是最小文件示例和完整文件示例。
keywords:
- rancher
- rancher中文
- rancher中文文档
- rancher官网
- rancher文档
- Rancher
- rancher 中文
- rancher 中文文档
- rancher cn
- RKE
- cluster.yml 文件示例
您可通过编辑 RKE 的集群配置文件cluster.yml,完成多种配置选项。以下是最小文件示例和完整文件示例。
说明:如果您使用的是 Rancher v2.0.5 或 v2.0.6,使用集群配置文件,配置集群选项时,服务名称不能含有除了英文字母和下划线外的其他字符。
最小文件示例
nodes:- address: 1.2.3.4user: ubunturole:- controlplane- etcd- worker
完整文件示例
nodes:- address: 1.1.1.1user: ubunturole:- controlplane- etcdport: 2222docker_socket: /var/run/docker.sock- address: 2.2.2.2user: ubunturole:- workerssh_key_path: /home/user/.ssh/id_rsassh_key: |------BEGIN RSA PRIVATE KEY----------END RSA PRIVATE KEY-----ssh_cert_path: /home/user/.ssh/test-key-cert.pubssh_cert: |-ssh-rsa-cert-v01@openssh.com AAAAHHNzaC1yc2EtY2VydC12MDFAb3Bl....- address: example.comuser: ubunturole:- workerhostname_override: node3internal_address: 192.168.1.6labels:app: ingresstaints:- key: test-keyvalue: test-valueeffect: NoSchedule# If set to true, RKE will not fail when unsupported Docker version# are foundignore_docker_version: false# 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 higherenable_cri_dockerd: true# Cluster level SSH private key# Used if no ssh information is set for the nodessh_key_path: ~/.ssh/test# 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 addedssh_agent_auth: true# 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 settingsprivate_registries:- url: registry.comuser: Usernamepassword: passwordis_default: true# Bastion/Jump host configurationbastion_host:address: x.x.x.xuser: ubuntuport: 22ssh_key_path: /home/user/.ssh/bastion_rsa# or# ssh_key: |-# -----BEGIN RSA PRIVATE KEY-----## -----END RSA PRIVATE KEY-----# Set the name of the Kubernetes clustercluster_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# 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: rancher/hyperkube:v1.10.3-rancher2etcd: rancher/coreos-etcd:v3.1.12alpine: rancher/rke-tools:v0.1.9nginx_proxy: rancher/rke-tools:v0.1.9cert_downloader: rancher/rke-tools:v0.1.9kubernetes_services_sidecar: rancher/rke-tools:v0.1.9kubedns: rancher/k8s-dns-kube-dns-amd64:1.14.8dnsmasq: rancher/k8s-dns-dnsmasq-nanny-amd64:1.14.8kubedns_sidecar: rancher/k8s-dns-sidecar-amd64:1.14.8kubedns_autoscaler: rancher/cluster-proportional-autoscaler-amd64:1.0.0pod_infra_container: rancher/pause-amd64:3.1services:etcd:# Custom uid/guid for etcd directory and filesuid: 52034gid: 52034# if external etcd is used# 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# This must match the service_cluster_ip_range in kube-controllerservice_cluster_ip_range: 10.43.0.0/16# Expose a different port range for NodePort servicesservice_node_port_range: 30000-32767pod_security_policy: false# Encrypt secret data at Rest# Available as of v0.3.1secrets_encryption_config:enabled: truecustom_config:apiVersion: apiserver.config.k8s.io/v1kind: EncryptionConfigurationresources:- resources:- secretsproviders:- aescbc:keys:- name: k-fw5hnsecret: RTczRjFDODMwQzAyMDVBREU4NDJBMUZFNDhCNzM5N0I=- identity: {}# Enable audit logging# Available as of v1.0.0audit_log:enabled: trueconfiguration:max_age: 6max_backup: 6max_size: 110path: /var/log/kube-audit/audit-log.jsonformat: jsonpolicy:apiVersion: audit.k8s.io/v1 # This is required.kind: PolicyomitStages:- "RequestReceived"rules:# Log pod changes at RequestResponse level- level: RequestResponseresources:- group: ""# Resource "pods" doesn't match requests to any subresource of pods,# which is consistent with the RBAC policy.resources: ["pods"]# 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.0event_rate_limit:enabled: trueconfiguration:apiVersion: eventratelimit.admission.k8s.io/v1alpha1kind: Configurationlimits:- type: Serverqps: 6000burst: 30000# Enable AlwaysPullImages Admission controller plugin# Available as of v0.2.0always_pull_images: false# Add additional arguments to the kubernetes API server# This WILL OVERRIDE any existing defaultsextra_args:# Enable audit log to stdoutaudit-log-path: "-"# Increase number of delete workersdelete-collection-workers: 3# Set the level of log output to debug-levelv: 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 clustercluster_cidr: 10.42.0.0/16# IP range for any services created on Kubernetes# This must match the service_cluster_ip_range in kube-apiservice_cluster_ip_range: 10.43.0.0/16# Add additional arguments to the kubernetes API server# This WILL OVERRIDE any existing defaultsextra_args:# Set the level of log output to debug-levelv: 4# Enable RotateKubeletServerCertificate feature gatefeature-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 clustercluster_domain: cluster.local# IP address for the DNS service endpointcluster_dns_server: 10.43.0.10# Fail if swap is onfail_swap_on: false# Configure pod-infra-container-image argumentpod-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.0generate_serving_certificate: trueextra_args:# Set max pods to 250 instead of default 110max-pods: 250# Enable RotateKubeletServerCertificate feature gatefeature-gates: RotateKubeletServerCertificate=true# Optionally define additional volume binds to a serviceextra_binds:- "/usr/libexec/kubernetes/kubelet-plugins:/usr/libexec/kubernetes/kubelet-plugins"scheduler:extra_args:# Set the level of log output to debug-levelv: 4kubeproxy:extra_args:# Set the level of log output to debug-levelv: 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: x509sans:- "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 authorizationauthorization:mode: rbac# If you want to set a Kubernetes cloud provider, you specify# the name and configurationcloud_provider: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# Specify network plugin-in (canal, calico, flannel, weave, or none)network:plugin: canal# Specify MTUmtu: 1400options:# Configure interface to use for Canalcanal_iface: eth1canal_flannel_backend_type: vxlan# Available as of v1.2.6canal_autoscaler_priority_class_name: system-cluster-criticalcanal_priority_class_name: system-cluster-critical# Available as of v1.2.4tolerations:- 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.0update_strategy:strategy: RollingUpdaterollingUpdate:maxUnavailable: 6# Specify DNS provider (coredns or kube-dns)dns:provider: coredns# Available as of v1.1.0update_strategy:strategy: RollingUpdaterollingUpdate:maxUnavailable: 20%maxSurge: 15%linear_autoscaler_params:cores_per_replica: 0.34nodes_per_replica: 4prevent_single_point_failure: truemin: 2max: 3# Specify monitoring provider (metrics-server)monitoring:provider: metrics-server# Available as of v1.1.0update_strategy:strategy: RollingUpdaterollingUpdate:maxUnavailable: 8# Currently only nginx ingress provider is supported.# To disable ingress controller, set `provider: none`# `node_selector` controls ingress placement and is optionalingress:provider: nginxnode_selector:app: ingress# Available as of v1.1.0update_strategy:strategy: RollingUpdaterollingUpdate:maxUnavailable: 5# All add-on manifests MUST specify a namespaceaddons: |----apiVersion: v1kind: Podmetadata:name: my-nginxnamespace: defaultspec:containers:- name: my-nginximage: nginxports:- containerPort: 80addons_include:- 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
