Skip to content

Commit

Permalink
add job ks-upgrade to upgrade role
Browse files Browse the repository at this point in the history
Signed-off-by: Wenhao Zhou <wenhaozhou@yunify.com>
  • Loading branch information
zhou1203 committed Oct 13, 2022
1 parent 08dd030 commit 8189ccc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
13 changes: 9 additions & 4 deletions roles/ks-core/ks-core/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,16 @@
# register: source_state
# failed_when: "source_state.stderr and 'already exists' not in source_state.stderr"

- name: KubeSphere | Upgrade GlobalRolebindings
- name: Kubesphere | Checking Users Manger and Workspaces Manger
shell:
{{ bin_dir }}/kubectl get globalroles.iam.kubesphere.io users-manager workspaces-manager --no-header | wc -l
register: manager_result

- name: KubeSphere | Creating migration job
shell: >
{{ bin_dir }}/kubectl get globalrolebindings -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.roleRef.name}{"\n"}'
| grep -e "users-manager$" -e "workspaces-manager$" | awk '{print $1}'
| xargs -i {{ bin_dir }}/kubectl patch globalrolebindings {} --type merge -p '{"roleRef":{"name":"platform-regular"}}'
{{ bin_dir }}/kubectl apply -f {{ kubesphere_dir }}/ks-upgrade.yaml
when:
- manager_result.stdout != "0"

- name: KubeSphere | Importing ks-core status
shell: >
Expand Down
22 changes: 22 additions & 0 deletions roles/ks-core/ks-core/templates/ks-upgrade.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
apiVersion: batch/v1
kind: Job
metadata:
name: ks-upgrade
namespace: kubesphere-system
labels:
job: ks-upgrade
version: v3.0.0
spec:
template:
spec:
serviceAccountName: ks-installer
restartPolicy: OnFailure
containers:
- command:
- ks-upgrade
- --logtostderr
- --v=4
image: {{ ks_update_repo }}:{{ ks_update_tag }}
imagePullPolicy: IfNotPresent
name: ks-upgrade

0 comments on commit 8189ccc

Please sign in to comment.