-
Notifications
You must be signed in to change notification settings - Fork 748
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: huanggze <[email protected]>
- Loading branch information
huanggze
committed
Jul 22, 2020
1 parent
c06c6f0
commit b7ac924
Showing
57 changed files
with
380 additions
and
744 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
- name: Kubesphere | Getting elasticsearch and curator installation files | ||
copy: | ||
src: "elasticsearch" | ||
dest: "{{ kubesphere_dir }}/" | ||
|
||
|
||
- name: Kubesphere | Creating custom manifests | ||
template: | ||
src: "{{ item.file }}.j2" | ||
dest: "{{ kubesphere_dir }}/elasticsearch/{{ item.file }}" | ||
with_items: | ||
- { name: custom-values-elasticsearch, file: custom-values-elasticsearch.yaml } | ||
- { name: custom-values-elasticsearch-curator, file: custom-values-elasticsearch-curator.yaml } | ||
|
||
|
||
# Update check | ||
- block: | ||
- name: Kubesphere | Check elasticsearch data StatefulSet | ||
shell: > | ||
{{ bin_dir }}/kubectl get sts -n kubesphere-logging-system | grep "elasticsearch-logging-data" | wc -l | ||
register: sts_number | ||
|
||
- name: Kubesphere | Check elasticsearch storageclass | ||
shell: > | ||
{{ bin_dir }}/kubectl get sts -n kubesphere-logging-system elasticsearch-logging-data -o yaml | grep "storageClassName" | wc -l | ||
register: sc_number | ||
|
||
- name: Kubesphere | Comment elasticsearch storageclass parameter | ||
shell: > | ||
sed -i 's/\(^.*storageClass:.*$\)/#\1/' {{ kubesphere_dir }}/custom-values-elasticsearch.yaml | ||
when: | ||
- sts_number.stdout != "0" | ||
- sc_number.stdout == "0" | ||
|
||
|
||
# Deploy elasticsearch | ||
- block: | ||
- name: Kubesphere | Deploy elasticsearch-logging | ||
shell: > | ||
{{ bin_dir }}/helm upgrade --install elasticsearch-logging | ||
{{ kubesphere_dir }}/elasticsearch/elasticsearch-1.22.1.tgz | ||
-f {{ kubesphere_dir }}/elasticsearch/custom-values-elasticsearch.yaml | ||
--namespace kubesphere-logging-system | ||
register: es_result | ||
ignore_errors: True | ||
|
||
- name: Kubesphere | Get PersistentVolume Name | ||
shell: > | ||
kubectl get pv | grep "kubesphere-logging-system/data-elasticsearch-logging" | awk '{print $1}' | ||
register: es_pv_name | ||
when: | ||
- "es_result.stderr and 'no matches for kind' in es_result.stderr" | ||
|
||
- name: Kubesphere | Patch PersistentVolume (persistentVolumeReclaimPolicy) | ||
shell: > | ||
kubectl patch pv {{ item }} | ||
-p '{"spec":{"persistentVolumeReclaimPolicy": "Retain"}}' | ||
loop: "{{ es_pv_name.stdout_lines }}" | ||
when: | ||
- "es_result.stderr and 'no matches for kind' in es_result.stderr" | ||
|
||
- name: Kubesphere | Delete elasticsearch | ||
shell: > | ||
{{ bin_dir }}/helm del --purge elasticsearch-logging | ||
when: | ||
- "es_result.stderr and 'no matches for kind' in es_result.stderr" | ||
|
||
- name: Kubesphere | Waiting for seconds | ||
wait_for: timeout=20 | ||
when: | ||
- "es_result.stderr and 'no matches for kind' in es_result.stderr" | ||
|
||
- name: Kubesphere | Deploy elasticsearch-logging | ||
shell: > | ||
{{ bin_dir }}/helm upgrade --install elasticsearch-logging | ||
{{ kubesphere_dir }}/elasticsearch/elasticsearch-1.22.1.tgz | ||
-f {{ kubesphere_dir }}/elasticsearch/custom-values-elasticsearch.yaml | ||
--namespace kubesphere-logging-system | ||
register: es_result | ||
when: | ||
- "es_result.stderr and 'no matches for kind' in es_result.stderr" | ||
|
||
- fail: | ||
msg: "{{ es_result.stderr }}" | ||
when: | ||
- es_result.stderr is defined | ||
- es_result.stderr != "" | ||
- es_result.stderr.find("no matches for kind") == -1 | ||
|
||
when: | ||
- common.es.externalElasticsearchUrl is not defined | ||
- common.es.externalElasticsearchPort is not defined | ||
|
||
|
||
# Deploy elasticsearch curator | ||
- block: | ||
- name: Kubesphere | Check elasticsearch-logging-curator | ||
shell: > | ||
{{ bin_dir }}/helm list elasticsearch-logging-curator | ||
register: curator_check | ||
ignore_errors: True | ||
|
||
|
||
- name: Kubesphere | Deploy elasticsearch-logging-curator | ||
shell: > | ||
{{ bin_dir }}/helm upgrade --install elasticsearch-logging-curator | ||
{{ kubesphere_dir }}/elasticsearch/elasticsearch-curator-1.3.3.tgz | ||
-f {{ kubesphere_dir }}/elasticsearch/custom-values-elasticsearch-curator.yaml | ||
--namespace kubesphere-logging-system | ||
when: | ||
- (curator_check.stdout.find("DEPLOYED") == -1) or (curator_check.stdout.find("5.5.4-0217") == -1) | ||
|
||
|
||
# Update clusterconfig (cc) status | ||
- name: Kubesphere | import es status | ||
shell: > | ||
{{ bin_dir }}/kubectl patch cc ks-installer | ||
--type merge | ||
-p '{"status": {"es": {"status": "enabled", "enabledTime": "{{ lookup('pipe','date +%Y-%m-%dT%H:%M:%S%Z') }}"}}}' | ||
-n kubesphere-system | ||
register: import | ||
failed_when: "import.stderr and 'Warning' not in import.stderr" | ||
until: import is succeeded | ||
retries: 5 | ||
delay: 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
- name: Kubesphere | Getting elasticsearch and curator installation files | ||
copy: | ||
src: "fluentbit-operator" | ||
dest: "{{ kubesphere_dir }}/" | ||
|
||
|
||
- name: Kubesphere | Creating custom manifests | ||
template: | ||
src: "{{ item.file }}.j2" | ||
dest: "{{ kubesphere_dir }}/fluentbit-operator/{{ item.path }}/{{ item.file }}" | ||
with_items: | ||
- { path: fluentbit, file: custom-fluentbit-fluentBit.yaml } | ||
- { path: init, file: custom-fluentbit-operator-deployment.yaml } | ||
- { path: migrator, file: custom-migrator-job.yaml } | ||
|
||
|
||
# Upgrade or install fluent bit operator | ||
- name: Kubesphere | Checking kubesphere-version | ||
shell: > | ||
{{ bin_dir }}/kubectl describe configmap -n kubesphere-system ks-console-ae-config | grep "kubesphere:" | awk '{print $2}' | ||
register: kubesphere_version | ||
ignore_errors: True | ||
|
||
|
||
- name: Kubesphere | Backup old fluentbit crd | ||
shell: > | ||
{{ bin_dir }}/kubectl get fluentbits.logging.kubesphere.io -n kubesphere-logging-system fluent-bit -o yaml > {{ kubesphere_dir }}/fluentbit-crd.yaml.bak | ||
when: | ||
- kubesphere_version.stdout.split('.')[0] == "2" | ||
|
||
|
||
- name: Kubesphere | Deleting old fluentbit operator | ||
shell: > | ||
{{ bin_dir }}/kubectl delete {{ item.type }} -n kubesphere-logging-system {{ item.name }} | ||
loop: | ||
- { type: deploy, name: logging-fluentbit-operator } | ||
- { type: fluentbits.logging.kubesphere.io, name: fluent-bit } | ||
- { type: ds, name: fluent-bit } | ||
- { type: crd, name: fluentbits.logging.kubesphere.io } | ||
when: | ||
- kubesphere_version.stdout.split('.')[0] == "2" | ||
|
||
|
||
- name: Kubesphere | Prepare fluentbit operator setup | ||
shell: > | ||
{{ bin_dir }}/kubectl apply -f {{ kubesphere_dir }}/fluentbit-operator/init | ||
- name: Kubesphere | Migrate fluentbit operator old config | ||
shell: > | ||
{{ bin_dir }}/kubectl apply -f {{ kubesphere_dir }}/fluentbit-operator/migrator | ||
when: | ||
- kubesphere_version.stdout.split('.')[0] == "2" | ||
|
||
|
||
- name: Kubesphere | Deploy new fluentbit operator | ||
shell: > | ||
{{ bin_dir }}/kubectl apply -f {{ kubesphere_dir }}/fluentbit-operator/fluentbit | ||
register: import | ||
until: import is succeeded | ||
retries: 5 | ||
delay: 3 | ||
|
||
|
||
# Update clusterconfig (cc) status | ||
- name: Kubesphere | import fluentbit status | ||
shell: > | ||
{{ bin_dir }}/kubectl patch cc ks-installer | ||
--type merge | ||
-p '{"status": {"fluentbit": {"status": "enabled", "enabledTime": "{{ lookup('pipe','date +%Y-%m-%dT%H:%M:%S%Z') }}"}}}' | ||
-n kubesphere-system | ||
register: import | ||
failed_when: "import.stderr and 'Warning' not in import.stderr" | ||
until: import is succeeded | ||
retries: 5 | ||
delay: 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.