RKE 使用 cluster.yml 文件安装和配置您的 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: Secret
    48. metadata:
    49. name: cattle-keys-ingress
    50. namespace: cattle-system
    51. type: Opaque
    52. data:
    53. tls.crt: <BASE64_CRT> # ssl cert for ingress. If selfsigned, must be signed by same CA as cattle server
    54. tls.key: <BASE64_KEY> # ssl key for ingress. If selfsigned, must be signed by same CA as cattle server
    55. ---
    56. apiVersion: v1
    57. kind: Secret
    58. metadata:
    59. name: cattle-keys-server
    60. namespace: cattle-system
    61. type: Opaque
    62. data:
    63. cacerts.pem: <BASE64_CA> # CA cert used to sign cattle server cert and key
    64. ---
    65. apiVersion: v1
    66. kind: Service
    67. metadata:
    68. namespace: cattle-system
    69. name: cattle-service
    70. labels:
    71. app: cattle
    72. spec:
    73. ports:
    74. - port: 80
    75. targetPort: 80
    76. protocol: TCP
    77. name: http
    78. - port: 443
    79. targetPort: 443
    80. protocol: TCP
    81. name: https
    82. selector:
    83. app: cattle
    84. ---
    85. apiVersion: extensions/v1beta1
    86. kind: Ingress
    87. metadata:
    88. namespace: cattle-system
    89. name: cattle-ingress-http
    90. annotations:
    91. nginx.ingress.kubernetes.io/proxy-connect-timeout: "30"
    92. nginx.ingress.kubernetes.io/proxy-read-timeout: "1800" # Max time in seconds for ws to remain shell window open
    93. nginx.ingress.kubernetes.io/proxy-send-timeout: "1800" # Max time in seconds for ws to remain shell window open
    94. spec:
    95. rules:
    96. - host: <FQDN> # FQDN to access cattle server
    97. http:
    98. paths:
    99. - backend:
    100. serviceName: cattle-service
    101. servicePort: 80
    102. tls:
    103. - secretName: cattle-keys-ingress
    104. hosts:
    105. - <FQDN> # FQDN to access cattle server
    106. ---
    107. kind: Deployment
    108. apiVersion: extensions/v1beta1
    109. metadata:
    110. namespace: cattle-system
    111. name: cattle
    112. spec:
    113. replicas: 1
    114. template:
    115. metadata:
    116. labels:
    117. app: cattle
    118. spec:
    119. serviceAccountName: cattle-admin
    120. containers:
    121. # Rancher install via RKE addons is only supported up to v2.0.8
    122. - image: rancher/rancher:v2.0.8
    123. imagePullPolicy: Always
    124. name: cattle-server
    125. # env:
    126. # - name: HTTP_PROXY
    127. # value: "http://your_proxy_address:port"
    128. # - name: HTTPS_PROXY
    129. # value: "http://your_proxy_address:port"
    130. # - name: NO_PROXY
    131. # value: "localhost,127.0.0.1,0.0.0.0,10.43.0.0/16,your_network_ranges_that_dont_need_proxy_to_access"
    132. livenessProbe:
    133. httpGet:
    134. path: /ping
    135. port: 80
    136. initialDelaySeconds: 60
    137. periodSeconds: 60
    138. readinessProbe:
    139. httpGet:
    140. path: /ping
    141. port: 80
    142. initialDelaySeconds: 20
    143. periodSeconds: 10
    144. ports:
    145. - containerPort: 80
    146. protocol: TCP
    147. - containerPort: 443
    148. protocol: TCP
    149. volumeMounts:
    150. - mountPath: /etc/rancher/ssl
    151. name: cattle-keys-volume
    152. readOnly: true
    153. volumes:
    154. - name: cattle-keys-volume
    155. secret:
    156. defaultMode: 420
    157. secretName: cattle-keys-server