您可通过编辑 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. ssh_key_path: /home/user/.ssh/id_rsa
  8. port: 2222
  9. - address: 2.2.2.2
  10. user: ubuntu
  11. role:
  12. - worker
  13. ssh_key: |-
  14. -----BEGIN RSA PRIVATE KEY-----
  15. -----END RSA PRIVATE KEY-----
  16. - address: example.com
  17. user: ubuntu
  18. role:
  19. - worker
  20. hostname_override: node3
  21. internal_address: 192.168.1.6
  22. labels:
  23. app: ingress
  24. # 默认值为false,如果设置为true,当发现不支持的Docker版本时,RKE不会报错
  25. ignore_docker_version: false
  26. # 集群级SSH私钥,如果没有为节点设置ssh信息则使用该私钥
  27. ssh_key_path: ~/.ssh/test
  28. # 启用SSH代理,使用带有密码的SSH私钥
  29. # 这需要配置环境`SSH_AUTH_SOCK`,指向已添加私钥的SSH代理
  30. ssh_agent_auth: true
  31. # 镜像仓库凭证列表
  32. # 如果你使用的是Docker Hub注册表,
  33. # 你可以省略`url`
  34. # 或者设置为`docker.io`is_default设置为`true`
  35. # 将覆盖全局设置中设置的系统默认注册表
  36. private_registries:
  37. - url: registry.com
  38. user: Username # 请替换为真实的用户名
  39. password: password # 请替换为真实的密码
  40. is_default: true
  41. # 堡垒机配置
  42. bastion_host:
  43. address: x.x.x.x
  44. user: ubuntu
  45. port: 22
  46. ssh_key_path: /home/user/.ssh/bastion_rsa
  47. # or
  48. # ssh_key: |-
  49. # -----BEGIN RSA PRIVATE KEY-----
  50. #
  51. # -----END RSA PRIVATE KEY-----
  52. # Set the name of the Kubernetes cluster
  53. cluster_name: mycluster
  54. # The Kubernetes version used. The default versions of Kubernetes
  55. # are tied to specific versions of the system images.
  56. #
  57. # For RKE v0.2.x and below, the map of Kubernetes versions and their system images is
  58. # located here:
  59. # https://github.com/rancher/types/blob/release/v2.2/apis/management.cattle.io/v3/k8s_defaults.go
  60. #
  61. # For RKE v0.3.0 and above, the map of Kubernetes versions and their system images is
  62. # located here:
  63. # https://github.com/rancher/kontainer-driver-metadata/blob/master/rke/k8s_rke_system_images.go
  64. #
  65. # In case the kubernetes_version and kubernetes image in
  66. # system_images are defined, the system_images configuration
  67. # will take precedence over kubernetes_version.
  68. kubernetes_version: v1.10.3-rancher2
  69. # System Images are defaulted to a tag that is mapped to a specific
  70. # Kubernetes Version and not required in a cluster.yml.
  71. # Each individual system image can be specified if you want to use a different tag.
  72. #
  73. # For RKE v0.2.x and below, the map of Kubernetes versions and their system images is
  74. # located here:
  75. # https://github.com/rancher/types/blob/release/v2.2/apis/management.cattle.io/v3/k8s_defaults.go
  76. #
  77. # For RKE v0.3.0 and above, the map of Kubernetes versions and their system images is
  78. # located here:
  79. # https://github.com/rancher/kontainer-driver-metadata/blob/master/rke/k8s_rke_system_images.go
  80. #
  81. system_images:
  82. kubernetes: rancher/hyperkube:v1.10.3-rancher2
  83. etcd: rancher/coreos-etcd:v3.1.12
  84. alpine: rancher/rke-tools:v0.1.9
  85. nginx_proxy: rancher/rke-tools:v0.1.9
  86. cert_downloader: rancher/rke-tools:v0.1.9
  87. kubernetes_services_sidecar: rancher/rke-tools:v0.1.9
  88. kubedns: rancher/k8s-dns-kube-dns-amd64:1.14.8
  89. dnsmasq: rancher/k8s-dns-dnsmasq-nanny-amd64:1.14.8
  90. kubedns_sidecar: rancher/k8s-dns-sidecar-amd64:1.14.8
  91. kubedns_autoscaler: rancher/cluster-proportional-autoscaler-amd64:1.0.0
  92. pod_infra_container: rancher/pause-amd64:3.1
  93. services:
  94. etcd:
  95. # if external etcd is used
  96. # path: /etcdcluster
  97. # external_urls:
  98. # - https://etcd-example.com:2379
  99. # ca_cert: |-
  100. # -----BEGIN CERTIFICATE-----
  101. # xxxxxxxxxx
  102. # -----END CERTIFICATE-----
  103. # cert: |-
  104. # -----BEGIN CERTIFICATE-----
  105. # xxxxxxxxxx
  106. # -----END CERTIFICATE-----
  107. # key: |-
  108. # -----BEGIN PRIVATE KEY-----
  109. # xxxxxxxxxx
  110. # -----END PRIVATE KEY-----
  111. # Note for Rancher v2.0.5 and v2.0.6 users: If you are configuring
  112. # Cluster Options using a Config File when creating Rancher Launched
  113. # Kubernetes, the names of services should contain underscores
  114. # only: `kube_api`.
  115. kube-api:
  116. # IP range for any services created on Kubernetes
  117. # This must match the service_cluster_ip_range in kube-controller
  118. service_cluster_ip_range: 10.43.0.0/16
  119. # Expose a different port range for NodePort services
  120. service_node_port_range: 30000-32767
  121. pod_security_policy: false
  122. # Add additional arguments to the kubernetes API server
  123. # This WILL OVERRIDE any existing defaults
  124. extra_args:
  125. # Enable audit log to stdout
  126. audit-log-path: "-"
  127. # Increase number of delete workers
  128. delete-collection-workers: 3
  129. # Set the level of log output to debug-level
  130. v: 4
  131. # Note for Rancher 2 users: If you are configuring Cluster Options
  132. # using a Config File when creating Rancher Launched Kubernetes,
  133. # the names of services should contain underscores only:
  134. # `kube_controller`. This only applies to Rancher v2.0.5 and v2.0.6.
  135. kube-controller:
  136. # CIDR pool used to assign IP addresses to pods in the cluster
  137. cluster_cidr: 10.42.0.0/16
  138. # IP range for any services created on Kubernetes
  139. # This must match the service_cluster_ip_range in kube-api
  140. service_cluster_ip_range: 10.43.0.0/16
  141. kubelet:
  142. # Base domain for the cluster
  143. cluster_domain: cluster.local
  144. # IP address for the DNS service endpoint
  145. cluster_dns_server: 10.43.0.10
  146. # Fail if swap is on
  147. fail_swap_on: false
  148. # Set max pods to 250 instead of default 110
  149. extra_args:
  150. max-pods: 250
  151. # Optionally define additional volume binds to a service
  152. extra_binds:
  153. - "/usr/libexec/kubernetes/kubelet-plugins:/usr/libexec/kubernetes/kubelet-plugins"
  154. # Currently, only authentication strategy supported is x509.
  155. # You can optionally create additional SANs (hostnames or IPs) to
  156. # add to the API server PKI certificate.
  157. # This is useful if you want to use a load balancer for the
  158. # control plane servers.
  159. authentication:
  160. strategy: x509
  161. sans:
  162. - "10.18.160.10"
  163. - "my-loadbalancer-1234567890.us-west-2.elb.amazonaws.com"
  164. # Kubernetes Authorization mode
  165. # Use `mode: rbac` to enable RBAC
  166. # Use `mode: none` to disable authorization
  167. authorization:
  168. mode: rbac
  169. # If you want to set a Kubernetes cloud provider, you specify
  170. # the name and configuration
  171. cloud_provider:
  172. name: aws
  173. # Add-ons are deployed using kubernetes jobs. RKE will give
  174. # up on trying to get the job status after this timeout in seconds..
  175. addon_job_timeout: 30
  176. # Specify network plugin-in (canal, calico, flannel, weave, or none)
  177. network:
  178. plugin: canal
  179. # Specify DNS provider (coredns or kube-dns)
  180. dns:
  181. provider: coredns
  182. # Currently only nginx ingress provider is supported.
  183. # To disable ingress controller, set `provider: none`
  184. # `node_selector` controls ingress placement and is optional
  185. ingress:
  186. provider: nginx
  187. node_selector:
  188. app: ingress
  189. # All add-on manifests MUST specify a namespace
  190. addons: |-
  191. ---
  192. apiVersion: v1
  193. kind: Pod
  194. metadata:
  195. name: my-nginx
  196. namespace: default
  197. spec:
  198. containers:
  199. - name: my-nginx
  200. image: nginx
  201. ports:
  202. - containerPort: 80
  203. addons_include:
  204. - https://raw.githubusercontent.com/rook/rook/master/cluster/examples/kubernetes/rook-operator.yaml
  205. - https://raw.githubusercontent.com/rook/rook/master/cluster/examples/kubernetes/rook-cluster.yaml
  206. - /path/to/manifest