From 8eb713c59233e348f20a39ac249d0131d5fa4ed5 Mon Sep 17 00:00:00 2001 From: wanjunlei Date: Wed, 25 Oct 2023 16:03:39 +0800 Subject: [PATCH] fix bug monitoring task failed when updating from v3.3.x to v3.4.0 Signed-off-by: wanjunlei --- .../files/federated/federatednamespaces.yaml | 133 ------------------ .../tasks/notification-manager.yaml | 43 ------ .../kubesphere-monitoring-federated.yaml | 0 .../notification}/update_federated_crds.sh | 0 roles/ks-multicluster/tasks/main.yml | 1 + .../tasks/notification-manager.yaml | 24 ++++ 6 files changed, 25 insertions(+), 176 deletions(-) delete mode 100644 roles/ks-monitor/files/federated/federatednamespaces.yaml rename roles/{ks-monitor/files/federated => ks-multicluster/files/notification}/kubesphere-monitoring-federated.yaml (100%) rename roles/{ks-monitor/files/federated => ks-multicluster/files/notification}/update_federated_crds.sh (100%) create mode 100644 roles/ks-multicluster/tasks/notification-manager.yaml diff --git a/roles/ks-monitor/files/federated/federatednamespaces.yaml b/roles/ks-monitor/files/federated/federatednamespaces.yaml deleted file mode 100644 index b8830d31a..000000000 --- a/roles/ks-monitor/files/federated/federatednamespaces.yaml +++ /dev/null @@ -1,133 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: federatednamespaces.types.kubefed.io -spec: - group: types.kubefed.io - names: - kind: FederatedNamespace - plural: federatednamespaces - shortNames: - - fns - scope: Namespaced - versions: - - name: v1beta1 - schema: - openAPIV3Schema: - properties: - apiVersion: - type: string - kind: - type: string - metadata: - type: object - spec: - properties: - overrides: - items: - properties: - clusterName: - type: string - clusterOverrides: - items: - properties: - op: - pattern: ^(add|remove|replace)?$ - type: string - path: - type: string - value: - x-kubernetes-preserve-unknown-fields: true - required: - - path - type: object - type: array - type: object - type: array - placement: - properties: - clusterSelector: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: - type: string - values: - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - type: object - type: object - clusters: - items: - properties: - name: - type: string - required: - - name - type: object - type: array - type: object - template: - type: object - x-kubernetes-preserve-unknown-fields: true - type: object - status: - properties: - clusters: - items: - properties: - name: - type: string - remoteStatus: - type: object - x-kubernetes-preserve-unknown-fields: true - status: - type: string - required: - - name - type: object - type: array - conditions: - items: - properties: - lastTransitionTime: - format: date-time - type: string - lastUpdateTime: - format: date-time - type: string - reason: - type: string - status: - type: string - type: - type: string - required: - - type - - status - type: object - type: array - observedGeneration: - format: int64 - type: integer - type: object - required: - - spec - type: object - served: true - storage: true - subresources: - status: {} diff --git a/roles/ks-monitor/tasks/notification-manager.yaml b/roles/ks-monitor/tasks/notification-manager.yaml index 78675ce1e..4d8176d24 100644 --- a/roles/ks-monitor/tasks/notification-manager.yaml +++ b/roles/ks-monitor/tasks/notification-manager.yaml @@ -5,11 +5,6 @@ src: "notification-manager" dest: "{{ kubesphere_dir }}/" -- name: notification-manager | Getting federated files - copy: - src: "federated" - dest: "{{ kubesphere_dir }}/" - - name: notification-manager | Getting notification-manager installation files template: src: "{{ item.file }}.j2" @@ -47,42 +42,4 @@ - notification_check.rc == 0 - notification_check.stdout.find("2.3.0") == -1 -- name: notification-manager | Checking federatednamespace crd installed - shell: > - {{ bin_dir }}/kubectl get crd federatednamespaces.types.kubefed.io -o jsonpath='{.metadata.name}' - register: crd_installed - failed_when: false - -- name: notification-manager | Deploying federatednamespace crd - shell: "{{ bin_dir }}/kubectl apply -f {{ kubesphere_dir }}/federated/federatednamespaces.yaml" - register: fed_result - failed_when: "fed_result.stderr and 'Warning' not in fed_result.stderr and 'spec.clusterIP' not in fed_result.stderr" - until: fed_result is succeeded - retries: 5 - delay: 3 - when: - - multicluster is defined and multicluster.clusterRole == 'host' - - crd_installed.rc != 0 or crd_installed.stdout.find("federatednamespaces.types.kubefed.io") == -1 - -- name: notification-manager | Checking federated namespace deployed - shell: > - {{ bin_dir }}/kubectl get federatednamespaces.types.kubefed.io -n kubesphere-monitoring-federated kubesphere-monitoring-federated -o jsonpath='{.metadata.name}' - register: namespace_deployed - failed_when: false - -- name: notification-manager | Deploying federated namespace - shell: "{{ bin_dir }}/kubectl apply -f {{ kubesphere_dir }}/federated/kubesphere-monitoring-federated.yaml" - register: fed_result - failed_when: "fed_result.stderr and 'Warning' not in fed_result.stderr and 'spec.clusterIP' not in fed_result.stderr" - until: fed_result is succeeded - retries: 5 - delay: 3 - when: - - multicluster is defined and multicluster.clusterRole == 'host' - - namespace_deployed.rc != 0 or namespace_deployed.stdout.find("kubesphere-monitoring-federated") == -1 - -- name: notification-manager | Update federated crds - shell: "bash {{ kubesphere_dir }}/federated/update_federated_crds.sh" - when: - - multicluster is defined and multicluster.clusterRole == 'host' diff --git a/roles/ks-monitor/files/federated/kubesphere-monitoring-federated.yaml b/roles/ks-multicluster/files/notification/kubesphere-monitoring-federated.yaml similarity index 100% rename from roles/ks-monitor/files/federated/kubesphere-monitoring-federated.yaml rename to roles/ks-multicluster/files/notification/kubesphere-monitoring-federated.yaml diff --git a/roles/ks-monitor/files/federated/update_federated_crds.sh b/roles/ks-multicluster/files/notification/update_federated_crds.sh similarity index 100% rename from roles/ks-monitor/files/federated/update_federated_crds.sh rename to roles/ks-multicluster/files/notification/update_federated_crds.sh diff --git a/roles/ks-multicluster/tasks/main.yml b/roles/ks-multicluster/tasks/main.yml index 234af3dd9..0f3a697f2 100644 --- a/roles/ks-multicluster/tasks/main.yml +++ b/roles/ks-multicluster/tasks/main.yml @@ -77,6 +77,7 @@ with_fileglob: - "{{ kubesphere_dir }}/kubefed/federatedcrds/*" +- import_tasks: notification-manager.yaml - name: Kubefed | Importing multicluster status shell: > diff --git a/roles/ks-multicluster/tasks/notification-manager.yaml b/roles/ks-multicluster/tasks/notification-manager.yaml new file mode 100644 index 000000000..9da4c3be4 --- /dev/null +++ b/roles/ks-multicluster/tasks/notification-manager.yaml @@ -0,0 +1,24 @@ +--- +- name: notification-manager | Getting federated files + copy: + src: "notification" + dest: "{{ kubesphere_dir }}/" + +- name: notification-manager | Checking federated namespace deployed + shell: > + {{ bin_dir }}/kubectl get federatednamespaces.types.kubefed.io -n kubesphere-monitoring-federated kubesphere-monitoring-federated -o jsonpath='{.metadata.name}' + register: namespace_deployed + failed_when: false + +- name: notification-manager | Deploying federated namespace + shell: "{{ bin_dir }}/kubectl apply -f {{ kubesphere_dir }}/notification/kubesphere-monitoring-federated.yaml" + register: fed_result + failed_when: "fed_result.stderr and 'Warning' not in fed_result.stderr and 'spec.clusterIP' not in fed_result.stderr" + until: fed_result is succeeded + retries: 5 + delay: 3 + when: + - namespace_deployed.rc != 0 or namespace_deployed.stdout.find("kubesphere-monitoring-federated") == -1 + +- name: notification-manager | Update federated crds + shell: "bash {{ kubesphere_dir }}/notification/update_federated_crds.sh"