Skip to content

Commit

Permalink
Merge pull request #1313 from KubeKyrie/add-precheck-time-info
Browse files Browse the repository at this point in the history
add precheck time info
  • Loading branch information
ErikJiang authored Jul 17, 2024
2 parents 1ff62e7 + 83491ac commit bdcfb01
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 16 deletions.
33 changes: 17 additions & 16 deletions pkg/util/entrypoint/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,22 @@ const (
RemoveNodePB = "remove-node.yml"
UpgradeClusterPB = "upgrade-cluster.yml"

PingPB = "ping.yml"
RepoPB = "enable-repo.yml"
FirewallPB = "disable-firewalld.yml"
KubeconfigPB = "kubeconfig.yml"
ClusterInfoPB = "cluster-info.yml"
UpdateHostsPB = "update-hosts.yml"
RemovePkgsPB = "remove-pkgs.yml"
PreCheckPB = "precheck.yml"
RenewCertsPB = "renew-certs.yml"
KubeVipConfigPB = "config-for-kube-vip.yml"
ConfigInsecureRegistryPB = "config-insecure-registry.yml"
NfConntrackPB = "enable-nf-conntrack.yml"
MountXFSPquotaPB = "mount-xfs-pquota.yml"
SetContainerdRegistryMirror = "set-containerd-registry-mirror.yml"
DisableKernelUnattendedUpgrade = "disable-kernel-unattended-upgrade.yml"
PingPB = "ping.yml"
RepoPB = "enable-repo.yml"
FirewallPB = "disable-firewalld.yml"
KubeconfigPB = "kubeconfig.yml"
ClusterInfoPB = "cluster-info.yml"
UpdateHostsPB = "update-hosts.yml"
RemovePkgsPB = "remove-pkgs.yml"
PreCheckPB = "precheck.yml"
RenewCertsPB = "renew-certs.yml"
KubeVipConfigPB = "config-for-kube-vip.yml"
ConfigInsecureRegistryPB = "config-insecure-registry.yml"
NfConntrackPB = "enable-nf-conntrack.yml"
MountXFSPquotaPB = "mount-xfs-pquota.yml"
SetContainerdRegistryMirror = "set-containerd-registry-mirror.yml"
DisableKernelUnattendedUpgrade = "disable-kernel-unattended-upgrade.yml"
ConfigDockerCgroupDriverForKylinSP2 = "config-docker-cgroup-driver-for-kylinSP2.yml"
)

//go:embed entrypoint.sh.template
Expand Down Expand Up @@ -67,7 +68,7 @@ func NewActions() *Actions {
PingPB, RepoPB, FirewallPB, KubeconfigPB, ClusterInfoPB, UpdateHostsPB,
RemovePkgsPB, PreCheckPB, RenewCertsPB,
KubeVipConfigPB, ConfigInsecureRegistryPB, NfConntrackPB, MountXFSPquotaPB,
SetContainerdRegistryMirror, DisableKernelUnattendedUpgrade,
SetContainerdRegistryMirror, DisableKernelUnattendedUpgrade, ConfigDockerCgroupDriverForKylinSP2,
}
actions.Playbooks.Dict = map[string]void{}
for _, pbItem := range actions.Playbooks.List {
Expand Down
25 changes: 25 additions & 0 deletions playbooks/precheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
check_existing_k8s_service: true
check_existing_docker: true
check_dual_stack_network: true
check_node_time_sync: true

tasks:
- name: Gather minimal facts
Expand Down Expand Up @@ -95,6 +96,20 @@
shell: " ( if [ ! -f /tmp/kubean_data_temp_cache_{{inventory_hostname}} ]; then touch /tmp/kubean_data_temp_cache_{{inventory_hostname}} ; fi ) ; yq -i '.{{inventory_hostname}}.existing_docker=\"{{ check_docker_cmd_result.rc == 0 }}\"' /tmp/kubean_data_temp_cache_{{inventory_hostname}} "
delegate_to: localhost

- name: Perform fetch time info
shell: date +%s
register: timestamp_result
ignore_errors: true
when:
- check_node_time_sync

- name: Perform fetch timezone
shell: timedatectl | grep "Time zone"
register: timezone_result
ignore_errors: true
when:
- check_node_time_sync

- name: Perform fetch ip info
shell: |
ip --brief address show | grep -i up | grep '{{ access_ip }}' | sed 's/fe80\S*//g' | sed 's/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\S*//g' | head
Expand Down Expand Up @@ -136,6 +151,16 @@
ignore_errors: true
delegate_to: localhost

- name: Store node time info to localhost
shell: |
( if [ ! -f /tmp/kubean_data_temp_cache_{{inventory_hostname}} ]; then touch /tmp/kubean_data_temp_cache_{{inventory_hostname}} ; fi )
yq -i '.{{inventory_hostname}}.node_timestamp="{{ timestamp_result.stdout }}"' /tmp/kubean_data_temp_cache_{{inventory_hostname}}
yq -i '.{{inventory_hostname}}.timezone="{{ timezone_result.stdout.split(':')[1].strip() }}"' /tmp/kubean_data_temp_cache_{{inventory_hostname}}
ignore_errors: true
delegate_to: localhost
when:
- check_node_time_sync

- hosts: localhost
gather_facts: false
vars:
Expand Down

0 comments on commit bdcfb01

Please sign in to comment.