[Kubernetes Deployment] Ansible automation tool deploys K8s version 1.27 offline

1. Prerequisites

  • Single Master, multi-Node deployment architecture
  • Requires host network communication, no network restrictions
  • Requires root user privileges to deploy

2. Use Ansible to deploy K8S cluster steps

Step 1: Obtain the offline installation package
from Baidu Netdisk

Step 2: Install the ansible command

tar zxf k8s1.27.tar.gz && cd k8s1.27/Packages
tar zxf ansible.tar.gz && cd ansible
yum localinstall *

Step 3: Configure the installation host information (required)

vim k8s1.27/hosts

insert image description here
Parameter explanation:

  • ansible_ssh_user: execution user
  • ansible_ssh_pass: execute user password
  • ansible_sudo_pass: execute user password (sudo permission)
  • ansible_ssh_port: connect SSH port

Step 4: Specify the location of the Packages directory (required)

vim k8s1.27/config.yml

insert image description here
Step 5: Execute the script and wait patiently for the process. Offline deployment does not involve the network, which is relatively fast, about (10 minutes)

cd k8s1.27
ansible-playbook -i hosts k8sv1.27_kubeadm_install.yml

After the deployment is completed, the following figure is displayed:
insert image description here
Step 6: Verify the cluster, the status is to Readyindicate completion, if it is, NotReadyplease wait patiently.

kubectl get nodes

insert image description here

3. Expand content

1. Add multiple Node nodes

Step 1: k8s1.27/hostsAdd new node information

vim k8s1.27/hosts

insert image description here
Step 2: k8s1.27/roles/k8s-envInit/templates/hosts.j2Add new index location

vim k8s1.27/roles/k8s-envInit/templates/hosts.j2

insert image description here

Guess you like

Origin blog.csdn.net/weixin_45310323/article/details/130952452