-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* epicli/upgrade: reusing existing shared-config + cleanups * upgrade: k8s HA upgrades minimal implementation * upgrade: kubernetes cleanup and refactor * Apply suggestions from code review Co-authored-by: to-bar <[email protected]> * upgrade: removing unneeded kubeconfig from k8s nodes (security fix) * upgrade: statefulset patching refactor * upgrade: cleanups and refactor for logs * Make deployment manifest tasks more generic * Improve detecting CNI plugin * AnsibleVarsGenerator.py: fixing regression issue introducted during upgrade refactor * Apply suggestions from code review Co-authored-by: to-bar <[email protected]> * upgrade: statefulset patching refactor - patching all containers (fix) - patching init containers also (fix) - removing include_tasks statements (speedup) * Ensure settings for backward compatibility * Revert "Ensure settings for backward compatibility" This reverts commit 5c9cdb6. * AnsibleInventoryUpgrade.py: merging shared-config with defaults * Adding changelog entry * Revert "AnsibleVarsGenerator.py: fixing regression issue introducted during upgrade refactor" This reverts commit c38eb9d. * Revert "epicli/upgrade: reusing existing shared-config + cleanups" This reverts commit e5957c5. * AnsibleVarsGenerator.py: adding nicer way to handle shared config Co-authored-by: to-bar <[email protected]>
- Loading branch information
Showing
52 changed files
with
739 additions
and
645 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
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
26 changes: 4 additions & 22 deletions
26
.../data/common/ansible/playbooks/roles/kubernetes_master/tasks/apply-network-components.yml
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 |
---|---|---|
@@ -1,25 +1,7 @@ | ||
--- | ||
- name: Apply network plugin configured by user | ||
include_tasks: "./cni-plugins/{{ network_plugin }}.yml" | ||
include_tasks: cni-plugins/{{ network_plugin }}.yml | ||
|
||
# Wait for CNI plugin become ready to prevent failure of 'Get token from master' task on node before joining master | ||
- name: Wait for CNI plugin become ready | ||
shell: >- | ||
kubectl wait --for=condition=Ready pods -l {{ selectors[network_plugin] }} | ||
--field-selector=spec.nodeName=$(hostname --long) -n kube-system --timeout=10s | ||
args: | ||
executable: /bin/bash | ||
environment: | ||
KUBECONFIG: /home/{{ admin_user.name }}/.kube/config | ||
register: wait_for_cni_plugin | ||
until: wait_for_cni_plugin is succeeded | ||
retries: 30 | ||
delay: 1 | ||
changed_when: false | ||
vars: | ||
selectors: | ||
calico: k8s-app=calico-node | ||
canal: k8s-app=canal | ||
flannel: app=flannel | ||
when: | ||
- network_plugin in selectors.keys() | ||
# Wait for CNI plugin to become ready to prevent failure of 'Get token from master' task on node before joining master | ||
- name: Include wait-for-cni-plugin.yml | ||
include_tasks: cni-plugins/wait-for-cni-plugin.yml |
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
21 changes: 21 additions & 0 deletions
21
...ommon/ansible/playbooks/roles/kubernetes_master/tasks/cni-plugins/wait-for-cni-plugin.yml
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,21 @@ | ||
--- | ||
# This file is meant to be also used by upgrade role | ||
|
||
- name: Wait for CNI plugin to become ready | ||
environment: | ||
KUBECONFIG: /etc/kubernetes/admin.conf | ||
shell: >- | ||
kubectl wait --for=condition=Ready pods -l {{ selectors[network_plugin] }} | ||
--field-selector=spec.nodeName=$(hostname --long) -n kube-system --timeout=10s | ||
args: | ||
executable: /bin/bash | ||
register: wait_for_cni_plugin | ||
until: wait_for_cni_plugin is succeeded | ||
retries: 30 | ||
delay: 1 | ||
changed_when: false | ||
vars: | ||
selectors: | ||
calico: k8s-app=calico-node | ||
canal: k8s-app=canal | ||
flannel: app=flannel |
11 changes: 4 additions & 7 deletions
11
...li/data/common/ansible/playbooks/roles/kubernetes_master/tasks/deployments/apply-file.yml
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 |
---|---|---|
@@ -1,9 +1,6 @@ | ||
--- | ||
- name: "Apply /etc/epiphany/manifests/{{ file_name }} file" | ||
- name: Apply {{ file_path }} file | ||
environment: | ||
KUBECONFIG: "/home/{{ admin_user.name }}/.kube/config" | ||
shell: | | ||
kubectl apply \ | ||
-f /etc/epiphany/manifests/{{ file_name }} | ||
args: | ||
executable: /bin/bash | ||
KUBECONFIG: /etc/kubernetes/admin.conf | ||
shell: >- | ||
kubectl apply -f {{ file_path }} |
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
20 changes: 0 additions & 20 deletions
20
core/src/epicli/data/common/ansible/playbooks/roles/upgrade/tasks/ensure-kubeconfig.yml
This file was deleted.
Oops, something went wrong.
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
55 changes: 33 additions & 22 deletions
55
core/src/epicli/data/common/ansible/playbooks/roles/upgrade/tasks/kubernetes.yml
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 |
---|---|---|
@@ -1,37 +1,48 @@ | ||
--- | ||
- name: Include wait-for-kube-apiserver.yml | ||
import_tasks: kubernetes/wait-for-kube-apiserver.yml | ||
delegate_to: "{{ groups['kubernetes_master'][0] }}" | ||
- name: k8s | Wait for kube-apiserver then get cluster and kubelet version | ||
delegate_to: "{{ groups.kubernetes_master[0] }}" | ||
block: | ||
- name: k8s | Include wait-for-kube-apiserver.yml | ||
import_tasks: kubernetes/utils/wait-for-kube-apiserver.yml | ||
|
||
- name: Include get-cluster-version.yml | ||
import_tasks: kubernetes/get-cluster-version.yml # sets cluster_version | ||
delegate_to: "{{ groups['kubernetes_master'][0] }}" | ||
- name: k8s | Include get-cluster-version.yml | ||
import_tasks: kubernetes/get-cluster-version.yml # sets cluster_version | ||
|
||
- name: Check if upgrade from current K8s version is supported | ||
- name: k8s | Check if upgrade from current K8s version is supported | ||
assert: | ||
that: cluster_version is version('v1.14.6', '>=') | ||
fail_msg: Your Kubernetes version ({{ cluster_version }}) is not supported by this version of Epiphany which requires at least version 1.14.6 (Epiphany v0.4.4). For more information, refer to the documentation. | ||
quiet: true | ||
|
||
- name: Include get-kubelet-version.yml | ||
- name: k8s | Include get-kubelet-version.yml | ||
import_tasks: kubernetes/get-kubelet-version.yml # sets kubelet_version | ||
delegate_to: "{{ groups['kubernetes_master'][0] }}" | ||
|
||
- name: Upgrade master to v{{ version }} | ||
include_tasks: kubernetes/upgrade-master.yml | ||
- name: k8s | Upgrade masters then nodes | ||
vars: | ||
version: "{{ ver }}" | ||
cni_version: "{{ cni_ver }}" | ||
when: | ||
- groups['kubernetes_master'][0] == inventory_hostname | ||
- cluster_version is version('v' + version, '<=') | ||
block: | ||
- name: k8s | Upgrade masters | ||
when: cluster_version is version('v' + version, '<=') | ||
block: | ||
- name: k8s | Upgrade first master to v{{ version }} | ||
include_tasks: kubernetes/upgrade-master0.yml | ||
when: | ||
- inventory_hostname == groups.kubernetes_master[0] | ||
|
||
- name: Upgrade node to v{{ version }} | ||
include_tasks: kubernetes/upgrade-node.yml | ||
vars: | ||
version: "{{ ver }}" | ||
cni_version: "{{ cni_ver }}" | ||
when: | ||
- groups['kubernetes_node'] is defined | ||
- inventory_hostname in groups['kubernetes_node'] | ||
- kubelet_version is version('v' + version, '<=') | ||
- name: k8s | Upgrade next master to v{{ version }} | ||
include_tasks: kubernetes/upgrade-masterN.yml | ||
when: | ||
- inventory_hostname in groups.kubernetes_master[1:] | ||
|
||
- name: k8s | Upgrade nodes | ||
when: kubelet_version is version('v' + version, '<=') | ||
block: | ||
- name: k8s | Upgrade node to v{{ version }} | ||
include_tasks: kubernetes/upgrade-node.yml | ||
when: | ||
- groups.kubernetes_node is defined | ||
- inventory_hostname in groups.kubernetes_node | ||
|
||
# TODO: Create a flag file that the upgrade completed to not run it again for the same version next time |
Oops, something went wrong.