Skip to content

Commit

Permalink
V2.18.1 (#1)
Browse files Browse the repository at this point in the history
* adding kube_pods_subnet

* kube_pods_subnet value updated

* description updated

* description updated

* kube_proxy_mode added on Jenkins file

* kube_proxy_mode added on Jenkins file

* kube_proxy_mode added the main.yaml

* adding reboot module

* space

* nodelocaldns_ip default value updated

* calico_iptables_backend added

* nodelocaldns_ip default value updated
  • Loading branch information
yiskaneto authored Feb 14, 2023
1 parent fc6ec95 commit c8c79ea
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 4 deletions.
51 changes: 48 additions & 3 deletions K8_KubeSpray.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ pipeline {
defaultValue: false,
description: 'Only uninstall, if this is set to true then the other stages will be skiped'
)
booleanParam(
name: 'restart_node',
defaultValue: false,
description: 'Recommended after resseting k8s'
)
booleanParam(
name: 'run_requirements',
defaultValue: true,
Expand Down Expand Up @@ -116,7 +121,13 @@ pipeline {
)
choice(
name: 'kube_network_plugin',
choices: ['calico','flannel','cilium','weave','cloud'],
choices: ['calico','flannel','cilium','weave','cloud','canal'],
description: 'valid values: calico, flannel, cilium, weave, cloud, canal'
)
choice(
name: 'calico_iptables_backend',
choices: ['NFT','Auto','Legacy'],
description: 'valid values: NFT, Auto, Legacy. '
)
choice(
name: 'etcd_deployment_type',
Expand Down Expand Up @@ -228,6 +239,11 @@ pipeline {
defaultValue: false,
description: 'Whether or not to use localhost as kubeapi loadbalancer'
)
choice(
name: 'kube_proxy_mode',
choices: ['ipvs','iptables'],
description: 'Valid values: ipvs, iptables. Use ipvs for Red Hat-Based Linux Distributions'
)
string(
name: 'kube_service_addresses',
defaultValue: '10.233.0.0/18',
Expand All @@ -238,6 +254,11 @@ pipeline {
defaultValue: '10.233.64.0/18',
description: 'Internal network. When used, it will assign IP addresses from this range to individual pods. This network must be unused in your network infrastructure!'
)
string(
name: 'nodelocaldns_ip',
defaultValue: '10.233.0.10',
description: "node local dns ip, which will be a be added in the nodes' /etc/resolve.conf"
)
string(
name: 'kubespray_temp_dir',
defaultValue: '/tmp/kubespray_temp_dir',
Expand Down Expand Up @@ -322,7 +343,28 @@ pipeline {
}
}

// stage('Running OS requirements K8s') {
stage('Reboot Nodes') {
when {
expression { params.restart_node == true }
}
steps {
sh """
echo "Rebooting nodes"
"""
ansiblePlaybook(
playbook: "${env.WORKSPACE}/roles/Requirements/reboot_target_nodes.yaml",
inventory: "${env.WORKSPACE}/inventory.ini",
forks: 16,
colorized: true,
extras: '-u ${user} --ssh-extra-args=" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --flush-cache -v',
extraVars: [
jenkins_workspace: "${env.WORKSPACE}/"
]
)
}
}

// stage('Running OS requirements K8s') {
// when {
// expression { params.run_requirements == true && params.only_reset_k8s_cluster == false }
// }
Expand Down Expand Up @@ -377,6 +419,7 @@ pipeline {
http_proxy: "${params.http_proxy}",
https_proxy: "${params.https_proxy}",
no_proxy: "${params.no_proxy}",
calico_iptables_backend: "${params.calico_iptables_backend}",
etcd_deployment_type: "${params.etcd_deployment_type}",
etcd_data_dir: "${params.etcd_data_dir}",
use_external_load_balancer: "${params.use_external_load_balancer}",
Expand All @@ -400,13 +443,15 @@ pipeline {
docker_daemon_graph: "${params.docker_daemon_graph}",
containerd_storage_dir: "${params.containerd_storage_dir}",
docker_log_opts: "${params.docker_log_opts}",
kube_proxy_mode: "${params.kube_proxy_mode}",
kube_service_addresses: "${params.kube_service_addresses}",
kube_pods_subnet: "${params.kube_pods_subnet}",
nodelocaldns_ip: "${params.nodelocaldns_ip}",
local_release_dir: "${params.kubespray_temp_dir}"
]
)
}
}
}

stage('Running KubeSpray') {
when {
Expand Down
9 changes: 9 additions & 0 deletions roles/Requirements/reboot_target_nodes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- hosts: all
remote_user: root
gather_facts: false
tasks:
- name: Rebooting all nodes using ansible module
reboot:
reboot_timeout: 1800
test_command: whoami
1 change: 1 addition & 0 deletions roles/Requirements/tasks/populate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- import_tasks: populate/update_all_cluster_variables.yaml
- import_tasks: populate/update_k8s_cluster_variables.yaml
- import_tasks: populate/update_k8s_addons_variables.yaml
- import_tasks: populate/update_k8s_net_calico.yaml
- import_tasks: populate/update_all_docker.yaml
- import_tasks: populate/update_all_containerd.yaml
- import_tasks: populate/update_etcd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
regexp: "^kube_network_plugin: "
line: "kube_network_plugin: {{ kube_network_plugin }}"

- name: Updating kube_proxy_mode inventory/mycluster/group_vars/k8s_cluster/k8s-cluster.yml
ansible.builtin.lineinfile:
path: "{{ jenkins_workspace }}kubespray/inventory/mycluster/group_vars/k8s_cluster/k8s-cluster.yml"
regexp: "^kube_proxy_mode: "
line: "kube_proxy_mode: {{ kube_proxy_mode }}"

- name: Updating kube_service_addresses inventory/mycluster/group_vars/k8s_cluster/k8s-cluster.yml
ansible.builtin.lineinfile:
path: "{{ jenkins_workspace }}kubespray/inventory/mycluster/group_vars/k8s_cluster/k8s-cluster.yml"
Expand All @@ -23,6 +29,12 @@
regexp: "^kube_pods_subnet: "
line: "kube_pods_subnet: {{ kube_pods_subnet }}"

- name: Updating nodelocaldns_ip inventory/mycluster/group_vars/k8s_cluster/k8s-cluster.yml
ansible.builtin.lineinfile:
path: "{{ jenkins_workspace }}kubespray/inventory/mycluster/group_vars/k8s_cluster/k8s-cluster.yml"
regexp: "^nodelocaldns_ip: "
line: "nodelocaldns_ip: {{ nodelocaldns_ip }}"

- name: Updating cluster_name inventory/mycluster/group_vars/k8s_cluster/k8s-cluster.yml
ansible.builtin.lineinfile:
path: "{{ jenkins_workspace }}kubespray/inventory/mycluster/group_vars/k8s_cluster/k8s-cluster.yml"
Expand Down
6 changes: 6 additions & 0 deletions roles/Requirements/tasks/populate/update_k8s_net_calico.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Updating calico_iptables_backend on inventory/mycluster/group_vars/k8s_cluster/k8s-net-calico.yml
ansible.builtin.lineinfile:
path: "{{ jenkins_workspace }}kubespray/inventory/mycluster/group_vars/k8s_cluster/k8s-net-calico.yml"
regexp: "^calico_iptables_backend: "
line: "calico_iptables_backend: {{ calico_iptables_backend }}"
7 changes: 6 additions & 1 deletion roles/Requirements/vars/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ no_proxy: "{{ no_proxy }}"
# File from KubeSpray kubeSpray/inventory/mycluster/group_vars/k8s_cluster/k8s_cluster.yml
cluster_name: "{{ cluster_name }}"
local_release_dir: "{{ local_release_dir }}"
kube_proxy_mode: "{{ kube_proxy_mode }}"
kube_service_addresses: "{{ kube_service_addresses }}"
kube_pods_subnet: "{{ kube_pods_subnet }}"
nodelocaldns_ip: "{{ nodelocaldns_ip }}"
container_manager: "{{ container_manager }}"
resolvconf_mode: "{{ resolvconf_mode }}"
kube_network_plugin: "{{ kube_network_plugin }}"
Expand All @@ -39,4 +41,7 @@ docker_log_opts: "{{ docker_log_opts }}"
containerd_storage_dir: "{{ containerd_storage_dir }}"

# File from KubeSpray kubeSpray/inventory/mycluster/group_vars/etcd.yml
etcd_deployment_type: "{{ etcd_deployment_type }}"
etcd_deployment_type: "{{ etcd_deployment_type }}"

# File from KubeSpray kubeSpray/inventory/mycluster/group_vars/k8s_cluster/k8s-net-calico.yml
calico_iptables_backend: "{{ calico_iptables_backend }}"

0 comments on commit c8c79ea

Please sign in to comment.