add variables for more config options maintenance
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
---
|
||||
# Kubernetes configuration
|
||||
kubernetes_version: "1.32"
|
||||
pod_cidr: "192.168.0.0/16"
|
||||
service_cidr: "10.96.0.0/16"
|
||||
|
||||
# CNI plugin choice (options: calico, flannel, etc.)
|
||||
cni_plugin: "calico"
|
||||
calico_version: "v3.29.1"
|
||||
|
||||
# Node resources
|
||||
control_plane_cpus: 2
|
||||
control_plane_memory: 4G
|
||||
control_plane_disk: 20G
|
||||
worker_cpus: 2
|
||||
worker_memory: 4G
|
||||
worker_disk: 20G
|
||||
|
||||
# DNS configuration
|
||||
dns_servers:
|
||||
- "8.8.8.8"
|
||||
- "8.8.4.4"
|
||||
@@ -6,15 +6,15 @@ all:
|
||||
control_plane:
|
||||
hosts:
|
||||
controlplane:
|
||||
ansible_host: 10.203.146.138
|
||||
ansible_host: 10.203.146.40
|
||||
workers:
|
||||
hosts:
|
||||
node01:
|
||||
ansible_host: 10.203.146.17
|
||||
ansible_host: 10.203.146.133
|
||||
node02:
|
||||
ansible_host: 10.203.146.203
|
||||
ansible_host: 10.203.146.11
|
||||
node03:
|
||||
ansible_host: 10.203.146.70
|
||||
ansible_host: 10.203.146.223
|
||||
vars:
|
||||
ansible_user: ubuntu
|
||||
ansible_become: yes
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
---
|
||||
# ansible/playbooks/kubernetes.yml
|
||||
- name: Common configuration for all nodes
|
||||
hosts: k8s_cluster
|
||||
become: yes
|
||||
vars_files:
|
||||
- ../defaults/kubernetes.yml
|
||||
tags:
|
||||
- common
|
||||
tasks:
|
||||
@@ -14,6 +15,8 @@
|
||||
- name: Kubernetes setup for all nodes
|
||||
hosts: k8s_cluster
|
||||
become: yes
|
||||
vars_files:
|
||||
- ../defaults/kubernetes.yml
|
||||
tags:
|
||||
- k8s-setup
|
||||
tasks:
|
||||
@@ -22,6 +25,8 @@
|
||||
- name: Initialize Kubernetes control plane
|
||||
hosts: control_plane
|
||||
become: yes
|
||||
vars_files:
|
||||
- ../defaults/kubernetes.yml
|
||||
tags:
|
||||
- control-plane
|
||||
tasks:
|
||||
@@ -30,12 +35,13 @@
|
||||
- name: Join worker nodes to cluster
|
||||
hosts: workers
|
||||
become: yes
|
||||
vars_files:
|
||||
- ../defaults/kubernetes.yml
|
||||
tags:
|
||||
- workers
|
||||
tasks:
|
||||
- include_tasks: ../tasks/kubernetes/worker-join.yml
|
||||
|
||||
|
||||
- name: Validate Kubernetes cluster
|
||||
hosts: k8s_cluster
|
||||
become: yes
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
---
|
||||
# tasks/control-plane-init.yml
|
||||
- name: Set Kubernetes network CIDRs for Calico
|
||||
- name: Set Kubernetes network CIDRs
|
||||
set_fact:
|
||||
pod_cidr: "192.168.0.0/16" # Calico default CIDR
|
||||
service_cidr: "10.96.0.0/16"
|
||||
pod_cidr: "{{ pod_cidr }}"
|
||||
service_cidr: "{{ service_cidr }}"
|
||||
|
||||
- name: Initialize Kubernetes control plane
|
||||
command: >
|
||||
|
||||
@@ -126,10 +126,7 @@
|
||||
|
||||
- name: Install Kubernetes components
|
||||
apt:
|
||||
name:
|
||||
- kubelet
|
||||
- kubeadm
|
||||
- kubectl
|
||||
name: "{{ kubernetes_packages }}"
|
||||
state: present
|
||||
|
||||
- name: Hold Kubernetes packages
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
state: started
|
||||
enabled: yes
|
||||
|
||||
- name: Configure systemd-resolved to use Google DNS
|
||||
- name: Configure systemd-resolved to use configurable DNS
|
||||
lineinfile:
|
||||
path: /etc/systemd/resolved.conf
|
||||
regexp: '^#?DNS='
|
||||
line: 'DNS=8.8.8.8'
|
||||
line: 'DNS={{ dns_servers | join(" ") }}'
|
||||
state: present
|
||||
|
||||
- name: Restart systemd-resolved service
|
||||
|
||||
Reference in New Issue
Block a user