Browse Source

Add openshift-descheduler project.

Avesh Agarwal 7 years ago
parent
commit
0963508c9c

+ 0 - 1
roles/openshift_descheduler/defaults/main.yaml

@@ -1,7 +1,6 @@
 ---
 # descheduler common setup
 openshift_descheduler_state: present
-openshift_descheduler_namespace: openshift-infra
 openshift_descheduler_tmp_location: /tmp
 openshift_descheduler_delete_config: True
 

+ 13 - 6
roles/openshift_descheduler/tasks/install_descheduler.yaml

@@ -1,8 +1,15 @@
 ---
+- name: Add descheduler project
+  oc_project:
+    state: present
+    name: openshift-descheduler
+    node_selector: ""
+    description: Descheduler
+
 - name: create descheduler service account
   oc_serviceaccount:
     name: "{{ openshift_descheduler_service_account }}"
-    namespace: "{{ openshift_descheduler_namespace }}"
+    namespace: openshift-descheduler
     state: present
 
 - name: create descheduler cluster role
@@ -30,7 +37,7 @@
 
 #- name: "Ensure descheduler cluster roles are {{ openshift_descheduler_state }}"
 #  oc_obj:
-#    namespace: "{{ openshift_descheduler_namespace }}"
+#    namespace: openshift-descheduler
 #    state: present
 #    kind: "{{ item.type }}"
 #    name: "{{ item.name }}"
@@ -45,8 +52,8 @@
 - name: bind descheduler cluster role to its service account
   oc_adm_policy_user:
     state: present
-    user: "system:serviceaccount:openshift-infra:{{ openshift_descheduler_service_account }}"
-    namespace: "{{ openshift_descheduler_namespace }}"
+    user: "system:serviceaccount:openshift-descheduler:{{ openshift_descheduler_service_account }}"
+    namespace: openshift-descheduler
     resource_kind: cluster-role
     resource_name: "{{ openshift_descheduler_cluster_role_name }}"
 
@@ -60,7 +67,7 @@
   oc_configmap:
     state: present
     name: "{{ openshift_descheduler_policy_configmap_name }}"
-    namespace: "{{ openshift_descheduler_namespace }}"
+    namespace: openshift-descheduler
     from_file:
       policy.yaml: "{{ openshift_descheduler_tmp_location }}/policy.yaml"
 
@@ -72,7 +79,7 @@
 
 - name: "Ensure the descheduler is {{ openshift_descheduler_state }}"
   oc_obj:
-    namespace: "{{ openshift_descheduler_namespace }}"
+    namespace: openshift-descheduler
     state: present
     kind: cronjob
     name: "{{ openshift_descheduler_cronjob_name }}"

+ 4 - 25
roles/openshift_descheduler/tasks/uninstall_descheduler.yaml

@@ -1,32 +1,11 @@
 ---
-- name: remove descheduler service account
-  oc_serviceaccount:
-    name: "{{ openshift_descheduler_service_account }}"
-    namespace: "{{ openshift_descheduler_namespace }}"
+# remove namespace - This will delete all the objects inside the namespace
+- name: Remove openshift-descheduler project
+  oc_project:
     state: absent
+    name: openshift-descheduler
 
 - name: remove descheduler cluster role
   oc_clusterrole:
     state: absent
     name: "{{ openshift_descheduler_cluster_role_name }}"
-
-- name: remove binding of descheduler cluster role to its service account
-  oc_adm_policy_user:
-    state: absent
-    user: "system:serviceaccount:openshift-infra:{{ openshift_descheduler_service_account }}"
-    namespace: "{{ openshift_descheduler_namespace }}"
-    resource_kind: cluster-role
-    resource_name: "{{ openshift_descheduler_cluster_role_name }}"
-
-- name: remove descheduler policy configmap
-  oc_configmap:
-    state: absent
-    name: "{{ openshift_descheduler_policy_configmap_name }}"
-    namespace: "{{ openshift_descheduler_namespace }}"
-
-- name: "Ensure the descheduler is {{ openshift_descheduler_state }}"
-  oc_obj:
-    namespace: "{{ openshift_descheduler_namespace }}"
-    state: absent
-    kind: cronjob
-    name: "{{ openshift_descheduler_cronjob_name }}"

+ 1 - 1
roles/openshift_descheduler/tasks/upgrade.yaml

@@ -4,7 +4,7 @@
     state: list
     kind: cronjob
     name: "{{ openshift_descheduler_cronjob_name }}"
-    namespace: "{{ openshift_descheduler_namespace }}"
+    namespace: openshift-descheduler
   register: descheduler_cronjob
 
 - name: Upgrade descheduler cronjob

+ 1 - 1
roles/openshift_descheduler/templates/descheduler-cronjob.yaml.j2

@@ -2,7 +2,7 @@ apiVersion: batch/v1beta1
 kind: CronJob
 metadata:
   name: "{{ openshift_descheduler_cronjob_name }}"
-  namespace: "{{ openshift_descheduler_namespace }}"
+  namespace: openshift-descheduler
 spec:
   schedule: "{{ openshift_descheduler_cronjob_schedule }}"
   jobTemplate: