Skip to content

Commit a30faf1

Browse files
authored
Merge pull request #102 from sriramandev/topic/prepare-1.30.11
Add support for v1.30.11 vSphere Kubernetes Release
2 parents e27c536 + 5db9b8c commit a30faf1

12 files changed

Lines changed: 119 additions & 12 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import argparse
2+
import json
3+
import subprocess
4+
5+
IMAGE_NAME = "docker.io/vmware/docker-registry"
6+
PAUSE_IMAGE_NAME = "localhost:5000/vmware.io/pause"
7+
LABEL = "io.cri-containerd.pinned=pinned"
8+
9+
def get_image_version(image_name):
10+
cp = subprocess.run(["crictl", "images", "-o", "json"], capture_output=True, text=True)
11+
cp.check_returncode()
12+
images = json.loads(cp.stdout)["images"]
13+
for image in images:
14+
for repo_tag in image["repoTags"]:
15+
if repo_tag.startswith(image_name):
16+
return repo_tag.split(":")[-1]
17+
else:
18+
raise Exception(f"No image with name {image_name} found")
19+
20+
def get_registry_version():
21+
return get_image_version(IMAGE_NAME)
22+
23+
def get_pause_version():
24+
return get_image_version(PAUSE_IMAGE_NAME)
25+
26+
def apply_label(image):
27+
subprocess.run(["ctr", "-n", "k8s.io", "images", "label", image, LABEL], check=True)
28+
29+
def pin_image():
30+
image_name_with_version = IMAGE_NAME + ":" + get_registry_version()
31+
apply_label(image_name_with_version)
32+
33+
pause_image_name_with_version = PAUSE_IMAGE_NAME + ":" + get_pause_version()
34+
apply_label(pause_image_name_with_version)
35+
36+
def main():
37+
parser = argparse.ArgumentParser(
38+
description='Script to copy carvel packages')
39+
parser.add_argument('--version',
40+
action='store_true',
41+
help='Print version of docker-registry image')
42+
parser.add_argument('--pin',
43+
action='store_true',
44+
help='Pin image by applying label io.cri-containerd.pinned=pinned')
45+
46+
args = parser.parse_args()
47+
if args.version:
48+
print(get_registry_version())
49+
elif args.pin:
50+
pin_image()
51+
52+
53+
if __name__ == '__main__':
54+
main()

ansible/tasks/main.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Copyright 2023 VMware, Inc.
1+
# © Broadcom. All Rights Reserved.
2+
# The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
23
# SPDX-License-Identifier: MPL-2.0
34
---
45
- import_tasks: common.yml
@@ -20,9 +21,11 @@
2021
register: registry_store_url_check
2122
ignore_errors: true
2223

24+
# Used in Windows OVA builds
2325
- import_tasks: registry.yml
2426
when: registry_store_url_check.status == 200
2527

28+
# Used in Linux OVA builds
2629
- import_tasks: retag_images.yml
2730
when: registry_store_url_check.status != 200
2831

@@ -35,4 +38,15 @@
3538
args:
3639
executable: /bin/bash
3740

38-
- import_tasks: disable_pwd_rotation.yml
41+
- import_tasks: disable_pwd_rotation.yml
42+
43+
# Gather list of installed packages
44+
- name: Gather the package facts
45+
ansible.builtin.package_facts:
46+
manager: auto
47+
48+
- name: Copy installed package details to local file
49+
ansible.builtin.copy:
50+
content: "{{ ansible_facts.packages | to_nice_json }}"
51+
dest: "{{ output_dir }}/package_list.json"
52+
delegate_to: localhost

ansible/tasks/retag_images.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Copyright 2023 VMware, Inc.
1+
# (c) Broadcom. All Rights Reserved.
2+
# The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
23
# SPDX-License-Identifier: MPL-2.0
34
---
45
- name: Retag Container Images
@@ -14,6 +15,11 @@
1415
args:
1516
executable: python3
1617

18+
- name: Pin container images
19+
ansible.builtin.script: files/scripts/docker_registry_ops.py --pin
20+
args:
21+
executable: python3
22+
1723
- name: Stop docker registry
1824
shell: 'ctr -n k8s.io task kill docker-registry'
1925

build-ova.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ function download_configuration_files() {
3131
# Download compatibility files
3232
wget -q http://${HOST_IP}:${ARTIFACTS_CONTAINER_PORT}/artifacts/metadata/compatibility/vmware-system.compatibilityoffering.json
3333
wget -q http://${HOST_IP}:${ARTIFACTS_CONTAINER_PORT}/artifacts/metadata/compatibility/vmware-system.guest.kubernetes.distribution.image.version.json
34+
35+
# Download VKr constraints files
36+
wget -q http://${HOST_IP}:${ARTIFACTS_CONTAINER_PORT}/artifacts/metadata/vmware-system.kr.destination-semver-constraint.json || echo "override-semver-constraint.json don't exist"
37+
wget -q http://${HOST_IP}:${ARTIFACTS_CONTAINER_PORT}/artifacts/metadata/vmware-system.kr.override-semver-constraint.json || echo "override-semver-constraint.json don't exist"
3438
}
3539

3640
# Generate packaer input variables based on packer-variables folder

goss/goss-command.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Copyright 2023 VMware, Inc.
1+
# © Broadcom. All Rights Reserved.
2+
# The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
23
# SPDX-License-Identifier: MPL-2.0
34

45
command:
@@ -10,9 +11,15 @@ command:
1011
timeout: 0
1112
crictl ps:
1213
exit-status: 0
13-
stdout: []
14-
stderr: []
1514
timeout: 0
15+
ctr -n k8s.io image ls 2>/dev/null | grep docker-registry | grep 'io.cri-containerd.pinned=pinned':
16+
exit-status: 0
17+
stderr: []
18+
timeout: 10000 # in ms
19+
ctr -n k8s.io image ls 2>/dev/null | grep pause | grep 'io.cri-containerd.pinned=pinned':
20+
exit-status: 0
21+
stderr: []
22+
timeout: 10000 # in ms
1623
{{if ne .Vars.containerd_wasm_shims_runtimes ""}}
1724
containerd-shim-lunatic-v1:
1825
exit-status: 1

packer-variables/default-args.j2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@
3838
"remove_extra_repos": "true",
3939
{# Packer VM name #}
4040
"build_version": "{{ os_type }}-kube-{{ kubernetes_series }}-{{ ova_ts_suffix }}",
41-
"custom_role": "true"
41+
"custom_role": "true",
42+
"output_dir": "/image-builder/images/capi/output/{{ os_type }}-kube-{{ kubernetes_series }}-{{ ova_ts_suffix }}"
4243
}

packer-variables/photon-5/default-args-photon-5.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
location after mounting that Path using docker #}
44
"custom_role_names": "/image-builder/images/capi/image/ansible /image-builder/images/capi/image/compliance",
55
"distro_version": "5.0",
6-
"extra_rpms": "glibc zlib filesystem ethtool pkg-config bash bzip2 shadow procps-ng iana-etc coreutils bc libtool findutils xz iproute2 util-linux kmod linux linux-devel iptables Linux-PAM systemd dbus file e2fsprogs rpm gawk cloud-utils gptfdisk nfs-utils openssh gdbm photon-release photon-repos haveged sed grep cpio gzip vim tdnf less iputils bindutils diffutils bridge-utils cri-tools apparmor-utils apparmor-profiles krb5 which tzdata motd sudo iotop lsof traceroute ethtool dstat ltrace ipset netcat tcpdump wget net-tools curl tar open-vm-tools libseccomp cloud-init sysstat jq conntrack dkms",
6+
"extra_rpms": "glibc zlib filesystem ethtool pkg-config bash bzip2 shadow procps-ng iana-etc coreutils bc libtool findutils xz iproute2 util-linux kmod linux linux-devel iptables Linux-PAM systemd dbus file e2fsprogs rpm gawk cloud-utils gptfdisk nfs-utils openssh gdbm photon-release photon-repos haveged sed grep cpio gzip vim tdnf less iputils bindutils diffutils bridge-utils cri-tools apparmor-utils apparmor-profiles krb5 which tzdata motd sudo iotop lsof traceroute ethtool dstat ltrace ipset netcat tcpdump wget net-tools curl tar open-vm-tools libseccomp cloud-init sysstat jq conntrack dkms python3-rpm",
77
{# additional variables passed to the ansible role, if stig is enabled #}
88
{# variables passed to the ansible role are appended to this list at the end #}
9-
"ansible_user_vars": "artifacts_container_url=http://{{ host_ip }}:{{ artifacts_container_port }} dockerVersion={{ docker_distribution }} imageVersion={{ image_version|replace('-', '.') }} ansible_python_interpreter=/usr/bin/python3 addon_image_list=http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/calico.tar,http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/metrics-server.tar{% if capabilities_package_present %},http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/capabilities.tar{% endif %},http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/guest-cluster-auth-service.tar,http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/pinniped.tar,http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/antrea.tar,http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/vsphere-cpi.tar,http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/vsphere-pv-csi.tar,http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/secretgen-controller.tar,http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/kapp-controller.tar{% if gateway_package_present %},http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/gateway-api.tar{% endif %} localhost_addon_image_list={{ calico_package_localhost_path }},{{ metrics_server_package_localhost_path }}{% if capabilities_package_present %},{{ capabilities_package_localhost_path }}{% endif %},{{ guest_cluster_auth_service_package_localhost_path }},{{ pinniped_package_localhost_path }},{{ antrea_package_localhost_path }},{{ vsphere_cpi_package_localhost_path }},{{ vsphere_pv_csi_package_localhost_path }},{{ secretgen_controller_package_localhost_path }},{{ kapp_controller_localhost_path }}{% if gateway_package_present %},{{ gateway_api_package_localhost_path }}{% endif %} networkd_dispatcher_download_url=http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/networkd-dispatcher-2.1.tar.bz2 registry_store_archive_url=http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/registries/{{ registry_store_path }} run_sysctl_net_ipv6_conf_all_mc_forwarding=false run_sysctl_net_ipv6_conf_default_mc_forwarding=false run_sysctl_net_ipv6_conf_eth0_mc_forwarding=false run_kernel_net_ip_forward=false run_modprobe_conf=false run_fips_boot_enable=false run_openssl_fips=false run_sshd_banner=false"
9+
"ansible_user_vars": "artifacts_container_url=http://{{ host_ip }}:{{ artifacts_container_port }} dockerVersion={{ docker_distribution }} imageVersion={{ image_version|replace('-', '.') }} ansible_python_interpreter=/usr/bin/python3 addon_image_list=http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/calico.tar,http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/metrics-server.tar{% if capabilities_package_present %},http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/capabilities.tar{% endif %},http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/guest-cluster-auth-service.tar,http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/pinniped.tar,http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/antrea.tar,http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/vsphere-cpi.tar,http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/vsphere-pv-csi.tar,http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/secretgen-controller.tar,http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/kapp-controller.tar{% if gateway_package_present %},http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/gateway-api.tar{% endif %} localhost_addon_image_list={{ calico_package_localhost_path }},{{ metrics_server_package_localhost_path }}{% if capabilities_package_present %},{{ capabilities_package_localhost_path }}{% endif %},{{ guest_cluster_auth_service_package_localhost_path }},{{ pinniped_package_localhost_path }},{{ antrea_package_localhost_path }},{{ vsphere_cpi_package_localhost_path }},{{ vsphere_pv_csi_package_localhost_path }},{{ secretgen_controller_package_localhost_path }},{{ kapp_controller_localhost_path }}{% if gateway_package_present %},{{ gateway_api_package_localhost_path }}{% endif %} networkd_dispatcher_download_url=http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/networkd-dispatcher-2.1.tar.bz2 registry_store_archive_url=http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/registries/{{ registry_store_path }} run_sysctl_net_ipv6_conf_all_mc_forwarding=false run_sysctl_net_ipv6_conf_default_mc_forwarding=false run_sysctl_net_ipv6_conf_eth0_mc_forwarding=false run_kernel_net_ip_forward=false run_modprobe_conf=false run_fips_boot_enable=false run_openssl_fips=false run_sshd_banner=false output_dir=/image-builder/images/capi/output/{{ os_type }}-kube-{{ kubernetes_series }}-{{ ova_ts_suffix }}"
1010
}

packer-variables/ubuntu-2204-efi/default-args-ubuntu-2204-efi.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"custom_role_names": "/image-builder/images/capi/image/ansible",
33
"distro_version": "22.04",
44
"extra_debs": "unzip iptables-persistent nfs-common dkms",
5+
"ansible_user_vars": "artifacts_container_url=http://{{ host_ip }}:{{ artifacts_container_port }} dockerVersion={{ docker_distribution }} imageVersion={{ image_version|replace('-', '.') }} ansible_python_interpreter=/usr/bin/python3 addon_image_list=http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/calico.tar,http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/metrics-server.tar{% if capabilities_package_present %},http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/capabilities.tar{% endif %},http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/guest-cluster-auth-service.tar,http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/pinniped.tar,http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/antrea.tar,http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/vsphere-cpi.tar,http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/vsphere-pv-csi.tar,http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/secretgen-controller.tar,http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/kapp-controller.tar{% if gateway_package_present %},http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/packages/gateway-api.tar{% endif %} localhost_addon_image_list={{ calico_package_localhost_path }},{{ metrics_server_package_localhost_path }}{% if capabilities_package_present %},{{ capabilities_package_localhost_path }}{% endif %},{{ guest_cluster_auth_service_package_localhost_path }},{{ pinniped_package_localhost_path }},{{ antrea_package_localhost_path }},{{ vsphere_cpi_package_localhost_path }},{{ vsphere_pv_csi_package_localhost_path }},{{ secretgen_controller_package_localhost_path }},{{ kapp_controller_localhost_path }}{% if gateway_package_present %},{{ gateway_api_package_localhost_path }}{% endif %} networkd_dispatcher_download_url=http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/networkd-dispatcher-2.1.tar.bz2 registry_store_archive_url=http://{{ host_ip }}:{{ artifacts_container_port }}/artifacts/{{ kubernetes_version }}/registries/{{ registry_store_path }} output_dir=/image-builder/images/capi/output/{{ os_type }}-kube-{{ kubernetes_series }}-{{ ova_ts_suffix }}",
56
"boot_disable_ipv6": "1",
67
"ip_settle_timeout": "15m"
78
}

