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,使用集群配置文件,配置集群选项时,服务名称不能含有除了英文字母和下划线外的其他字符。

最小文件示例

  1. nodes:
  2. - address: 1.2.3.4
  3. user: ubuntu
  4. role:
  5. - controlplane
  6. - etcd
  7. - worker

完整文件示例

  1. nodes:
  2. - address: 1.1.1.1
  3. user: ubuntu
  4. role:
  5. - controlplane
  6. - etcd
  7. port: 2222
  8. docker_socket: /var/run/docker.sock
  9. - address: 2.2.2.2
  10. user: ubuntu
  11. role:
  12. - worker
  13. ssh_key_path: /home/user/.ssh/id_rsa
  14. ssh_key: |-
  15. -----BEGIN RSA PRIVATE KEY-----
  16. -----END RSA PRIVATE KEY-----
  17. ssh_cert_path: /home/user/.ssh/test-key-cert.pub
  18. ssh_cert: |-
  19. ssh-rsa-cert-v01@openssh.com AAAAHHNzaC1yc2EtY2VydC12MDFAb3Bl....
  20. - address: example.com
  21. user: ubuntu
  22. role:
  23. - worker
  24. hostname_override: node3
  25. internal_address: 192.168.1.6
  26. labels:
  27. app: ingress
  28. taints:
  29. - key: test-key
  30. value: test-value
  31. effect: NoSchedule
  32. # If set to true, RKE will not fail when unsupported Docker version
  33. # are found
  34. ignore_docker_version: false
  35. # Enable running cri-dockerd
  36. # Up to Kubernetes 1.23, kubelet contained code called dockershim
  37. # to support Docker runtime. The replacement is called cri-dockerd
  38. # and should be enabled if you want to keep using Docker as your
  39. # container runtime
  40. # Only available to enable in Kubernetes 1.21 and higher
  41. enable_cri_dockerd: true
  42. # Cluster level SSH private key
  43. # Used if no ssh information is set for the node
  44. ssh_key_path: ~/.ssh/test
  45. # Enable use of SSH agent to use SSH private keys with passphrase
  46. # This requires the environment `SSH_AUTH_SOCK` configured pointing
  47. #to your SSH agent which has the private key added
  48. ssh_agent_auth: true
  49. # List of registry credentials
  50. # If you are using a Docker Hub registry, you can omit the `url`
  51. # or set it to `docker.io`
  52. # is_default set to `true` will override the system default
  53. # registry set in the global settings
  54. private_registries:
  55. - url: registry.com
  56. user: Username
  57. password: password
  58. is_default: true
  59. # Bastion/Jump host configuration
  60. bastion_host:
  61. address: x.x.x.x
  62. user: ubuntu
  63. port: 22
  64. ssh_key_path: /home/user/.ssh/bastion_rsa
  65. # or
  66. # ssh_key: |-
  67. # -----BEGIN RSA PRIVATE KEY-----
  68. #
  69. # -----END RSA PRIVATE KEY-----
  70. # Set the name of the Kubernetes cluster
  71. cluster_name: mycluster
  72. # The Kubernetes version used. The default versions of Kubernetes
  73. # are tied to specific versions of the system images.
  74. #
  75. # For RKE v0.2.x and below, the map of Kubernetes versions and their system images is
  76. # located here:
  77. # https://github.com/rancher/types/blob/release/v2.2/apis/management.cattle.io/v3/k8s_defaults.go
  78. #
  79. # For RKE v0.3.0 and above, the map of Kubernetes versions and their system images is
  80. # located here:
  81. # https://github.com/rancher/kontainer-driver-metadata/blob/master/rke/k8s_rke_system_images.go
  82. #
  83. # In case the kubernetes_version and kubernetes image in
  84. # system_images are defined, the system_images configuration
  85. # will take precedence over kubernetes_version.
  86. kubernetes_version: v1.10.3-rancher2
  87. # System Images are defaulted to a tag that is mapped to a specific
  88. # Kubernetes Version and not required in a cluster.yml.
  89. # Each individual system image can be specified if you want to use a different tag.
  90. #
  91. # For RKE v0.2.x and below, the map of Kubernetes versions and their system images is
  92. # located here:
  93. # https://github.com/rancher/types/blob/release/v2.2/apis/management.cattle.io/v3/k8s_defaults.go
  94. #
  95. # For RKE v0.3.0 and above, the map of Kubernetes versions and their system images is
  96. # located here:
  97. # https://github.com/rancher/kontainer-driver-metadata/blob/master/rke/k8s_rke_system_images.go
  98. #
  99. system_images:
  100. kubernetes: rancher/hyperkube:v1.10.3-rancher2
  101. etcd: rancher/coreos-etcd:v3.1.12
  102. alpine: rancher/rke-tools:v0.1.9
  103. nginx_proxy: rancher/rke-tools:v0.1.9
  104. cert_downloader: rancher/rke-tools:v0.1.9
  105. kubernetes_services_sidecar: rancher/rke-tools:v0.1.9
  106. kubedns: rancher/k8s-dns-kube-dns-amd64:1.14.8
  107. dnsmasq: rancher/k8s-dns-dnsmasq-nanny-amd64:1.14.8
  108. kubedns_sidecar: rancher/k8s-dns-sidecar-amd64:1.14.8
  109. kubedns_autoscaler: rancher/cluster-proportional-autoscaler-amd64:1.0.0
  110. pod_infra_container: rancher/pause-amd64:3.1
  111. services:
  112. etcd:
  113. # Custom uid/guid for etcd directory and files
  114. uid: 52034
  115. gid: 52034
  116. # if external etcd is used
  117. # path: /etcdcluster
  118. # external_urls:
  119. # - https://etcd-example.com:2379
  120. # ca_cert: |-
  121. # -----BEGIN CERTIFICATE-----
  122. # xxxxxxxxxx
  123. # -----END CERTIFICATE-----
  124. # cert: |-
  125. # -----BEGIN CERTIFICATE-----
  126. # xxxxxxxxxx
  127. # -----END CERTIFICATE-----
  128. # key: |-
  129. # -----BEGIN PRIVATE KEY-----
  130. # xxxxxxxxxx
  131. # -----END PRIVATE KEY-----
  132. # Note for Rancher v2.0.5 and v2.0.6 users: If you are configuring
  133. # Cluster Options using a Config File when creating Rancher Launched
  134. # Kubernetes, the names of services should contain underscores
  135. # only: `kube_api`.
  136. kube-api:
  137. # IP range for any services created on Kubernetes
  138. # This must match the service_cluster_ip_range in kube-controller
  139. service_cluster_ip_range: 10.43.0.0/16
  140. # Expose a different port range for NodePort services
  141. service_node_port_range: 30000-32767
  142. pod_security_policy: false
  143. # Encrypt secret data at Rest
  144. # Available as of v0.3.1
  145. secrets_encryption_config:
  146. enabled: true
  147. custom_config:
  148. apiVersion: apiserver.config.k8s.io/v1
  149. kind: EncryptionConfiguration
  150. resources:
  151. - resources:
  152. - secrets
  153. providers:
  154. - aescbc:
  155. keys:
  156. - name: k-fw5hn
  157. secret: RTczRjFDODMwQzAyMDVBREU4NDJBMUZFNDhCNzM5N0I=
  158. - identity: {}
  159. # Enable audit logging
  160. # Available as of v1.0.0
  161. audit_log:
  162. enabled: true
  163. configuration:
  164. max_age: 6
  165. max_backup: 6
  166. max_size: 110
  167. path: /var/log/kube-audit/audit-log.json
  168. format: json
  169. policy:
  170. apiVersion: audit.k8s.io/v1 # This is required.
  171. kind: Policy
  172. omitStages:
  173. - "RequestReceived"
  174. rules:
  175. # Log pod changes at RequestResponse level
  176. - level: RequestResponse
  177. resources:
  178. - group: ""
  179. # Resource "pods" doesn't match requests to any subresource of pods,
  180. # which is consistent with the RBAC policy.
  181. resources: ["pods"]
  182. # Using the EventRateLimit admission control enforces a limit on the number of events
  183. # that the API Server will accept in a given time period
  184. # Available as of v1.0.0
  185. event_rate_limit:
  186. enabled: true
  187. configuration:
  188. apiVersion: eventratelimit.admission.k8s.io/v1alpha1
  189. kind: Configuration
  190. limits:
  191. - type: Server
  192. qps: 6000
  193. burst: 30000
  194. # Enable AlwaysPullImages Admission controller plugin
  195. # Available as of v0.2.0
  196. always_pull_images: false
  197. # Add additional arguments to the kubernetes API server
  198. # This WILL OVERRIDE any existing defaults
  199. extra_args:
  200. # Enable audit log to stdout
  201. audit-log-path: "-"
  202. # Increase number of delete workers
  203. delete-collection-workers: 3
  204. # Set the level of log output to debug-level
  205. v: 4
  206. # Note for Rancher 2 users: If you are configuring Cluster Options
  207. # using a Config File when creating Rancher Launched Kubernetes,
  208. # the names of services should contain underscores only:
  209. # `kube_controller`. This only applies to Rancher v2.0.5 and v2.0.6.
  210. kube-controller:
  211. # CIDR pool used to assign IP addresses to pods in the cluster
  212. cluster_cidr: 10.42.0.0/16
  213. # IP range for any services created on Kubernetes
  214. # This must match the service_cluster_ip_range in kube-api
  215. service_cluster_ip_range: 10.43.0.0/16
  216. # Add additional arguments to the kubernetes API server
  217. # This WILL OVERRIDE any existing defaults
  218. extra_args:
  219. # Set the level of log output to debug-level
  220. v: 4
  221. # Enable RotateKubeletServerCertificate feature gate
  222. feature-gates: RotateKubeletServerCertificate=true
  223. # Enable TLS Certificates management
  224. # https://kubernetes.io/docs/tasks/tls/managing-tls-in-a-cluster/
  225. cluster-signing-cert-file: "/etc/kubernetes/ssl/kube-ca.pem"
  226. cluster-signing-key-file: "/etc/kubernetes/ssl/kube-ca-key.pem"
  227. kubelet:
  228. # Base domain for the cluster
  229. cluster_domain: cluster.local
  230. # IP address for the DNS service endpoint
  231. cluster_dns_server: 10.43.0.10
  232. # Fail if swap is on
  233. fail_swap_on: false
  234. # Configure pod-infra-container-image argument
  235. pod-infra-container-image: "k8s.gcr.io/pause:3.2"
  236. # Generate a certificate signed by the kube-ca Certificate Authority
  237. # for the kubelet to use as a server certificate
  238. # Available as of v1.0.0
  239. generate_serving_certificate: true
  240. extra_args:
  241. # Set max pods to 250 instead of default 110
  242. max-pods: 250
  243. # Enable RotateKubeletServerCertificate feature gate
  244. feature-gates: RotateKubeletServerCertificate=true
  245. # Optionally define additional volume binds to a service
  246. extra_binds:
  247. - "/usr/libexec/kubernetes/kubelet-plugins:/usr/libexec/kubernetes/kubelet-plugins"
  248. scheduler:
  249. extra_args:
  250. # Set the level of log output to debug-level
  251. v: 4
  252. kubeproxy:
  253. extra_args:
  254. # Set the level of log output to debug-level
  255. v: 4
  256. # Currently, only authentication strategy supported is x509.
  257. # You can optionally create additional SANs (hostnames or IPs) to
  258. # add to the API server PKI certificate.
  259. # This is useful if you want to use a load balancer for the
  260. # control plane servers.
  261. authentication:
  262. strategy: x509
  263. sans:
  264. - "10.18.160.10"
  265. - "my-loadbalancer-1234567890.us-west-2.elb.amazonaws.com"
  266. # Kubernetes Authorization mode
  267. # Use `mode: rbac` to enable RBAC
  268. # Use `mode: none` to disable authorization
  269. authorization:
  270. mode: rbac
  271. # If you want to set a Kubernetes cloud provider, you specify
  272. # the name and configuration
  273. cloud_provider:
  274. name: aws
  275. # Add-ons are deployed using kubernetes jobs. RKE will give
  276. # up on trying to get the job status after this timeout in seconds..
  277. addon_job_timeout: 30
  278. # Specify network plugin-in (canal, calico, flannel, weave, or none)
  279. network:
  280. plugin: canal
  281. # Specify MTU
  282. mtu: 1400
  283. options:
  284. # Configure interface to use for Canal
  285. canal_iface: eth1
  286. canal_flannel_backend_type: vxlan
  287. # Available as of v1.2.6
  288. canal_autoscaler_priority_class_name: system-cluster-critical
  289. canal_priority_class_name: system-cluster-critical
  290. # Available as of v1.2.4
  291. tolerations:
  292. - key: "node.kubernetes.io/unreachable"
  293. operator: "Exists"
  294. effect: "NoExecute"
  295. tolerationseconds: 300
  296. - key: "node.kubernetes.io/not-ready"
  297. operator: "Exists"
  298. effect: "NoExecute"
  299. tolerationseconds: 300
  300. # Available as of v1.1.0
  301. update_strategy:
  302. strategy: RollingUpdate
  303. rollingUpdate:
  304. maxUnavailable: 6
  305. # Specify DNS provider (coredns or kube-dns)
  306. dns:
  307. provider: coredns
  308. # Available as of v1.1.0
  309. update_strategy:
  310. strategy: RollingUpdate
  311. rollingUpdate:
  312. maxUnavailable: 20%
  313. maxSurge: 15%
  314. linear_autoscaler_params:
  315. cores_per_replica: 0.34
  316. nodes_per_replica: 4
  317. prevent_single_point_failure: true
  318. min: 2
  319. max: 3
  320. # Specify monitoring provider (metrics-server)
  321. monitoring:
  322. provider: metrics-server
  323. # Available as of v1.1.0
  324. update_strategy:
  325. strategy: RollingUpdate
  326. rollingUpdate:
  327. maxUnavailable: 8
  328. # Currently only nginx ingress provider is supported.
  329. # To disable ingress controller, set `provider: none`
  330. # `node_selector` controls ingress placement and is optional
  331. ingress:
  332. provider: nginx
  333. node_selector:
  334. app: ingress
  335. # Available as of v1.1.0
  336. update_strategy:
  337. strategy: RollingUpdate
  338. rollingUpdate:
  339. maxUnavailable: 5
  340. # All add-on manifests MUST specify a namespace
  341. addons: |-
  342. ---
  343. apiVersion: v1
  344. kind: Pod
  345. metadata:
  346. name: my-nginx
  347. namespace: default
  348. spec:
  349. containers:
  350. - name: my-nginx
  351. image: nginx
  352. ports:
  353. - containerPort: 80
  354. addons_include:
  355. - https://raw.githubusercontent.com/rook/rook/master/cluster/examples/kubernetes/rook-operator.yaml
  356. - https://raw.githubusercontent.com/rook/rook/master/cluster/examples/kubernetes/rook-cluster.yaml
  357. - /path/to/manifest