Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add and update playbooks #2418

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions builtin/playbooks/artifact_export.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- localhost
roles:
- init/init-artifact
- init/init-cert
tasks:
- name: Export artifact
command: |
Expand Down
1 change: 1 addition & 0 deletions builtin/playbooks/artifact_images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
tags: ["always"]
roles:
- init/init-artifact
- init/init-cert
- install/image-registry
14 changes: 14 additions & 0 deletions builtin/playbooks/capkk_binary_install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
- name: NFS Install
hosts:
- nfs
gather_facts: true
roles:
- install/nfs

#- name: Image Registry Install
# hosts:
# - image_registry
# gather_facts: true
# roles:
# - install/image-registry
46 changes: 46 additions & 0 deletions builtin/playbooks/capkk_bootstrap_ready.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
- name: CNI Binary Install Pre-Check
hosts:
- k8s_cluster
gather_facts: true
vars_files:
- vars/cluster_requirements.yaml
tasks:
- name: Stop if arch supported
assert:
that: or (.cluster_require.supported_architectures.amd64 | has .os.architecture) (.cluster_require.supported_architectures.arm64 | has .os.architecture)
success_msg: |
{{- if .cluster_require.supported_architectures.amd64 | has .os.architecture }}
amd64
{{- else }}
arm64
{{- end }}
fail_msg: "{{ .os.architecture }} is not a known arch"
register: binary_type

- name: Kubernetes Install
hosts:
- k8s_cluster
vars_files:
- vars/create_cluster_kubernetes.yaml
roles:
- install/cri
- capkk/install/kubernetes

- name: Certs Distribution
hosts:
- kube_control_plane
roles:
- role: install/certs
when: .renew_certs.enabled

- name: Install CNI
hosts:
- kube_control_plane|random
roles:
- addons/cni
- addons/kata
- addons/nfd
- addons/sc

- import_playbook: hook/post_install.yaml
11 changes: 11 additions & 0 deletions builtin/playbooks/capkk_check_connect.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
- name: Check Connect
hosts: all
ignore_errors: true
tasks:
- name: Check Connect for Hosts
when: .inventory_name | ne "localhost"
command: echo 1
# post_tasks:
# - name: Compute Respond Time for Hosts
# command: ping -c 1 -W 1 k8s-master-node | grep time= | awk '{print $8}' | cut -d'=' -f2
18 changes: 18 additions & 0 deletions builtin/playbooks/capkk_delete_cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: Delete Kubernetes
hosts:
- k8s_cluster
roles:
- capkk/delete/kubernetes

- name: Delete Network
hosts:
- k8s_cluster
roles:
- capkk/delete/network

- name: Delete ETCD
hosts:
- etcd
roles:
- capkk/delete/etcd
27 changes: 27 additions & 0 deletions builtin/playbooks/capkk_etcd_binary_install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
- name: ETCD Binary Install Pre-Check
when: .kubernetes.etcd.deployment_type | eq "external"
hosts:
- etcd
gather_facts: true
vars_files:
- vars/cluster_requirements.yaml
tasks:
- name: Stop if arch supported
assert:
that: or (.cluster_require.supported_architectures.amd64 | has .os.architecture) (.cluster_require.supported_architectures.arm64 | has .os.architecture)
success_msg: |
{{- if .cluster_require.supported_architectures.amd64 | has .os.architecture }}
amd64
{{- else }}
arm64
{{- end }}
fail_msg: "{{ .os.architecture }} is not a known arch"
register: binary_type

- name: ETCD Binary Install
when: .kubernetes.etcd.deployment_type | eq "external"
hosts:
- etcd
roles:
- install/etcd
34 changes: 34 additions & 0 deletions builtin/playbooks/capkk_preparation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
- import_playbook: hook/pre_install.yaml

- name: Environment PreCheck
gather_facts: true
hosts:
- k8s_cluster
- etcd
- image_registry
- nfs
tags: [ "always" ]
roles:
- precheck/env_check

- name: Initialize OS
gather_facts: true
hosts:
- k8s_cluster
- etcd
- image_registry
roles:
- init/init-os

- name: Download Artifacts
hosts:
- localhost
roles:
- init/init-artifact

- name: Generate Certs
hosts:
- localhost
roles:
- init/init-cert
2 changes: 1 addition & 1 deletion builtin/playbooks/certs_renew.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
vars_files:
- vars/certs_renew.yaml
roles:
- init/init-artifact
- init/init-cert

- hosts:
- etcd
Expand Down
10 changes: 5 additions & 5 deletions builtin/playbooks/create_cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
roles:
- install/etcd

- hosts:
- image_registry
gather_facts: true
roles:
- install/image-registry
#- hosts:
# - image_registry
# gather_facts: true
# roles:
# - install/image-registry

- hosts:
- k8s_cluster
Expand Down
5 changes: 4 additions & 1 deletion builtin/playbooks/hook/post_install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
- all
tasks:
- name: Copy post install scripts to remote
ignore_errors: yes
ignore_errors: true
copy:
src: |
{{ .work_dir }}/scripts/post_install_{{ .inventory_name }}.sh
dest: |
/etc/kubekey/scripts/post_install_{{ .inventory_name }}.sh
mode: 0755
register: execute_result

- name: Execute post install scripts
when: .execute_result.stderr | eq ""
command: |
for file in /etc/kubekey/scripts/post_install_*.sh; do
if [ -f $file ]; then
Expand Down
5 changes: 4 additions & 1 deletion builtin/playbooks/hook/pre_install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
- all
tasks:
- name: Copy pre install scripts to remote
ignore_errors: yes
ignore_errors: true
copy:
src: |
{{ .work_dir }}/scripts/pre_install_{{ .inventory_name }}.sh
dest: |
/etc/kubekey/scripts/pre_install_{{ .inventory_name }}.sh
mode: 0755
register: execute_result

- name: Execute pre install scripts
when: .execute_result.stderr | eq ""
command: |
for file in /etc/kubekey/scripts/pre_install_*.sh; do
if [ -f $file ]; then
Expand Down
1 change: 1 addition & 0 deletions builtin/playbooks/init_os.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- localhost
roles:
- init/init-artifact
- init/init-cert

- hosts:
- etcd
Expand Down
1 change: 1 addition & 0 deletions builtin/playbooks/init_registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- localhost
roles:
- init/init-artifact
- init/init-cert

- hosts:
- image_registry
Expand Down
8 changes: 8 additions & 0 deletions builtin/playbooks/vars/cluster_requirements.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cluster_require:
supported_architectures:
amd64:
- amd64
- x86_64
arm64:
- arm64
- aarch64
Loading
Loading