8000 Updating code for k8s dynamic module, kube vip interface and updating pip conf by Katakam-Rakesh · Pull Request #3125 · dell/omnia · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Updating code for k8s dynamic module, kube vip interface and updating pip conf #3125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Jun 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e2a1fb9
updated prepare oim
Katakam-Rakesh Jun 13, 2025
8ce4586
Merge branch 'pub/k8s' of github.com:Katakam-Rakesh/omnia into pub/k8s
Katakam-Rakesh Jun 16, 2025
f99c895
lint fix
Katakam-Rakesh Jun 16, 2025
a9ad770
Merge branch 'pub/k8s' of github.com:Katakam-Rakesh/omnia into pub/k8s
Katakam-Rakesh Jun 16, 2025
ae788f1
updated k8s for kube-vip with cidr
Katakam-Rakesh Jun 16, 2025
12ddddd
Merge branch 'pub/k8s' of github.com:Katakam-Rakesh/omnia into pub/k8s
Katakam-Rakesh Jun 17, 2025
46d9d33
updated code for k8s offline install false
Katakam-Rakesh Jun 17, 2025
f344a92
Merge branch 'pub/k8s' of github.com:Katakam-Rakesh/omnia into pub/k8s
Katakam-Rakesh Jun 17, 2025
fbd978c
updated code for k8s offline install false
Katakam-Rakesh Jun 17, 2025
a677ba5
Merge branch 'pub/k8s' of github.com:Katakam-Rakesh/omnia into pub/k8s
Katakam-Rakesh Jun 17, 2025
330908d
updated local repo
Katakam-Rakesh Jun 17, 2025
f61a7e1
Merge branch 'pub/k8s' of github.com:Katakam-Rakesh/omnia into pub/k8s
Katakam-Rakesh Jun 17, 2025
c61ebdb
updated code for kube vip interface
Katakam-Rakesh Jun 17, 2025
590a4dc
Merge branch 'pub/k8s' of github.com:Katakam-Rakesh/omnia into pub/k8s
Katakam-Rakesh Jun 19, 2025
a05598a
removed pip.conf from sync files
Katakam-Rakesh Jun 19, 2025
324df28
Merge branch 'pub/k8s' of github.com:Katakam-Rakesh/omnia into pub/k8s
Katakam-Rakesh Jun 19, 2025
a3409d5
fixed review comments
Katakam-Rakesh Jun 19, 2025
616d2f0
Merge branch 'pub/k8s' of github.com:Katakam-Rakesh/omnia into pub/k8s
Katakam-Rakesh Jun 20, 2025
bd41c0c
reverted pip conf changes
Katakam-Rakesh Jun 20, 2025
9692581
Merge branch 'pub/k8s' of github.com:Katakam-Rakesh/omnia into pub/k8s
Katakam-Rakesh Jun 20, 2025
dff6dc6
Update pip.conf.j2
Katakam-Rakesh Jun 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions common/library/modules/match_subnet_and_update_inv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Copyright 2025 Dell Inc. or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#!/usr/bin/python
"""
Ansible module to find the network interface in a given subnet
and update kube_vip_interface in the kube_control_plane group
of the inventory file.
"""

import ipaddress
import re
from ansible.module_utils.basic import AnsibleModule


def update_kube_control_plane_block(inventory_path, hostname, matched_iface):
"""Update or append kube_vip_interface for the given host in the kube_control_plane group."""
with open(inventory_path, 'r', encoding='utf-8') as f:
lines = f.readlines()

in_control_plane = False
updated = False

for i, line in enumerate(lines):
stripped = line.strip()

if stripped.startswith('['):
in_control_plane = stripped == "[kube_control_plane]"

if in_control_plane and re.match(rf"^{re.escape(hostname)}\b", stripped):
if f'kube_vip_interface={matched_iface}' in stripped:
break
elif 'kube_vip_interface=' in stripped:
new_line = re.sub(r'kube_vip_interface=\S+', f'kube_vip_interface={matched_iface}', stripped)
else:
new_line = stripped + f' kube_vip_interface={matched_iface}'

lines[i] = new_line + "\n"
updated = True
break

if updated:
with open(inventory_path, 'w', encoding='utf-8') as f:
f.writelines(lines)

return updated


def run_module():
"""Main module logic."""
module_args = {
"interfaces": {"type": "dict", "required": True},
"subnet": {"type": "str", "required": True},
"hostname": {"type": "str", "required": True},
"inventory_path": {"type": "str", "required": True}
}

result = {
"changed": False,
"matched_interface": None,
"updated_inventory": False,
"msg": ""
}

module = AnsibleModule(argument_spec=module_args, supports_ 8000 check_mode=True)

interfaces = module.params['interfaces']
subnet = module.params['subnet']
hostname = module.params['hostname']
inventory_path = module.params['inventory_path']

