Heat templates for deploying OpenStack
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

156 lines
5.8KB

  1. heat_template_version: ocata
  2. description: Triggers a Mistral workflow for the deployment of Kubernetes
  3. parameters:
  4. RoleNetIpMap:
  5. default: {}
  6. type: json
  7. ServiceData:
  8. default: {}
  9. description: Dictionary packing service data
  10. type: json
  11. ServiceNetMap:
  12. default: {}
  13. description: Mapping of service_name -> network name. Typically set
  14. via parameter_defaults in the resource registry. This
  15. mapping overrides those in ServiceNetMapDefaults.
  16. type: json
  17. DefaultPasswords:
  18. default: {}
  19. type: json
  20. RoleName:
  21. default: ''
  22. description: Role name on which the service is applied
  23. type: string
  24. RoleParameters:
  25. default: {}
  26. description: Parameters specific to the role
  27. type: json
  28. EndpointMap:
  29. default: {}
  30. description: Mapping of service endpoint -> protocol. Typically set
  31. via parameter_defaults in the resource registry.
  32. type: json
  33. outputs:
  34. role_data:
  35. description: Role data for the Kubernetes Service
  36. value:
  37. service_name: kubernetes_master
  38. config_settings:
  39. tripleo.kubernetes_master.firewall_rules:
  40. '200 kubernetes-master api':
  41. dport: 6443
  42. proto: tcp
  43. '200 kubernetes-master etcd':
  44. dport:
  45. - 2379
  46. - 2380
  47. proto: tcp
  48. '200 kubernetes-master flannel':
  49. dport:
  50. - 8285
  51. - 8472
  52. proto: udp
  53. upgrade_tasks: []
  54. step_config: ''
  55. external_deploy_tasks:
  56. # FIXME: remove this block when kubespray is packaged
  57. - name: kubernetes_master step 2 kubespray repository
  58. when: step == '2'
  59. block:
  60. - name: check kubespray directory existence
  61. stat:
  62. path: /usr/share/kubespray
  63. register: kubespray_stat
  64. - name: clone kubespray repo
  65. git:
  66. repo: https://github.com/kubernetes-incubator/kubespray
  67. dest: /usr/share/kubespray
  68. update: no
  69. become: yes
  70. become_user: root
  71. when: not kubespray_stat.stat.exists
  72. - name: kubernetes_master step 2
  73. when: step == '2'
  74. block:
  75. - name: create kubespray temp dirs
  76. file:
  77. path: "{{item}}"
  78. state: directory
  79. with_items:
  80. - "{{playbook_dir}}/kubespray"
  81. - "{{playbook_dir}}/kubespray/artifacts"
  82. - name: generate kubespray inventory
  83. copy:
  84. dest: "{{playbook_dir}}/kubespray/inventory.yml"
  85. content: |
  86. kube-master:
  87. hosts:
  88. {% for host in groups['kubernetes_master'] -%}
  89. {{ hostvars.raw_get(host)['ansible_hostname'] }}:
  90. ansible_user: {{ hostvars.raw_get(host)['ansible_user'] | default(hostvars.raw_get(host)['ansible_ssh_user']) | default('root') }}
  91. ansible_host: {{ hostvars.raw_get(host)['ansible_host'] | default(host) }}
  92. {% endfor %}
  93. kube-node:
  94. hosts:
  95. {% for host in groups['kubernetes_worker'] -%}
  96. {{ hostvars.raw_get(host)['ansible_hostname'] }}:
  97. ansible_user: {{ hostvars.raw_get(host)['ansible_user'] | default(hostvars.raw_get(host)['ansible_ssh_user']) | default('root') }}
  98. ansible_host: {{ hostvars.raw_get(host)['ansible_host'] | default(host) }}
  99. {% endfor %}
  100. etcd:
  101. children:
  102. kube-master: {}
  103. k8s-cluster:
  104. children:
  105. kube-master: {}
  106. kube-node: {}
  107. - name: generate kubespray global vars
  108. copy:
  109. dest: "{{playbook_dir}}/kubespray/global_vars.yml"
  110. content: |
  111. kubeconfig_localhost: true
  112. kubectl_localhost: true
  113. artifacts_dir: '{{playbook_dir}}/kubespray/artifacts'
  114. - name: generate kubespray playbook
  115. copy:
  116. dest: "{{playbook_dir}}/kubespray/playbook.yml"
  117. content: |
  118. - include: /usr/share/kubespray/cluster.yml
  119. - name: set kubespray command
  120. set_fact:
  121. # NOTE: We could let kubespray configure docker
  122. # (remove --skip-tags docker) and run it in step 1
  123. # when this RFE is implemented:
  124. # https://github.com/kubernetes-incubator/kubespray/issues/1836
  125. kubespray_command: >-
  126. {%- if kubespray_command is defined -%}
  127. {{kubespray_command}}
  128. {%- else -%}
  129. ansible-playbook
  130. -b
  131. -i '{{playbook_dir}}/kubespray/inventory.yml'
  132. --skip-tags docker,bastion-ssh-config
  133. --extra-vars '@{{playbook_dir}}/kubespray/global_vars.yml'
  134. '{{playbook_dir}}/kubespray/playbook.yml'
  135. {%- endif -%}
  136. - name: print kubespray command
  137. debug:
  138. var: kubespray_command
  139. - name: run kubespray (immediate log at {{playbook_dir}}/kubespray/playbook.log)
  140. shell: |
  141. {{kubespray_command}} 2>&1 | tee {{playbook_dir}}/kubespray/playbook.log
  142. exit ${PIPESTATUS[0]}
  143. register: outputs
  144. - name: print kubespray outputs
  145. debug:
  146. var: (outputs.stderr|default('')).split('\n')|union(outputs.stdout_lines|default([]))
  147. failed_when: outputs|failed
  148. when: outputs is defined