Skip to content

Commit

Permalink
Release: v2.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Muthukumar-Subramaniam committed Oct 1, 2024
1 parent 0cc8f33 commit 58e41b4
Show file tree
Hide file tree
Showing 33 changed files with 64 additions and 46 deletions.
Binary file modified inst-k8s-ansible.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion inst-k8s-ansible/ansible.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Version : v2.2.4
##Version : v2.2.5
[defaults]
interpreter_python=/usr/bin/python3
inventory=./inventory
Expand Down
2 changes: 1 addition & 1 deletion inst-k8s-ansible/inst-k8s-ansible.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env ansible-playbook
##Version : v2.2.4
##Version : v2.2.5
- name: Install and configure the kubernetes cluster on linux nodes
hosts: k8s_cluster_ctrl_plane_node, k8s_cluster_worker_nodes
roles:
Expand Down
2 changes: 1 addition & 1 deletion inst-k8s-ansible/optional-install-metallb.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env ansible-playbook
##Version : v2.2.4
##Version : v2.2.5
### Optional metallb installation for k8s cluster
### Run it if required only after the k8s cluster is Ready

Expand Down
2 changes: 1 addition & 1 deletion inst-k8s-ansible/optional-k8s-csi-nfs-driver.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env ansible-playbook
##Version : v2.2.4
##Version : v2.2.5
### Optional CSI NFS Driver for k8s cluster
### Run it if required only after the k8s cluster is Ready
- name: Install CSI NFS Driver for k8s cluster
Expand Down
2 changes: 1 addition & 1 deletion inst-k8s-ansible/optional-k8s-csi-smb-driver.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env ansible-playbook
##Version : v2.2.4
##Version : v2.2.5
### Optional CSI SMB Driver for k8s cluster
### Run it if required only after the k8s cluster is Ready
- name: Install CSI SMB Driver for k8s cluster
Expand Down
2 changes: 1 addition & 1 deletion inst-k8s-ansible/playbook_version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"schemaVersion": 1,
"label": "stable release",
"message": "v2.2.4",
"message": "v2.2.5",
"color": "brightgreen"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Version : v2.2.4
##Version : v2.2.5
- name: Allow Kubernetes related ports for control plane node
become: true
ansible.posix.firewalld:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Version : v2.2.4
##Version : v2.2.5
- name: Check if firewalld is active
become: true
command: systemctl is-active firewalld
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Version : v2.2.4
##Version : v2.2.5
### Role to check the k8s cluster Ready status
- name: Get the current status of all the cluster nodes
shell: kubectl get nodes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Version : v2.2.4
##Version : v2.2.5
### Role to Fetch latest version of software components to be installed from GitHub API
- name: Get latest version information of runc
delegate_to: local-ansible-control-host
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Version : v2.2.4
##Version : v2.2.5
###Tasks to install and configure metallb for k8s cluster
- name: Check whether MetalLB is already installed
shell: |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Version : v2.2.4
##Version : v2.2.5
- name: Check if Calico CNI manifest has been applied already
shell: kubectl get pods -A | grep 'calico'
register: var_calico_check
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Version : v2.2.4
##Version : v2.2.5
- name: Check if Kubernetes config for user {{ var_k8s_user }} exists
stat:
path: /home/{{ var_k8s_user }}/.kube/config
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Version : v2.2.4
##Version : v2.2.5
- name: Check if the Kubernetes config images have already been pulled
become: true
shell: |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Version : v2.2.4
##Version : v2.2.5
- name: Check if kubeadm init has been performed
stat:
path: /etc/kubernetes/admin.conf
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Version : v2.2.4
##Version : v2.2.5
- set_fact:
var_k8s_ctrl_plane_node: "{{ ansible_host }}"
var_k8s_user: "{{ ansible_user }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
##Version : v2.2.4
##Version : v2.2.5
var_k8s_pod_network_cidr: "10.8.0.0/16"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Version : v2.2.4
##Version : v2.2.5
### Optional CSI NFS Driver for k8s cluster
- name: Check whether csi-nfs-driver is already installed
shell: |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Version : v2.2.4
##Version : v2.2.5
### Optional CSI SMB Driver for k8s cluster
- name: Check whether csi-smb-driver is already installed
shell: |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Version : v2.2.4
##Version : v2.2.5
###Role to Register worker nodes with the k8s cluster with kubeadm join command
- name: Check whether the worker node has joined the cluster already
stat:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Version : v2.2.4
##Version : v2.2.5
- name: Add k8s gpg apt-key ( Debian based systems )
become: true
apt_key:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Version : v2.2.4
##Version : v2.2.5
- name: Check if swap is enabled
become: true
command: swapon --show
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Version : v2.2.4
##Version : v2.2.5
- name: Download official binary tarball of latest containerd ( {{ var_containerd_latest_version }} ) to local-ansible-control-host
delegate_to: local-ansible-control-host
run_once: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Version : v2.2.4
##Version : v2.2.5
- name: Download latest official runc ( {{ var_runc_latest_version }} ) binary to local-ansible-control-host
delegate_to: local-ansible-control-host
run_once: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Version : v2.2.4
##Version : v2.2.5
- name: Load the required kernel modules
become: true
modprobe:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Version : v2.2.4
##Version : v2.2.5
- name: Load the required kernel parameters
become: true
ansible.posix.sysctl:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Version : v2.2.4
##Version : v2.2.5
###Tasks to upgrade the system packages
- name: Include tasks to upgrade the system packages
include_tasks: upgrade_os.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Version : v2.2.4
##Version : v2.2.5
- name: Add k8s rpm repository ( RedHat based systems )
become: true
yum_repository:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Version : v2.2.4
##Version : v2.2.5
- name: Add k8s rpm repository ( Suse based systems )
become: true
zypper_repository:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Version : v2.2.4
## Version : v2.2.5
- name: Upgrade the system packages (RedHat based systems)
become: true
when: ansible_os_family == "RedHat"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
##Version : v2.2.4
##Version : v2.2.5
var_containerd_temp_binary_tarball: "/tmp/temp-containerd.tar.gz"
var_runc_temp_binary: "/tmp/temp-runc"
48 changes: 33 additions & 15 deletions inst-k8s-ansible/setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env python3
##Version : v2.2.4
##Version : v2.2.5