try:
network = ipaddress.ip_network(subnet, strict=False)
matched_iface = None

for iface_name, iface_data in interfaces.items():
if 'ipv4' in iface_data and 'address' in iface_data['ipv4']:
ip = iface_data['ipv4']['address']
if ipaddress.ip_address(ip) in network:
matched_iface = iface_name
break

if matched_iface:
result["matched_interface"] = matched_iface
if not module.check_mode:
updated = update_kube_control_plane_block(inventory_path, hostname, matched_iface)
result["updated_inventory"] = updated
result["changed"] = updated
result["msg"] = f"Matched interface {matched_iface} and updated kube_control_plane group."
else:
result["msg"] = "No matching interface found."

except Exception as e:
module.fail_json(msg=f"Failed: {e}")

module.exit_json(**result)


def main():
"""Entry point."""
run_module()


if __name__ == '__main__':
main()
2 changes: 0 additions & 2 deletions discovery/roles/configure_synclist/templates/pip.conf.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
[global]
find-links =
{{ offline_pip_module_path }}
trusted-host = {{ pulp_server_ip }}
135 changes: 71 additions & 64 deletions input/config/rhel/9.6/k8s.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,60 @@
{
"k8s": {
"cluster": [
{"package": "firewalld", "type": "rpm", "repo_name": "baseos"},
{"package": "python3-firewall", "type": "rpm", "repo_name": "baseos"},
"k8s": {
"cluster": [
{
"package": "firewalld",
"type": "rpm",
"repo_name": "baseos"
},
{
"package": "python3-firewall",
"type": "rpm",
"repo_name": "baseos"
},
{
"package": "nvidia-container-toolkit",
"type": "rpm",
"repo_name": "nvidia-repo"
},
{
"package": "python3.11",
"type": "rpm",
"repo_name": "appstream"
},
{
"package": "rocm-device-plugin",
"type": "manifest",
"url": "https://raw.githubusercontent.com/ROCm/k8s-device-plugin/r1.16/k8s-ds-amdgpu-dp.yaml"
},
{
"package": "mpi-operator-v0.6.0",
"type": "manifest",
"url": "https://raw.githubusercontent.com/kubeflow/mpi-operator/v0.6.0/deploy/v2beta1/mpi-operator.yaml"
},
{
"package": "xilinx-device-plugin",
"type": "manifest",
"url": "https://raw.githubusercontent.com/Xilinx/FPGA_as_a_Service/2023.2/k8s-device-plugin/k8s-device-plugin.yml"
},
{
"package": "multus-daemonset",
"type": "manifest",
"url": "https://raw.githubusercontent.com/k8snetworkplumbingwg/multus-cni/master/deployments/multus-daemonset.yml"
},
{
"package": "kubernetes==32.0.1",
"type": "pip_module"
},
{
"package": "prettytable==3.14.0",
"type": "pip_module"
},
{
"package": "whereabouts",
"url": "https://github.com/k8snetworkplumbingwg/whereabouts.git",
"type": "git",
"version": "v0.8.0"
},
{
"package": "kubectl-v1.31.4",
"type": "tarball",
Expand All @@ -24,14 +71,14 @@
"url": "https://dl.k8s.io/release/v1.31.4/bin/linux/amd64/kubeadm"
},
{
"package": "calicoctl-v3.29.1",
"package": "calicoctl-v3.29.3",
"type": "tarball",
"url": "https://github.com/projectcalico/calico/releases/download/v3.29.1/calicoctl-linux-amd64"
"url": "https://github.com/projectcalico/calico/releases/download/v3.29.3/calicoctl-linux-amd64"
},
{
"package": "calico.archive-v3.29.1",
"package": "calico.archive-v3.29.3",
"type": "tarball",
"url": "https://github.com/projectcalico/calico/archive/v3.29.1.tar.gz"
"url": "https://github.com/projectcalico/calico/archive/v3.29.3.tar.gz"
},
{
"package": "crictl-v1.31.1",
Expand All @@ -44,24 +91,24 @@
"url": "https://github.com/etcd-io/etcd/releases/download/v3.5.16/etcd-v3.5.16-linux-amd64.tar.gz"
},
{
"package": "cni-v1.4.0",
"package": "cni-v1.4.1",
"type": "tarball",
"url": "https://github.com/containernetworking/plugins/releases/download/v1.4.0/cni-plugins-linux-amd64-v1.4.0.tgz"
"url": "https://github.com/containernetworking/plugins/releases/download/v1.4.1/cni-plugins-linux-amd64-v1.4.1.tgz"
},
{
"package": "runc.amd64-v1.2.3",
"package": "runc.amd64-v1.2.6",
"type": "tarball",
"url": "https://github.com/opencontainers/runc/releases/download/v1.2.3/runc.amd64"
"url": "https://github.com/opencontainers/runc/releases/download/v1.2.6/runc.amd64"
},
{
"package": "nerdctl-v1.7.7",
"package": "nerdctl-v2.0.5",
"type": "tarball",
"url": "https://github.com/containerd/nerdctl/releases/download/v1.7.7/nerdctl-1.7.7-linux-amd64.tar.gz"
"url": "https://github.com/containerd/nerdctl/releases/download/v2.0.5/nerdctl-2.0.5-linux-amd64.tar.gz"
},
{
"package": "containerd-v1.7.24",
"package": "containerd-v2.0.5",
"type": "tarball",
"url": "https://github.com/containerd/containerd/releases/download/v1.7.24/containerd-1.7.24-linux-amd64.tar.gz"
"url": "https://github.com/containerd/containerd/releases/download/v2.0.5/containerd-2.0.5-linux-amd64.tar.gz"
},
{
"package": "helm-v3.16.4",
Expand All @@ -73,21 +120,6 @@
"type": "tarball",
"url": "https://nvidia.github.io/k8s-device-plugin/stable/nvidia-device-plugin-0.14.4.tgz"
},
{
"package": "rocm-device-plugin",
"type": "manifest",
"url": "https://raw.githubusercontent.com/ROCm/k8s-device-plugin/r1.16/k8s-ds-amdgpu-dp.yaml"
},
{
"package": "mpi-operator-v0.6.0",
"type": "manifest",
"url": "https://raw.githubusercontent.com/kubeflow/mpi-operator/v0.6.0/deploy/v2beta1/mpi-operator.yaml"
},
{
"package": "xilinx-device-plugin",
"type": "manifest",
"url": "https://raw.githubusercontent.com/Xilinx/FPGA_as_a_Service/2023.2/k8s-device-plugin/k8s-device-plugin.yml"
},
{
"package": "spark-operator-v1beta2-1.3.8-3.1.1",
"type": "tarball",
Expand All @@ -98,23 +130,14 @@
"type": "tarball",
"url": "https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner/releases/download/nfs-subdir-external-provisioner-4.0.18/nfs-subdir-external-provisioner-4.0.18.tgz"
},
{"package": "python3.11", "type": "rpm", "repo_name": "appstream"},
{
"package": "kubernetes==32.0.1",
"type": "pip_module"
},
{
"package": "prettytable==3.14.0",
"type": "pip_module"
},
{
"package": "public.ecr.aws/xilinx_dcg/k8s-device-plugin",
"tag": "1.2.0",
"type": "image"
},
{
"package": "docker.io/library/nginx",
"tag": "1.25.2-alpine",
"tag": "1.27.4-alpine",
"type": "image"
},
{
Expand All @@ -129,7 +152,7 @@
},
{
"package": "registry.k8s.io/dns/k8s-dns-node-cache",
"tag": "1.22.28",
"tag": "1.25.0",
"type": "image"
},
{
Expand Down Expand Up @@ -164,12 +187,12 @@
},
{
"package": "quay.io/calico/cni",
"tag": "v3.29.1",
"tag": "v3.29.3",
"type": "image"
},
{
"package": "quay.io/calico/kube-controllers",
"tag": "v3.29.1",
"tag": "v3.29.3",
"type": "image"
},
{
Expand All @@ -179,7 +202,7 @@
},
{
"package": "quay.io/calico/node",
"tag": "v3.29.1",
"tag": "v3.29.3",
"type": "image"
},
{
Expand Down Expand Up @@ -227,11 +250,6 @@
"tag": "0.6.0",
"type": "image"
},
{
"package": "public.ecr.aws/xilinx_dcg/k8s-device-plugin",
"tag": "1.3.0",
"type": "image"
},
{
"package": "nvcr.io/nvidia/k8s-device-plugin",
"tag": "v0.14.4",
Expand Down Expand Up @@ -262,22 +280,11 @@
"tag": "latest",
"type": "image"
},
{
"package": "multus-daemonset",
"type": "manifest",
"url": "https://raw.githubusercontent.com/k8snetworkplumbingwg/multus-cni/master/deployments/multus-daemonset.yml"
},
{
"package": "whereabouts",
"url": "https://github.com/k8snetworkplumbingwg/whereabouts.git",
"type": "git",
"version": "v0.8.0"
},
{
"package": "ghcr.io/kube-vip/kube-vip",
"tag": "v0.8.0",
"tag": "v0.8.9",
"type": "image"
}
]
}
]
}
}
3 changes: 3 additions & 0 deletions local_repo/roles/validation/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
- name: Validate metadata
ansible.builtin.include_tasks: validate_metadata.yml

- name: Validate k8s json
ansible.builtin.include_tasks: validate_k8s_json.yml

- name: Run Kubernetes JSON Generator
ansible.builtin.include_tasks: dynamic_k8s_json.yml
when:
Expand Down
Loading
0