scripts/tkg_byoi.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,13 @@ def copy_ova(args):
232232
old_path = os.path.join(default_ova_destination_folder, old_ova_name)
233233
print("Copying OVA from {} to {}".format(old_path, new_path))
234234
shutil.copyfile(old_path, new_path)
235+
236+
# Copy the package list
237+
old_path = os.path.join(default_ova_destination_folder, "package_list.json")
238+
new_path = os.path.join(args.ova_destination_folder, "package_list.json")
239+
print("Copying package list file from {} to {}".format(old_path, new_path))
240+
shutil.copyfile(old_path, new_path)
241+
235242
print("Copying completed")
236243

237244

scripts/utkg_custom_ovf_properties.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22

3-
# Copyright 2023 VMware, Inc.
3+
# © Broadcom. All Rights Reserved.
4+
# The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
45
# SPDX-License-Identifier: MPL-2.0
56

67
import argparse
@@ -93,6 +94,17 @@ def create_non_addon_ovf_properties():
9394
key = Path(file).stem
9495
custom_ovf_properties[key] = convert_to_xml(data)
9596

97+
def create_non_addon_VKr_constraints_ovf_properties():
98+
filenames = [ join(tkg_core_directory,"vmware-system.kr.destination-semver-constraint.json"),
99+
join(tkg_core_directory,"vmware-system.kr.override-k8s-semver-version.json")]
100+
for file in filenames:
101+
try:
102+
with open(file) as f:
103+
data = json.dumps(json.load(f)).replace('"','')
104+
key = Path(file).stem
105+
custom_ovf_properties[key] = convert_to_xml(compress_and_base64_encode(data))
106+
except IOError:
107+
print("couldn't find/read file: ",file)
96108

97109
# fetch tkr apiversion and tkr version
98110
def fetch_tkr_data():
@@ -328,6 +340,7 @@ def main():
328340
set_versions(args)
329341
create_utkg_tkr_metadata_ovf_properties()
330342
create_non_addon_ovf_properties()
343+
create_non_addon_VKr_constraints_ovf_properties()
331344
write_properties_to_file(args.outfile)
332345
print(custom_ovf_properties)
333346

0 commit comments

Comments
 (0)