import os
import re
import ipaddress
import subprocess

var_host_file_cp = "./host-control-plane"
Expand Down Expand Up @@ -59,26 +60,43 @@ def fn_check_files(file_name):
var_pod_network_cidr = f.read().strip()

fn_print_msg("Validate the pod network CIDR . . .")

cidr_pattern = r'^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.0/[0-9]{1,2}$'
if not re.match(cidr_pattern, var_pod_network_cidr):
# Check if the CIDR matches the basic pattern
var_cidr_pattern = r'^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/[0-9]{1,2}$'
if not re.match(var_cidr_pattern, var_pod_network_cidr):
fn_print_fail(f"\nInvalid pod network CIDR {var_pod_network_cidr} is provided in the file {var_pod_network_file}!\n")
fn_msg_setup()
exit(1)

if not re.search(r'^(192\.168|10\.|172\.1[6789]\.|172\.2[0-9]\.|172\.3[01]\.)', var_pod_network_cidr):
fn_print_fail(f"\nThe pod network CIDR {var_pod_network_cidr} provided in the file {var_pod_network_file} doesn't fall under private address space (RFC 1918)!\n")
fn_msg_setup()
exit(1)
try:
# Create an IP network object
var_network = ipaddress.ip_network(var_pod_network_cidr, strict=False)

if re.match(r'^10\.96\.', var_pod_network_cidr):
fn_print_fail(f"\nThe pod network CIDR {var_pod_network_cidr} overlaps with Kubernetes default internal Cluster IP network 10.96.0.0/16!\n")
fn_msg_setup()
exit(1)
# Check if the network address matches the provided CIDR
if str(var_network.network_address) != var_pod_network_cidr.split('/')[0]:
fn_print_fail(f"\nThe network part {var_pod_network_cidr.split('/')[0]} does not match the prefix length /{var_network.prefixlen} in the file {var_pod_network_file}!")
fn_print_fail(f"\nMaybe you are looking for {var_network.network_address}/{var_network.prefixlen}!\n")
fn_msg_setup()
exit(1)

# Additional validations
if not re.search(r'^(192\.168|10\.|172\.1[6789]\.|172\.2[0-9]\.|172\.3[01]\.)', str(var_network)):
fn_print_fail(f"\nThe pod network CIDR {var_pod_network_cidr} provided in the file {var_pod_network_file} doesn't fall under private address space (RFC 1918)!\n")
fn_msg_setup()
exit(1)

if str(var_network.network_address).startswith("10.96."):
fn_print_fail(f"\nThe pod network CIDR {var_pod_network_cidr} overlaps with Kubernetes default internal Cluster IP network 10.96.0.0/16!\n")
fn_msg_setup()
exit(1)

var_cidr_prefix = var_network.prefixlen
if var_cidr_prefix < 16 or var_cidr_prefix > 28:
fn_print_fail(f"\nInvalid pod network CIDR prefix /{var_cidr_prefix} in the file {var_pod_network_file}, as a best practice only /16 to /28 is accepted!\n")
fn_msg_setup()
exit(1)

cidr_prefix = int(var_pod_network_cidr.split('/')[1])
if cidr_prefix < 16 or cidr_prefix > 28:
fn_print_fail(f"\nInvalid pod network CIDR prefix /{cidr_prefix} in the file {var_pod_network_file}, as a best practice only /16 to /28 is accepted!\n")
except ValueError as e:
fn_print_fail(f"\nError validating pod network CIDR: {e}")
fn_msg_setup()
exit(1)

Expand Down

0 comments on commit 58e41b4

Please sign in to comment.