install_descheduler.yaml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. ---
  2. - name: Add descheduler project
  3. oc_project:
  4. state: present
  5. name: openshift-descheduler
  6. node_selector: ""
  7. description: Descheduler
  8. - name: create descheduler service account
  9. oc_serviceaccount:
  10. name: "{{ openshift_descheduler_service_account }}"
  11. namespace: openshift-descheduler
  12. state: present
  13. - name: create descheduler cluster role
  14. oc_clusterrole:
  15. state: present
  16. name: "{{ openshift_descheduler_cluster_role_name }}"
  17. rules:
  18. - apiGroups: [""]
  19. resources: ["nodes"]
  20. verbs: ["get", "list", "watch"]
  21. - apiGroups: [""]
  22. resources: ["pods"]
  23. verbs: ["get", "list", "watch", "delete"]
  24. - apiGroups: [""]
  25. resources: ["pods/eviction"]
  26. verbs: ["create"]
  27. #- name: copy descheduler cluster role file
  28. # copy:
  29. # src: "{{ item }}"
  30. # dest: "{{ openshift_descheduler_tmp_location }}/{{ item }}"
  31. # with_items:
  32. # - clusterrole.yml
  33. # when: openshift_descheduler_state == 'present'
  34. #- name: "Ensure descheduler cluster roles are {{ openshift_descheduler_state }}"
  35. # oc_obj:
  36. # namespace: openshift-descheduler
  37. # state: present
  38. # kind: "{{ item.type }}"
  39. # name: "{{ item.name }}"
  40. # delete_after: "{{ openshift_descheduler_delete_config }}"
  41. # files:
  42. # - "{{ openshift_descheduler_tmp_location }}/{{ item.fname }}"
  43. # with_items:
  44. # - fname: clusterrole.yml
  45. # type: clusterrole
  46. # name: "{{ openshift_descheduler_name }}"
  47. - name: bind descheduler cluster role to its service account
  48. oc_adm_policy_user:
  49. state: present
  50. user: "system:serviceaccount:openshift-descheduler:{{ openshift_descheduler_service_account }}"
  51. namespace: openshift-descheduler
  52. resource_kind: cluster-role
  53. resource_name: "{{ openshift_descheduler_cluster_role_name }}"
  54. - name: copy descheduler policy template to tmp dir
  55. template:
  56. src: policy.yaml.j2
  57. dest: "{{ openshift_descheduler_tmp_location }}/policy.yaml"
  58. when: openshift_descheduler_install | bool
  59. - name: create descheduler policy configmap
  60. oc_configmap:
  61. state: present
  62. name: "{{ openshift_descheduler_policy_configmap_name }}"
  63. namespace: openshift-descheduler
  64. from_file:
  65. policy.yaml: "{{ openshift_descheduler_tmp_location }}/policy.yaml"
  66. - name: copy the cronjob file for descheduler
  67. template:
  68. src: descheduler-cronjob.yaml.j2
  69. dest: "{{ openshift_descheduler_tmp_location }}/descheduler-cronjob.yaml"
  70. when: openshift_descheduler_install | bool
  71. - name: Ensure the descheduler is present
  72. oc_obj:
  73. namespace: openshift-descheduler
  74. state: present
  75. kind: cronjob
  76. name: "{{ openshift_descheduler_cronjob_name }}"
  77. delete_after: "{{ openshift_descheduler_delete_config }}"
  78. files:
  79. - "{{ openshift_descheduler_tmp_location }}/descheduler-cronjob.yaml"