RKE 使用 cluster.yml 文件安装和配置您的 Kubernetes 集群。

    本模板旨在用于 RKE 插件安装,只支持到 Rancher v2.0.8。如果您要安装更新的 Rancher 版本,请使用 Rancher Helm chart。有关详细信息,请参阅Kubernetes 安装-安装大纲

    如果您使用配置如下所示,您可以使用这个 cluster.yml 模板安装和配置集群。

    详情请参考RKE 文档

    1. nodes:
    2. - address: <IP> # hostname or IP to access nodes
    3. user: <USER> # root user (usually 'root')
    4. role: [controlplane, etcd, worker] # K8s roles for node
    5. ssh_key_path: <PEM_FILE> # path to PEM file
    6. - address: <IP>
    7. user: <USER>
    8. role: [controlplane, etcd, worker]
    9. ssh_key_path: <PEM_FILE>
    10. - address: <IP>
    11. user: <USER>
    12. role: [controlplane, etcd, worker]
    13. ssh_key_path: <PEM_FILE>
    14. services:
    15. etcd:
    16. snapshot: true
    17. creation: 6h
    18. retention: 24h
    19. addons: |-
    20. ---
    21. kind: Namespace
    22. apiVersion: v1
    23. metadata:
    24. name: cattle-system
    25. ---
    26. kind: ServiceAccount
    27. apiVersion: v1
    28. metadata:
    29. name: cattle-admin
    30. namespace: cattle-system
    31. ---
    32. kind: ClusterRoleBinding
    33. apiVersion: rbac.authorization.k8s.io/v1
    34. metadata:
    35. name: cattle-crb
    36. namespace: cattle-system
    37. subjects:
    38. - kind: ServiceAccount
    39. name: cattle-admin
    40. namespace: cattle-system
    41. roleRef:
    42. kind: ClusterRole
    43. name: cluster-admin
    44. apiGroup: rbac.authorization.k8s.io
    45. ---
    46. apiVersion: v1
    47. kind: Service
    48. metadata:
    49. namespace: cattle-system
    50. name: cattle-service
    51. labels:
    52. app: cattle
    53. spec:
    54. ports:
    55. - port: 80
    56. targetPort: 80
    57. protocol: TCP
    58. name: http
    59. selector:
    60. app: cattle
    61. ---
    62. apiVersion: extensions/v1beta1
    63. kind: Ingress
    64. metadata:
    65. namespace: cattle-system
    66. name: cattle-ingress-http
    67. annotations:
    68. nginx.ingress.kubernetes.io/proxy-connect-timeout: "30"
    69. nginx.ingress.kubernetes.io/proxy-read-timeout: "1800" # Max time in seconds for ws to remain shell window open
    70. nginx.ingress.kubernetes.io/proxy-send-timeout: "1800" # Max time in seconds for ws to remain shell window open
    71. nginx.ingress.kubernetes.io/ssl-redirect: "false" # Disable redirect to ssl
    72. spec:
    73. rules:
    74. - host: <FQDN>
    75. http:
    76. paths:
    77. - backend:
    78. serviceName: cattle-service
    79. servicePort: 80
    80. ---
    81. kind: Deployment
    82. apiVersion: extensions/v1beta1
    83. metadata:
    84. namespace: cattle-system
    85. name: cattle
    86. spec:
    87. replicas: 1
    88. template:
    89. metadata:
    90. labels:
    91. app: cattle
    92. spec:
    93. serviceAccountName: cattle-admin
    94. containers:
    95. # Rancher install via RKE addons is only supported up to v2.0.8
    96. - image: rancher/rancher:v2.0.8
    97. args:
    98. - --no-cacerts
    99. imagePullPolicy: Always
    100. name: cattle-server
    101. # env:
    102. # - name: HTTP_PROXY
    103. # value: "http://your_proxy_address:port"
    104. # - name: HTTPS_PROXY
    105. # value: "http://your_proxy_address:port"
    106. # - name: NO_PROXY
    107. # value: "localhost,127.0.0.1,0.0.0.0,10.43.0.0/16,your_network_ranges_that_dont_need_proxy_to_access"
    108. livenessProbe:
    109. httpGet:
    110. path: /ping
    111. port: 80
    112. initialDelaySeconds: 60
    113. periodSeconds: 60
    114. readinessProbe:
    115. httpGet:
    116. path: /ping
    117. port: 80
    118. initialDelaySeconds: 20
    119. periodSeconds: 10
    120. ports:
    121. - containerPort: 80
    122. protocol: TCP