Test dependencies
Some checks failed
continuous-integration/drone Build is failing

This commit is contained in:
2023-02-22 21:24:42 +01:00
commit f2b0a5e7c7
429 changed files with 20330 additions and 0 deletions

3
packer/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/packer_cache/
/output-*/
/output/

4
packer/ami/OWNERS Normal file
View File

@ -0,0 +1,4 @@
# See the OWNERS docs at https://go.k8s.io/owners
approvers:
- cluster-api-aws-maintainers

11
packer/ami/amazon-2.json Normal file
View File

@ -0,0 +1,11 @@
{
"ami_filter_name": "amzn2-ami-hvm-2*",
"ami_filter_owners": "amazon",
"build_name": "amazon-2",
"distribution": "Amazon Linux",
"distribution_release": "Amazon Linux 2",
"distribution_version": "2",
"root_device_name": "/dev/xvda",
"source_ami": "",
"ssh_username": "ec2-user"
}

11
packer/ami/centos-7.json Normal file
View File

@ -0,0 +1,11 @@
{
"ami_filter_name": "CentOS Linux 7 x86_64 HVM EBS ENA*",
"ami_filter_owners": "461800378586",
"build_name": "centos-7",
"distribution": "CentOS",
"distribution_release": "Core",
"distribution_version": "7",
"root_device_name": "/dev/sda1",
"source_ami": "",
"ssh_username": "centos"
}

17
packer/ami/flatcar.json Normal file
View File

@ -0,0 +1,17 @@
{
"ami_filter_name": "Flatcar*{{env `FLATCAR_CHANNEL`}}*",
"ami_filter_owners": "075585003325",
"ansible_extra_vars": "ansible_python_interpreter=/opt/bin/python",
"build_name": "flatcar-{{env `FLATCAR_CHANNEL`}}",
"crictl_source_type": "http",
"distribution": "flatcar",
"kubernetes_cni_source_type": "http",
"kubernetes_source_type": "http",
"python_path": "/opt/bin/builder-env/site-packages",
"root_device_name": "/dev/xvda",
"ssh_username": "core",
"systemd_prefix": "/etc/systemd",
"sysusr_prefix": "/opt",
"sysusrlocal_prefix": "/opt",
"user_data": ""
}

View File

@ -0,0 +1,208 @@
{
"builders": [
{
"access_key": "{{user `aws_access_key`}}",
"ami_description": "{{user `ami_description`}}",
"ami_groups": "{{user `ami_groups`}}",
"ami_name": "capa-ami-{{user `build_name`}}-{{user `kubernetes_semver` | clean_resource_name}}-{{user `build_timestamp`}}",
"ami_product_codes": "",
"ami_regions": "{{user `ami_regions`}}",
"ami_users": "{{user `ami_users`}}",
"associate_public_ip_address": true,
"communicator": "winrm",
"disable_stop_instance": true,
"encrypt_boot": "{{user `encrypted`}}",
"iam_instance_profile": "{{user `iam_instance_profile`}}",
"instance_type": "{{user `builder_instance_type`}}",
"kms_key_id": "{{user `kms_key_id`}}",
"launch_block_device_mappings": [
{
"delete_on_termination": true,
"device_name": "{{ user `root_device_name` }}",
"throughput": "{{ user `throughput` }}",
"volume_size": "{{ user `volume_size` }}",
"volume_type": "{{ user `volume_type` }}"
}
],
"name": "{{user `build_name`}}",
"profile": "{{ user `aws_profile`}}",
"region": "{{ user `aws_region` }}",
"secret_key": "{{user `aws_secret_key`}}",
"security_group_ids": "{{user `aws_security_group_ids`}}",
"skip_create_ami": "{{ user `skip_create_ami`}}",
"skip_profile_validation": "{{user `skip_profile_validation`}}",
"snapshot_groups": "{{user `snapshot_groups`}}",
"snapshot_users": "{{user `snapshot_users`}}",
"source_ami": "{{user `source_ami`}}",
"source_ami_filter": {
"filters": {
"architecture": "x86_64",
"name": "{{user `ami_filter_name`}}",
"root-device-type": "ebs",
"virtualization-type": "hvm"
},
"most_recent": true,
"owners": "{{user `ami_filter_owners`}}"
},
"ssh_keypair_name": "{{user `ssh_keypair_name`}}",
"ssh_private_key_file": "{{user `ssh_private_key_file`}}",
"subnet_id": "{{ user `subnet_id` }}",
"tags": {
"build_date": "{{isotime}}",
"build_timestamp": "{{user `build_timestamp`}}",
"containerd_version": "{{user `containerd_version`}}",
"distribution": "{{user `distribution`}}",
"distribution_version": "{{user `distribution_version`}}",
"image_builder_version": "{{user `ib_version`}}",
"kubernetes_cni_version": "{{user `kubernetes_cni_semver`}}",
"kubernetes_version": "{{user `kubernetes_semver`}}",
"source_ami": "{{user `source_ami`}}"
},
"temporary_security_group_source_cidrs": "{{ user `temporary_security_group_source_cidrs` }}",
"token": "{{ user `aws_session_token` }}",
"type": "amazon-ebs",
"user_data_file": "packer/ami/scripts/winrm_bootstrap.txt",
"vpc_id": "{{ user `vpc_id` }}",
"winrm_insecure": true,
"winrm_timeout": "6m",
"winrm_use_ssl": true,
"winrm_username": "Administrator"
}
],
"post-processors": [
{
"custom_data": {
"containerd_version": "{{user `containerd_version`}}",
"kubernetes_cni_version": "{{user `kubernetes_cni_semver`}}",
"kubernetes_version": "{{user `kubernetes_semver`}}"
},
"output": "{{user `manifest_output`}}",
"type": "manifest"
}
],
"provisioners": [
{
"extra_arguments": [
"-e",
"ansible_winrm_server_cert_validation=ignore",
"--extra-vars",
"{{user `ansible_common_vars`}}",
"--extra-vars",
"{{user `ansible_extra_vars`}}",
"--extra-vars",
"{{user `ansible_user_vars`}}"
],
"playbook_file": "ansible/windows/node_windows.yml",
"type": "ansible",
"use_proxy": false,
"user": "Administrator"
},
{
"restart_timeout": "10m",
"type": "windows-restart"
},
{
"arch": "{{user `goss_arch`}}",
"download_path": "{{user `goss_download_path`}}",
"format": "{{user `goss_format`}}",
"format_options": "{{user `goss_format_options`}}",
"goss_file": "{{user `goss_entry_file`}}",
"inspect": "{{user `goss_inspect_mode`}}",
"remote_folder": "{{user `goss_remote_folder`}}",
"remote_path": "{{user `goss_remote_path`}}",
"skip_install": "{{user `goss_skip_install`}}",
"target_os": "Windows",
"tests": [
"{{user `goss_tests_dir`}}"
],
"type": "goss",
"url": "{{user `goss_url`}}",
"use_sudo": false,
"vars_env": {
"GOSS_MAX_CONCURRENT": "1",
"GOSS_USE_ALPHA": "1"
},
"vars_file": "{{user `goss_vars_file`}}",
"vars_inline": {
"OS": "{{user `distribution` | lower}}",
"PROVIDER": "amazon",
"containerd_version": "{{user `containerd_version`}}",
"distribution_version": "{{user `distribution_version`}}",
"docker_ee_version": "{{user `docker_ee_version`}}",
"kubernetes_version": "{{user `kubernetes_semver`}}",
"pause_image": "{{user `pause_image`}}",
"runtime": "{{user `runtime`}}",
"ssh_source_url": "{{user `ssh_source_url`}}"
},
"version": "{{user `goss_version`}}"
},
{
"inline": [
"rm -Force -Recurse C:\\var\\log\\kubelet\\*"
],
"type": "powershell"
},
{
"elevated_password": "{{.WinRMPassword}}",
"elevated_user": "Administrator",
"script": "packer/ami/scripts/sysprep_prerequisites.ps1",
"type": "powershell"
},
{
"inline": [
"C:/ProgramData/Amazon/EC2-Windows/Launch/Scripts/SysprepInstance.ps1"
],
"type": "powershell"
}
],
"variables": {
"additional_debug_files": null,
"ami_description": "Cluster API base image designed for {{user `kubernetes_semver`}}",
"ami_groups": "all",
"ami_regions": "ap-south-1,eu-west-3,eu-west-2,eu-west-1,ap-northeast-2,ap-northeast-1,sa-east-1,ca-central-1,ap-southeast-1,ap-southeast-2,eu-central-1,us-east-1,us-east-2,us-west-1,us-west-2",
"ami_users": "",
"ansible_common_vars": "",
"ansible_extra_vars": "",
"ansible_user_vars": "",
"aws_access_key": "",
"aws_profile": "",
"aws_region": "us-east-1",
"aws_secret_key": "",
"aws_security_group_ids": "",
"aws_session_token": "",
"build_name": null,
"build_timestamp": "{{timestamp}}",
"builder_instance_type": "t3.large",
"cloudbase_init_url": "https://github.com/cloudbase/cloudbase-init/releases/download/{{user `cloudbase_init_version`}}/CloudbaseInitSetup_{{user `cloudbase_init_version` | replace_all `.` `_` }}_x64.msi",
"cloudbase_metadata_services": "cloudbaseinit.metadata.services.ec2service.EC2Service",
"cloudbase_metadata_services_unattend": "cloudbaseinit.metadata.services.base.EmptyMetadataService",
"cloudbase_plugins": "cloudbaseinit.plugins.windows.createuser.CreateUserPlugin, cloudbaseinit.plugins.common.setuserpassword.SetUserPasswordPlugin, cloudbaseinit.plugins.windows.extendvolumes.ExtendVolumesPlugin, cloudbaseinit.plugins.common.ephemeraldisk.EphemeralDiskPlugin, cloudbaseinit.plugins.common.mtu.MTUPlugin, cloudbaseinit.plugins.common.sethostname.SetHostNamePlugin, cloudbaseinit.plugins.common.sshpublickeys.SetUserSSHPublicKeysPlugin",
"cloudbase_plugins_unattend": "cloudbaseinit.plugins.common.mtu.MTUPlugin",
"containerd_sha256": null,
"containerd_url": "",
"containerd_version": null,
"encrypted": "false",
"iam_instance_profile": "",
"ib_version": "{{env `IB_VERSION`}}",
"kms_key_id": "",
"kubernetes_base_url": "https://kubernetesreleases.blob.core.windows.net/kubernetes/{{user `kubernetes_semver`}}/binaries/node/windows/{{user `kubernetes_goarch`}}",
"manifest_output": "manifest.json",
"nssm_url": null,
"prepull": null,
"skip_create_ami": "false",
"skip_profile_validation": "false",
"snapshot_groups": "all",
"snapshot_users": "",
"ssh_keypair_name": "",
"ssh_private_key_file": "",
"subnet_id": "",
"temporary_security_group_source_cidrs": "",
"throughput": "125",
"volume_size": "40",
"volume_type": "gp3",
"vpc_id": "",
"windows_service_manager": null,
"windows_updates_kbs": null,
"wins_url": "https://github.com/rancher/wins/releases/download/v{{user `wins_version`}}/wins.exe"
}
}

210
packer/ami/packer.json Normal file
View File

@ -0,0 +1,210 @@
{
"builders": [
{
"access_key": "{{user `aws_access_key`}}",
"ami_description": "{{user `ami_description`}}",
"ami_groups": "{{user `ami_groups`}}",
"ami_name": "capa-ami-{{user `build_name`}}-{{user `kubernetes_semver` | clean_resource_name}}-{{user `build_timestamp`}}",
"ami_product_codes": "",
"ami_regions": "{{user `ami_regions`}}",
"ami_users": "{{user `ami_users`}}",
"encrypt_boot": "{{user `encrypted`}}",
"iam_instance_profile": "{{user `iam_instance_profile`}}",
"instance_type": "{{user `builder_instance_type`}}",
"kms_key_id": "{{user `kms_key_id`}}",
"launch_block_device_mappings": [
{
"delete_on_termination": true,
"device_name": "{{ user `root_device_name` }}",
"iops": "{{ user `iops`}}",
"throughput": "{{ user `throughput` }}",
"volume_size": "{{ user `volume_size` }}",
"volume_type": "{{ user `volume_type` }}"
}
],
"name": "{{user `build_name`}}",
"profile": "{{ user `aws_profile`}}",
"region": "{{ user `aws_region` }}",
"secret_key": "{{user `aws_secret_key`}}",
"security_group_ids": "{{user `aws_security_group_ids`}}",
"skip_create_ami": "{{ user `skip_create_ami`}}",
"skip_profile_validation": "{{user `skip_profile_validation`}}",
"snapshot_groups": "{{user `snapshot_groups`}}",
"snapshot_users": "{{user `snapshot_users`}}",
"source_ami": "{{user `source_ami`}}",
"source_ami_filter": {
"filters": {
"architecture": "x86_64",
"name": "{{user `ami_filter_name`}}",
"root-device-type": "ebs",
"virtualization-type": "hvm"
},
"most_recent": true,
"owners": "{{user `ami_filter_owners`}}"
},
"ssh_keypair_name": "{{user `ssh_keypair_name`}}",
"ssh_private_key_file": "{{user `ssh_private_key_file`}}",
"ssh_username": "{{user `ssh_username`}}",
"subnet_id": "{{ user `subnet_id` }}",
"tags": {
"build_date": "{{isotime}}",
"build_timestamp": "{{user `build_timestamp`}}",
"containerd_version": "{{user `containerd_version`}}",
"distribution": "{{user `distribution`}}",
"distribution_release": "{{user `distribution_release`}}",
"distribution_version": "{{user `distribution_version`}}",
"image_builder_version": "{{user `ib_version`}}",
"kubernetes_cni_version": "{{user `kubernetes_cni_semver`}}",
"kubernetes_version": "{{user `kubernetes_semver`}}",
"source_ami": "{{user `source_ami`}}"
},
"temporary_security_group_source_cidrs": "{{ user `temporary_security_group_source_cidrs` }}",
"token": "{{ user `aws_session_token` }}",
"type": "amazon-ebs",
"user_data": "{{ user `user_data` }}",
"vpc_id": "{{ user `vpc_id` }}"
}
],
"post-processors": [
{
"custom_data": {
"containerd_version": "{{user `containerd_version`}}",
"kubernetes_cni_version": "{{user `kubernetes_cni_semver`}}",
"kubernetes_version": "{{user `kubernetes_semver`}}"
},
"output": "{{user `manifest_output`}}",
"type": "manifest"
}
],
"provisioners": [
{
"environment_vars": [
"BUILD_NAME={{user `build_name`}}"
],
"inline": [
"if [ $BUILD_NAME != \"ubuntu-1804\" ]; then exit 0; fi",
"while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done",
"sudo apt-get -qq update && sudo DEBIAN_FRONTEND=noninteractive apt-get -qqy install python python-pip"
],
"type": "shell"
},
{
"execute_command": "BUILD_NAME={{user `build_name`}}; if [[ \"${BUILD_NAME}\" == *\"flatcar\"* ]]; then sudo {{.Vars}} -S -E bash '{{.Path}}'; fi",
"script": "./packer/files/flatcar/scripts/bootstrap-flatcar.sh",
"type": "shell"
},
{
"ansible_env_vars": [
"ANSIBLE_SSH_ARGS='{{user `existing_ansible_ssh_args`}} {{user `ansible_common_ssh_args`}}'"
],
"extra_arguments": [
"--extra-vars",
"{{user `ansible_common_vars`}}",
"--extra-vars",
"{{user `ansible_extra_vars`}}",
"--extra-vars",
"{{user `ansible_user_vars`}}",
"--scp-extra-args",
"{{user `ansible_scp_extra_args`}}"
],
"playbook_file": "./ansible/node.yml",
"type": "ansible"
},
{
"arch": "{{user `goss_arch`}}",
"download_path": "{{user `goss_download_path`}}",
"format": "{{user `goss_format`}}",
"format_options": "{{user `goss_format_options`}}",
"goss_file": "{{user `goss_entry_file`}}",
"inspect": "{{user `goss_inspect_mode`}}",
"remote_folder": "{{user `goss_remote_folder`}}",
"remote_path": "{{user `goss_remote_path`}}",
"skip_install": "{{user `goss_skip_install`}}",
"tests": [
"{{user `goss_tests_dir`}}"
],
"type": "goss",
"url": "{{user `goss_url`}}",
"use_sudo": true,
"vars_file": "{{user `goss_vars_file`}}",
"vars_inline": {
"ARCH": "amd64",
"OS": "{{user `distribution` | lower}}",
"OS_VERSION": "{{user `distribution_version` | lower}}",
"PROVIDER": "amazon",
"containerd_version": "{{user `containerd_version`}}",
"kubernetes_cni_deb_version": "{{ user `kubernetes_cni_deb_version` }}",
"kubernetes_cni_rpm_version": "{{ split (user `kubernetes_cni_rpm_version`) \"-\" 0 }}",
"kubernetes_cni_source_type": "{{user `kubernetes_cni_source_type`}}",
"kubernetes_cni_version": "{{user `kubernetes_cni_semver` | replace \"v\" \"\" 1}}",
"kubernetes_deb_version": "{{ user `kubernetes_deb_version` }}",
"kubernetes_rpm_version": "{{ split (user `kubernetes_rpm_version`) \"-\" 0 }}",
"kubernetes_source_type": "{{user `kubernetes_source_type`}}",
"kubernetes_version": "{{user `kubernetes_semver` | replace \"v\" \"\" 1}}"
},
"version": "{{user `goss_version`}}"
}
],
"variables": {
"amazon_ssm_agent_rpm": "https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm",
"ami_description": "Cluster API base image designed for {{user `kubernetes_semver`}}",
"ami_groups": "all",
"ami_regions": "ap-south-1,eu-west-3,eu-west-2,eu-west-1,ap-northeast-2,ap-northeast-1,sa-east-1,ca-central-1,ap-southeast-1,ap-southeast-2,eu-central-1,us-east-1,us-east-2,us-west-1,us-west-2",
"ami_users": "",
"ansible_common_vars": "",
"ansible_extra_vars": "",
"ansible_scp_extra_args": "",
"ansible_user_vars": "",
"aws_access_key": "",
"aws_profile": "",
"aws_region": "us-east-1",
"aws_secret_key": "",
"aws_security_group_ids": "",
"aws_session_token": "",
"build_timestamp": "{{timestamp}}",
"builder_instance_type": "t3.small",
"containerd_sha256": null,
"containerd_url": "https://github.com/containerd/containerd/releases/download/v{{user `containerd_version`}}/cri-containerd-cni-{{user `containerd_version`}}-linux-amd64.tar.gz",
"containerd_version": null,
"crictl_url": "https://github.com/kubernetes-sigs/cri-tools/releases/download/v{{user `crictl_version`}}/crictl-v{{user `crictl_version`}}-linux-amd64.tar.gz",
"crictl_version": null,
"encrypted": "false",
"existing_ansible_ssh_args": "{{env `ANSIBLE_SSH_ARGS`}}",
"iam_instance_profile": "",
"ib_version": "{{env `IB_VERSION`}}",
"iops": "3000",
"kms_key_id": "",
"kubernetes_cni_deb_version": null,
"kubernetes_cni_http_source": null,
"kubernetes_cni_rpm_version": null,
"kubernetes_cni_semver": null,
"kubernetes_cni_source_type": null,
"kubernetes_container_registry": null,
"kubernetes_deb_gpg_key": null,
"kubernetes_deb_repo": null,
"kubernetes_deb_version": null,
"kubernetes_http_source": null,
"kubernetes_load_additional_imgs": null,
"kubernetes_rpm_gpg_check": null,
"kubernetes_rpm_gpg_key": null,
"kubernetes_rpm_repo": null,
"kubernetes_rpm_version": null,
"kubernetes_semver": null,
"kubernetes_source_type": null,
"manifest_output": "manifest.json",
"python_path": "",
"skip_create_ami": "false",
"skip_profile_validation": "false",
"snapshot_groups": "all",
"snapshot_users": "",
"ssh_keypair_name": "",
"ssh_private_key_file": "",
"subnet_id": "",
"temporary_security_group_source_cidrs": "",
"throughput": "125",
"user_data": "#cloud-config\nrepo_upgrade: none",
"volume_size": "8",
"volume_type": "gp3",
"vpc_id": ""
}
}

15
packer/ami/rhel-8.json Normal file
View File

@ -0,0 +1,15 @@
{
"ami_filter_name": "RHEL-8.6.0_HVM-*",
"ami_filter_owners": "309956199498",
"build_name": "rhel-8",
"builder_instance_type": "m5.large",
"distribution": "rhel",
"distribution_release": "Enterprise",
"distribution_version": "8",
"epel_rpm_gpg_key": "https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8",
"redhat_epel_rpm": "https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm",
"root_device_name": "/dev/sda1",
"source_ami": "",
"ssh_username": "ec2-user",
"volume_size": "10"
}

View File

@ -0,0 +1,14 @@
{
"ami_filter_name": "Rocky-8-ec2-8.5-*",
"ami_filter_owners": "679593333241",
"build_name": "rockylinux-8",
"distribution": "rockylinux",
"distribution_release": "Core",
"distribution_version": "8",
"epel_rpm_gpg_key": "https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8",
"redhat_epel_rpm": "https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm",
"root_device_name": "/dev/sda1",
"source_ami": "",
"ssh_username": "rocky",
"volume_size": "10"
}

View File

@ -0,0 +1,29 @@
# Copyright 2020 The Kubernetes Authors.
# 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.
Write-Output 'Removing default unattend.xml file...'
if( Test-Path $Env:SystemRoot\system32\Sysprep\unattend.xml ) {
Remove-Item $Env:SystemRoot\system32\Sysprep\unattend.xml -Force
}
# Schedule InitializeInstance to run on next boot
& $Env:ProgramData\Amazon\EC2-Windows\Launch\Scripts\InitializeInstance.ps1 -Schedule
$unattendedXml = "$ENV:ProgramFiles\Cloudbase Solutions\Cloudbase-Init\conf\Unattend.xml"
$FileExists = Test-Path $unattendedXml
If ($FileExists -eq $True) {
# Use the Cloudbase-init provided unattend file during install
Write-Output "Using cloudbase-init unattend file for sysprep: $unattendedXml"
Copy-Item -Force 'C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf\Unattend.xml' $Env:ProgramData\Amazon\EC2-Windows\Launch\Sysprep\Unattend.xml
}

View File

@ -0,0 +1,47 @@
<powershell>
# MAKE SURE IN YOUR PACKER CONFIG TO SET:
#
#
# "winrm_username": "Administrator",
# "winrm_insecure": true,
# "winrm_use_ssl": true,
#
#
write-output "Running User Data Script"
write-host "(host) Running User Data Script"
Set-ExecutionPolicy Unrestricted -Scope LocalMachine -Force -ErrorAction Ignore
# Don't set this before Set-ExecutionPolicy as it throws an error
$ErrorActionPreference = "stop"
# Remove HTTP listener
Remove-Item -Path WSMan:\Localhost\listener\listener* -Recurse
# Create a self-signed certificate to let ssl work
$Cert = New-SelfSignedCertificate -CertstoreLocation Cert:\LocalMachine\My -DnsName "packer"
New-Item -Path WSMan:\LocalHost\Listener -Transport HTTPS -Address * -CertificateThumbPrint $Cert.Thumbprint -Force
# WinRM
write-output "Setting up WinRM"
write-host "(host) setting up WinRM"
cmd.exe /c winrm quickconfig -q
cmd.exe /c winrm set "winrm/config" '@{MaxTimeoutms="1800000"}'
cmd.exe /c winrm set "winrm/config/winrs" '@{MaxMemoryPerShellMB="1024"}'
cmd.exe /c winrm set "winrm/config/service" '@{AllowUnencrypted="true"}'
cmd.exe /c winrm set "winrm/config/client" '@{AllowUnencrypted="true"}'
cmd.exe /c winrm set "winrm/config/service/auth" '@{Basic="true"}'
cmd.exe /c winrm set "winrm/config/client/auth" '@{Basic="true"}'
cmd.exe /c winrm set "winrm/config/service/auth" '@{CredSSP="true"}'
cmd.exe /c winrm set "winrm/config/listener?Address=*+Transport=HTTPS" "@{Port=`"5986`";Hostname=`"packer`";CertificateThumbprint=`"$($Cert.Thumbprint)`"}"
cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes
cmd.exe /c netsh firewall add portopening TCP 5986 "Port 5986"
cmd.exe /c net stop winrm
cmd.exe /c sc config winrm start= auto
cmd.exe /c net start winrm
</powershell>

View File

@ -0,0 +1,11 @@
{
"ami_filter_name": "ubuntu/images/*ubuntu-bionic-18.04-amd64-server-*",
"ami_filter_owners": "099720109477",
"build_name": "ubuntu-18.04",
"distribution": "Ubuntu",
"distribution_release": "bionic",
"distribution_version": "18.04",
"root_device_name": "/dev/sda1",
"source_ami": "",
"ssh_username": "ubuntu"
}

View File

@ -0,0 +1,11 @@
{
"ami_filter_name": "ubuntu/images/*ubuntu-focal-20.04-amd64-server-*",
"ami_filter_owners": "099720109477",
"build_name": "ubuntu-20.04",
"distribution": "Ubuntu",
"distribution_release": "focal",
"distribution_version": "20.04",
"root_device_name": "/dev/sda1",
"source_ami": "",
"ssh_username": "ubuntu"
}

View File

@ -0,0 +1,11 @@
{
"ami_filter_name": "ubuntu/images/*ubuntu-jammy-22.04-amd64-server-*",
"ami_filter_owners": "099720109477",
"build_name": "ubuntu-22.04",
"distribution": "Ubuntu",
"distribution_release": "jammy",
"distribution_version": "22.04",
"root_device_name": "/dev/sda1",
"source_ami": "",
"ssh_username": "ubuntu"
}

View File

@ -0,0 +1,10 @@
{
"ami_filter_name": "Windows_Server-2004-English-Core-ContainersLatest-*",
"ami_filter_owners": "amazon",
"build_name": "windows-2004",
"distribution": "windows",
"distribution_version": "2004",
"root_device_name": "/dev/sda1",
"source_ami": "",
"windows_updates_kbs": "KB4588962 KB2267602"
}

View File

@ -0,0 +1,10 @@
{
"ami_filter_name": "Windows_Server-2019-English-Full-HyperV-*",
"ami_filter_owners": "amazon",
"build_name": "windows-2019",
"distribution": "windows",
"distribution_version": "2019",
"root_device_name": "/dev/sda1",
"source_ami": "",
"windows_updates_kbs": "KB4588962 KB2267602"
}

View File

@ -0,0 +1,50 @@
# Required pipeline variables:
# - BUILD_POOL - Azure DevOps build pool to use
# - CONTAINER_IMAGE - Dev container image URL to use. Should have Azure CLI, Packer and Ansible.
# - AZURE_TENANT_ID - tenant ID
# - AZURE_CLIENT_ID - Service principal ID
# - AZURE_CLIENT_SECRET - Service principal secret
# - AZURE_SUBSCRIPTION_ID - Subscription ID used by the pipeline
# - KUBERNETES_VERSION - version of Kubernetes to build the image with, e.g. `1.16.2`
# - OS - target of build e.g. `Ubuntu/Windows`
# - OS_VERSION - target of build e.g. `18.04/2004/2019`
jobs:
- job: build_vhd
container: $[ variables['CONTAINER_IMAGE'] ]
timeoutInMinutes: 120
strategy:
maxParallel: 0
pool:
name: $(BUILD_POOL)
steps:
- template: k8s-config.yaml
- script: |
set -o pipefail
make deps-azure
os=$(echo "${OS}" | tr '[:upper:]' '[:lower:]')
version=$(echo "${OS_VERSION}" | tr '[:upper:]' '[:lower:]' | tr -d .)
export RESOURCE_GROUP_NAME="cluster-api-images"
# timestamp is in RFC-3339 format to match kubetest
export TIMESTAMP="$(date -u '+%Y-%m-%dT%H:%M:%SZ')"
export JOB_NAME="${JOB_NAME:-"image-builder-vhd"}"
export TAGS="creationTimestamp=${TIMESTAMP} jobName=${JOB_NAME}"
printf "${TAGS}" | tee packer/azure/tags.out
make build-azure-vhd-$os-$version | tee packer/azure/packer.out
displayName: Building VHD
workingDirectory: '$(system.defaultWorkingDirectory)/images/capi'
env:
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
- template: generate-sas.yaml
- template: vhd-publishing-info.yaml
- task: PublishPipelineArtifact@1
inputs:
artifact: 'publishing-info'
path: '$(system.defaultWorkingDirectory)/images/capi/packer/azure/vhd-publishing-info.json'
condition: eq(variables.CLEANUP, 'False')
- template: delete-storage-account.yaml
- script: |
chown -R $USER:$USER .
displayName: cleanup - chown all files in work directory
condition: always()

View File

@ -0,0 +1,38 @@
# Required pipeline variables:
# - BUILD_POOL - Azure DevOps build pool to use
# - CONTAINER_IMAGE - Dev container image URL to use. Should have Azure CLI, Packer and Ansible.
# - AZURE_TENANT_ID - tenant ID
# - AZURE_CLIENT_ID - Service principal ID
# - AZURE_CLIENT_SECRET - Service principal secret
# - OS - target of build e.g. `Ubuntu/Windows`
# - OS_VERSION - target of build e.g. `18.04/2004/2019`
jobs:
- job: create_disk_version
container: $[ variables['CONTAINER_IMAGE'] ]
timeoutInMinutes: 120
strategy:
maxParallel: 0
pool:
name: $(BUILD_POOL)
steps:
- task: DownloadPipelineArtifact@2
inputs:
source: current
artifact: publishing-info
path: $(system.defaultWorkingDirectory)/images/capi/packer/azure/vhd/
- task: DownloadPipelineArtifact@2
inputs:
source: current
artifact: sku-info
path: $(system.defaultWorkingDirectory)/images/capi/packer/azure/sku/
- script: |
./scripts/new-disk-version.sh
displayName: Create a new marketplace SKU
workingDirectory: '$(system.defaultWorkingDirectory)/images/capi/packer/azure'
env:
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
- task: PublishPipelineArtifact@1
inputs:
artifact: 'version_info'
path: '$(system.defaultWorkingDirectory)/images/capi/packer/azure/version.json'

View File

@ -0,0 +1,34 @@
# Required pipeline variables:
# - BUILD_POOL - Azure DevOps build pool to use
# - CONTAINER_IMAGE - Dev container image URL to use. Should have Azure CLI, Packer and Ansible.
# - AZURE_CLIENT_ID - Service principal ID
# - AZURE_CLIENT_SECRET - Service principal secret
# - AZURE_TENANT_ID - tenant ID
# - KUBERNETES_VERSION - version of Kubernetes to create the sku for, e.g. `1.16.2`
# - OFFER - the name of the offer to create the sku for
# - OS - target of build e.g. `Ubuntu/Windows`
# - OS_VERSION - target of build e.g. `18.04/2004/2019/2022-containerd`
# - PUBLISHER - the name of the publisher to create the sku for
# - SKU_TEMPLATE_FILE - the base template file to use for the sku
# - VM_GENERATION - VM generation to use, e.g. `gen2`
jobs:
- job: create_sku
container: $[ variables['CONTAINER_IMAGE'] ]
timeoutInMinutes: 120
strategy:
maxParallel: 0
pool:
name: $(BUILD_POOL)
steps:
- script: |
./scripts/new-sku.sh
displayName: Create a new marketplace SKU
workingDirectory: '$(system.defaultWorkingDirectory)/images/capi/packer/azure'
env:
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
- task: PublishPipelineArtifact@1
inputs:
artifact: 'sku-info'
path: '$(system.defaultWorkingDirectory)/images/capi/packer/azure/sku-publishing-info.json'

View File

@ -0,0 +1,13 @@
steps:
- script: |
set -o pipefail
RESOURCE_GROUP_NAME=$(jq -r '.builds[-1].custom_data.resource_group_name' manifest.json | cut -d ":" -f2)
STORAGE_ACCOUNT_NAME=$(jq -r '.builds[-1].custom_data.storage_account_name' manifest.json | cut -d ":" -f2)
az login --service-principal -u ${AZURE_CLIENT_ID} -p ${AZURE_CLIENT_SECRET} --tenant ${AZURE_TENANT_ID}
az account set -s ${AZURE_SUBSCRIPTION_ID}
az storage account delete -n ${STORAGE_ACCOUNT_NAME} -g ${RESOURCE_GROUP_NAME} --yes
displayName: cleanup - delete storage account
workingDirectory: '$(system.defaultWorkingDirectory)/images/capi'
condition: eq(variables.CLEANUP, 'True')
env:
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)

View File

@ -0,0 +1,21 @@
steps:
- script: |
set -o pipefail
RESOURCE_GROUP_NAME=$(jq -r '.builds[-1].custom_data.resource_group_name' manifest.json | cut -d ":" -f2)
STORAGE_ACCOUNT_NAME=$(jq -r '.builds[-1].custom_data.storage_account_name' manifest.json | cut -d ":" -f2)
OS_DISK_URI=$(cat packer/azure/packer.out | grep "OSDiskUri:" -m 1 | cut -d " " -f 2)
printf "${STORAGE_ACCOUNT_NAME}" | tee packer/azure/storage-account-name.out
printf "${OS_DISK_URI}" | tee packer/azure/vhd-base-url.out
printf "${OS_DISK_URI}?" | tee packer/azure/vhd-url.out
printf "${RESOURCE_GROUP_NAME}" | tee packer/azure/resource-group-name.out
az login --service-principal -u ${AZURE_CLIENT_ID} -p ${AZURE_CLIENT_SECRET} --tenant ${AZURE_TENANT_ID}
az account set -s ${AZURE_SUBSCRIPTION_ID}
ACCOUNT_KEY=$(az storage account keys list -g ${RESOURCE_GROUP_NAME} --subscription ${AZURE_SUBSCRIPTION_ID} --account-name ${STORAGE_ACCOUNT_NAME} --query '[0].value')
start_date=$(date +"%Y-%m-%dT00:00Z" -d "-1 day")
expiry_date=$(date +"%Y-%m-%dT00:00Z" -d "+1 year")
az storage container generate-sas --name system --permissions lr --account-name ${STORAGE_ACCOUNT_NAME} --account-key ${ACCOUNT_KEY} --start $start_date --expiry $expiry_date | tr -d '\"' | tee -a packer/azure/vhd-url.out
displayName: Getting OS VHD URL
workingDirectory: '$(system.defaultWorkingDirectory)/images/capi'
condition: eq(variables.CLEANUP, 'False')
env:
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)

View File

@ -0,0 +1,15 @@
steps:
- script: |
KUBERNETES_RELEASE=$(echo ${KUBERNETES_VERSION} | cut -d "." -f -2)
sed -i "s/.*kubernetes_series.*/ \"kubernetes_series\": \"v${KUBERNETES_RELEASE}\",/g" kubernetes.json
sed -i "s/.*kubernetes_semver.*/ \"kubernetes_semver\": \"v${KUBERNETES_VERSION}\",/g" kubernetes.json
if [[ "${KUBERNETES_VERSION:-}" == "1.16.11" || "${KUBERNETES_VERSION:-}" == "1.17.7" || "${KUBERNETES_VERSION:-}" == "1.18.4" ]]; then
sed -i "s/.*kubernetes_rpm_version.*/ \"kubernetes_rpm_version\": \"${KUBERNETES_VERSION}-1\",/g" kubernetes.json
sed -i "s/.*kubernetes_deb_version.*/ \"kubernetes_deb_version\": \"${KUBERNETES_VERSION}-01\",/g" kubernetes.json
else
sed -i "s/.*kubernetes_rpm_version.*/ \"kubernetes_rpm_version\": \"${KUBERNETES_VERSION}-0\",/g" kubernetes.json
sed -i "s/.*kubernetes_deb_version.*/ \"kubernetes_deb_version\": \"${KUBERNETES_VERSION}-00\",/g" kubernetes.json
fi
cat kubernetes.json
displayName: Write configuration files
workingDirectory: '$(system.defaultWorkingDirectory)/images/capi/packer/config'

View File

@ -0,0 +1,59 @@
# Required pipeline variables:
# - BUILD_POOL - Azure DevOps build pool to use
# - CONTAINER_IMAGE - Dev container image URL to use. Should have Azure CLI, Packer and Ansible.
# - AZURE_TENANT_ID_VHD - tenant ID to build the vhd
# - AZURE_CLIENT_ID_VHD - Service principal ID to build the vhd
# - AZURE_CLIENT_SECRET_VHD - Service principal secret to build the vhd
# - AZURE_SUBSCRIPTION_ID_VHD - Subscription ID to build the vhd
# - KUBERNETES_VERSION - version of Kubernetes to create the sku for, e.g. `1.21.3`
# - CLEANUP - whether or not to clean up resources created in the run
trigger: none
schedules:
- cron: "0 1 * * *"
displayName: "nightly build"
always: true
branches:
include:
- master
stages:
- stage: vhd
jobs:
- job:
container: $[ variables['CONTAINER_IMAGE'] ]
timeoutInMinutes: 120
pool:
name: $(BUILD_POOL)
steps:
- template: k8s-config.yaml
- script: |
set -o pipefail
make deps-azure
os=$(echo "$OS" | tr '[:upper:]' '[:lower:]')
version=$(echo "$OS_VERSION" | tr '[:upper:]' '[:lower:]' | tr -d .)
make build-azure-vhd-$os-$version | tee packer/azure/packer.out
displayName: Building VHD
workingDirectory: '$(system.defaultWorkingDirectory)/images/capi'
env:
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
- template: delete-storage-account.yaml
- script: |
chown -R $USER:$USER .
displayName: cleanup - chown all files in work directory
condition: always()
strategy:
maxParallel: 0
matrix:
Windows:
OS: Windows
OS_VERSION: 2019
Linux:
OS: Ubuntu
OS_VERSION: 2004
variables:
AZURE_TENANT_ID: $(AZURE_TENANT_ID_VHD)
AZURE_CLIENT_ID: $(AZURE_CLIENT_ID_VHD)
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET_VHD)
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID_VHD)

View File

@ -0,0 +1,57 @@
# Required pipeline variables:
# - BUILD_POOL - Azure DevOps build pool to use
# - CONTAINER_IMAGE - Dev container image URL to use. Should have Azure CLI, Packer and Ansible.
# - AZURE_TENANT_ID_VHD - tenant ID to build the vhd
# - AZURE_CLIENT_ID_VHD - Service principal ID to build the vhd
# - AZURE_CLIENT_SECRET_VHD - Service principal secret to build the vhd
# - AZURE_SUBSCRIPTION_ID_VHD - Subscription ID to build the vhd
# - AZURE_TENANT_ID_SKU - tenant ID to PUT the SKU
# - AZURE_CLIENT_ID_SKU - Service principal ID to PUT the SKU
# - AZURE_CLIENT_SECRET_SKU - Service principal secret to PUT the SKU
# - KUBERNETES_VERSION - version of Kubernetes to create the sku for, e.g. `1.16.2`
# - PUBLISHER - the name of the publisher to create the sku for
# - OFFER - the name of the offer to create the sku for
# - SKU_TEMPLATE_FILE - the base template file to use for the sku
# - OS - target of build e.g. `Ubuntu/Windows`
# - OS_VERSION - target of build e.g. `18.04/2004/2019`
trigger: none
pr: none
stages:
- stage: vhd
jobs:
- template: build-vhd.yaml
variables:
AZURE_TENANT_ID: $(AZURE_TENANT_ID_VHD)
AZURE_CLIENT_ID: $(AZURE_CLIENT_ID_VHD)
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET_VHD)
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID_VHD)
- stage: test
condition: and(succeeded(), eq(variables.CLEANUP, 'False'))
jobs:
- template: test-vhd.yaml
variables:
AZURE_TENANT_ID: $(AZURE_TENANT_ID_VHD)
AZURE_CLIENT_ID: $(AZURE_CLIENT_ID_VHD)
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET_VHD)
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID_VHD)
- stage: sku
condition: and(succeeded(), eq(variables.CLEANUP, 'False'))
jobs:
- template: create-sku.yaml
variables:
AZURE_TENANT_ID: $(AZURE_TENANT_ID_SKU)
AZURE_CLIENT_ID: $(AZURE_CLIENT_ID_SKU)
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET_SKU)
- stage: disk_version
condition: and(succeeded(), eq(variables.CLEANUP, 'False'))
jobs:
- template: create-disk-version.yaml
variables:
AZURE_TENANT_ID: $(AZURE_TENANT_ID_SKU)
AZURE_CLIENT_ID: $(AZURE_CLIENT_ID_SKU)
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET_SKU)

View File

@ -0,0 +1,143 @@
# Required pipeline variables:
# - BUILD_POOL - Azure DevOps build pool to use
# - CONTAINER_IMAGE - Dev container image URL to use. Should have Azure CLI, Packer, and Ansible.
# - AZ_CAPI_EXTENSION_URL - URL to the Azure CAPI extension build.
# - AZURE_TENANT_ID - tenant ID
# - AZURE_CLIENT_ID - Service principal ID
# - AZURE_CLIENT_SECRET - Service principal secret
# - AZURE_SUBSCRIPTION_ID - Subscription ID used by the pipeline
# - KUBERNETES_VERSION - version of Kubernetes to build the image with, e.g. `1.16.2`
# - OS - target of build e.g. `Ubuntu/Windows`
# - OS_VERSION - target of build e.g. `18.04/2004/2019`
jobs:
- job: test_vhd
container: $[ variables['CONTAINER_IMAGE'] ]
timeoutInMinutes: 120
strategy:
maxParallel: 0
pool:
name: $(BUILD_POOL)
steps:
- task: DownloadPipelineArtifact@2
inputs:
source: current
artifact: publishing-info
path: $(system.defaultWorkingDirectory)/images/capi/packer/azure/vhd/
- script: |
set -x
set -e -o pipefail
VHD_RESOURCE_ID=$(jq -r .vhd_base_url $(system.defaultWorkingDirectory)/images/capi/packer/azure/vhd/vhd-publishing-info.json)
STORAGE_ACCOUNT_NAME=$(jq -r .storage_account_name $(system.defaultWorkingDirectory)/images/capi/packer/azure/vhd/vhd-publishing-info.json)
TAGS=$(jq -r .tags $(system.defaultWorkingDirectory)/images/capi/packer/azure/vhd/vhd-publishing-info.json)
echo "##vso[task.setvariable variable=VHD_RESOURCE_ID]$VHD_RESOURCE_ID"
echo "##vso[task.setvariable variable=STORAGE_ACCOUNT_NAME]$STORAGE_ACCOUNT_NAME"
echo "##vso[task.setvariable variable=TAGS;]$TAGS"
displayName: Import variables from build vhd job
env:
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
- script: |
set -x
set -e -o pipefail
RANDOM=$(bash -c 'echo $RANDOM')
RESOURCE_GROUP="capi-testvmimage-${RANDOM}"
echo "${RESOURCE_GROUP}" is the group
# Azure CLI login
az login -u $AZURE_CLIENT_ID -p $AZURE_CLIENT_SECRET --service-principal --tenant $AZURE_TENANT_ID
# Find the VHD blob location from its storage account
AZURE_LOCATION=$(az storage account show --name "${STORAGE_ACCOUNT_NAME}" --query '[location]' -o tsv)
# Create the resource group
az group create --name "${RESOURCE_GROUP}" --location "${AZURE_LOCATION}" --tags "${TAGS}"
# Create a managed image from the VHD blob
OS_TYPE="Linux"
if [ "$OS" == "Windows" ]; then
OS_TYPE="Windows"
fi
az image create -n testvmimage -g "${RESOURCE_GROUP}" --os-type "${OS_TYPE}" --source "${VHD_RESOURCE_ID}"
# Pass the managed image resource ID on to the next step
IMAGE_ID=$(az image show -g "${RESOURCE_GROUP}" -n testvmimage --query '[id]' --output tsv)
echo "##vso[task.setvariable variable=RESOURCE_GROUP;]$RESOURCE_GROUP"
echo "##vso[task.setvariable variable=MANAGED_IMAGE_ID;]$IMAGE_ID"
echo "##vso[task.setvariable variable=AZURE_LOCATION;]$AZURE_LOCATION"
displayName: promote VHD blob to managed image
env:
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
- template: k8s-config.yaml
- script: |
set -x
set -e -o pipefail
export PATH=${PATH}:.local/bin
./packer/azure/scripts/ensure-kustomize.sh
# Generate cluster template with kustomize
if [ "$OS" == "Windows" ]; then
kustomize build --load-restrictor LoadRestrictionsNone $(system.defaultWorkingDirectory)/images/capi/packer/azure/scripts/test-templates/windows/ > $(system.defaultWorkingDirectory)/images/capi/packer/azure/scripts/test-templates/cluster-template.yaml
else
kustomize build --load-restrictor LoadRestrictionsNone $(system.defaultWorkingDirectory)/images/capi/packer/azure/scripts/test-templates/linux/ > $(system.defaultWorkingDirectory)/images/capi/packer/azure/scripts/test-templates/cluster-template.yaml
fi
TEST_TEMPLATE=$(system.defaultWorkingDirectory)/images/capi/packer/azure/scripts/test-templates/cluster-template.yaml
echo "##vso[task.setvariable variable=TEST_TEMPLATE;]$TEST_TEMPLATE"
displayName: generate cluster template
workingDirectory: '$(system.defaultWorkingDirectory)/images/capi'
env:
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
- script: |
set -x
set -e -o pipefail
os=$(echo "$OS" | tr '[:upper:]' '[:lower:]')
# Set up the Azure CLI Cluster API extension
# https://github.com/Azure/azure-capi-cli-extension/releases/download/az-capi-nightly/capi-0.0.vnext-py2.py3-none-any.whl
az extension add --yes --source "${AZ_CAPI_EXTENSION_URL}"
# Install required binaries
mkdir ~/test-binaries
export PATH=${PATH}:~/test-binaries
az capi install -a -ip ~/test-binaries
echo "##vso[task.setvariable variable=PATH;]$PATH"
displayName: Install and configure az capi extension
env:
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
- script: |
params=()
if [ "$OS" == "Windows" ]; then
params+=(--windows)
fi
# Create a cluster
az capi create \
--yes \
--debug \
--name testvm \
--kubernetes-version="${KUBERNETES_VERSION}" \
--location="${AZURE_LOCATION}" \
--resource-group="${RESOURCE_GROUP}" \
--management-cluster-resource-group-name="${RESOURCE_GROUP}" \
--control-plane-machine-count=1 \
--node-machine-count=1 \
--template="${TEST_TEMPLATE}" \
--tags="${TAGS}" \
--wait-for-nodes=2 \
"${params[@]}"
displayName: Create a cluster
env:
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
- script: |
set -x
set -e -o pipefail
# Clean up the test resource group
az group delete -n "${RESOURCE_GROUP}" --yes --no-wait
displayName: Clean up test resource group
condition: always()

View File

@ -0,0 +1,19 @@
steps:
- script: |
VHD_BASE_URL="$(cat packer/azure/vhd-base-url.out)"
VHD_URL="$(cat packer/azure/vhd-url.out)"
STORAGE_ACCOUNT_NAME="$(cat packer/azure/storage-account-name.out)"
RESOURCE_GROUP_NAME="$(cat packer/azure/resource-group-name.out)"
TAGS="$(cat packer/azure/tags.out)"
cat <<EOF > packer/azure/vhd-publishing-info.json
{
"vhd_base_url": "${VHD_BASE_URL}",
"vhd_url": "${VHD_URL}",
"storage_account_name": "${STORAGE_ACCOUNT_NAME}",
"resource_group_name": "${RESOURCE_GROUP_NAME}",
"tags": "${TAGS}"
}
EOF
displayName: Generating publishing info for VHD
workingDirectory: '$(system.defaultWorkingDirectory)/images/capi'
condition: eq(variables.CLEANUP, 'False')

8
packer/azure/OWNERS Normal file
View File

@ -0,0 +1,8 @@
# See the OWNERS docs at https://go.k8s.io/owners
approvers:
- cluster-api-azure-maintainers
reviewers:
- cluster-api-azure-maintainers
- image-builder-azure-reviewers

View File

@ -0,0 +1,8 @@
{
"azure_location": "{{env `AZURE_LOCATION`}}",
"client_id": "{{env `AZURE_CLIENT_ID`}}",
"client_secret": "{{env `AZURE_CLIENT_SECRET`}}",
"containerd_wasm_shims_runtimes": "spin,slight",
"subscription_id": "{{env `AZURE_SUBSCRIPTION_ID`}}",
"vm_size": "Standard_B2ms"
}

View File

@ -0,0 +1,7 @@
{
"image_name": "capi-{{user `distribution`}}-{{user `distribution_version`}}-gen2",
"replication_regions": "{{env `AZURE_LOCATION`}}",
"resource_group_name": "{{env `RESOURCE_GROUP_NAME`}}",
"shared_image_gallery_name": "{{env `GALLERY_NAME`}}",
"sig_image_version": "0.3.{{user `build_timestamp`}}"
}

View File

@ -0,0 +1,7 @@
{
"image_name": "capi-{{user `distribution`}}-{{user `distribution_version`}}",
"replication_regions": "{{env `AZURE_LOCATION`}}",
"resource_group_name": "{{env `RESOURCE_GROUP_NAME`}}",
"shared_image_gallery_name": "{{env `GALLERY_NAME`}}",
"sig_image_version": "0.3.{{user `build_timestamp`}}"
}

View File

@ -0,0 +1,5 @@
{
"capture_container_name": "cluster-api-vhds",
"resource_group_name": "{{env `RESOURCE_GROUP_NAME`}}",
"storage_account_name": "{{env `STORAGE_ACCOUNT_NAME`}}"
}

View File

@ -0,0 +1,9 @@
{
"build_name": "centos-7-gen2",
"distribution": "centos",
"distribution_release": "centos-7",
"distribution_version": "7",
"image_offer": "CentOS",
"image_publisher": "OpenLogic",
"image_sku": "7_7-gen2"
}

View File

@ -0,0 +1,9 @@
{
"build_name": "centos-7",
"distribution": "centos",
"distribution_release": "centos-7",
"distribution_version": "7",
"image_offer": "CentOS",
"image_publisher": "OpenLogic",
"image_sku": "7.7"
}

View File

@ -0,0 +1,23 @@
{
"ansible_extra_vars": "ansible_python_interpreter=/opt/pypy/bin/pypy",
"build_name": "flatcar-gen2",
"crictl_source_type": "http",
"distribution": "flatcar",
"distribution_release": "{{env `FLATCAR_CHANNEL`}}",
"distribution_version": "{{env `FLATCAR_CHANNEL`}}-{{env `FLATCAR_VERSION`}}",
"image_offer": "flatcar-container-linux-free",
"image_publisher": "kinvolk",
"image_sku": "{{env `FLATCAR_CHANNEL`}}-gen2",
"image_version": "{{env `FLATCAR_VERSION` }}",
"kubernetes_cni_source_type": "http",
"kubernetes_source_type": "http",
"plan_image_offer": "{{user `image_offer`}}",
"plan_image_publisher": "{{user `image_publisher`}}",
"plan_image_sku": "{{user `image_sku`}}",
"python_path": "/opt/pypy/site-packages",
"root_device_name": "/dev/sda",
"ssh_username": "core",
"systemd_prefix": "/etc/systemd",
"sysusr_prefix": "/opt",
"sysusrlocal_prefix": "/opt"
}

23
packer/azure/flatcar.json Normal file
View File

@ -0,0 +1,23 @@
{
"ansible_extra_vars": "ansible_python_interpreter=/opt/pypy/bin/pypy",
"build_name": "flatcar",
"crictl_source_type": "http",
"distribution": "flatcar",
"distribution_release": "{{env `FLATCAR_CHANNEL`}}",
"distribution_version": "{{env `FLATCAR_CHANNEL`}}-{{env `FLATCAR_VERSION`}}",
"image_offer": "flatcar-container-linux-free",
"image_publisher": "kinvolk",
"image_sku": "{{env `FLATCAR_CHANNEL`}}",
"image_version": "{{env `FLATCAR_VERSION` }}",
"kubernetes_cni_source_type": "http",
"kubernetes_source_type": "http",
"plan_image_offer": "{{user `image_offer`}}",
"plan_image_publisher": "{{user `image_publisher`}}",
"plan_image_sku": "{{user `image_sku`}}",
"python_path": "/opt/pypy/site-packages",
"root_device_name": "/dev/sda",
"ssh_username": "core",
"systemd_prefix": "/etc/systemd",
"sysusr_prefix": "/opt",
"sysusrlocal_prefix": "/opt"
}

View File

@ -0,0 +1,244 @@
{
"builders": [
{
"azure_tags": {
"build_date": "{{isotime}}",
"build_timestamp": "{{user `build_timestamp`}}",
"creationTimestamp": "{{isotime \"2006-01-02T15:04:05Z\"}}",
"image_builder_version": "{{user `ib_version`}}",
"kubernetes_version": "{{user `kubernetes_semver`}}",
"os_version": "{{user `image_sku`}}"
},
"capture_container_name": "{{user `capture_container_name`}}",
"capture_name_prefix": "capi-{{user `build_timestamp`}}",
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"communicator": "winrm",
"image_offer": "{{user `image_offer` }}",
"image_publisher": "{{user `image_publisher` }}",
"image_sku": "{{user `image_sku`}}",
"image_version": "{{user `image_version`}}",
"location": "{{user `azure_location`}}",
"name": "vhd-{{user `build_name`}}",
"os_disk_size_gb": "{{user `os_disk_size_gb`}}",
"os_type": "Windows",
"private_virtual_network_with_public_ip": "{{user `private_virtual_network_with_public_ip`}}",
"resource_group_name": "{{user `resource_group_name`}}",
"storage_account": "{{user `storage_account_name`}}",
"subscription_id": "{{user `subscription_id`}}",
"type": "azure-arm",
"virtual_network_name": "{{user `virtual_network_name`}}",
"virtual_network_resource_group_name": "{{user `virtual_network_resource_group_name`}}",
"virtual_network_subnet_name": "{{user `virtual_network_subnet_name`}}",
"vm_size": "{{user `vm_size`}}",
"winrm_insecure": true,
"winrm_timeout": "10m",
"winrm_use_ssl": true,
"winrm_username": "packer"
},
{
"azure_tags": {
"build_date": "{{isotime}}",
"build_timestamp": "{{user `build_timestamp`}}",
"creationTimestamp": "{{isotime \"2006-01-02T15:04:05Z\"}}",
"image_builder_version": "{{user `ib_version`}}",
"kubernetes_version": "{{user `kubernetes_semver`}}",
"os_version": "{{user `image_sku`}}"
},
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"communicator": "winrm",
"image_offer": "{{user `image_offer` }}",
"image_publisher": "{{user `image_publisher` }}",
"image_sku": "{{user `image_sku`}}",
"image_version": "{{user `image_version`}}",
"location": "{{user `azure_location`}}",
"managed_image_name": "{{user `image_name`}}-{{user `runtime`}}-{{user `build_timestamp`}}",
"managed_image_resource_group_name": "{{user `resource_group_name`}}",
"managed_image_storage_account_type": "{{user `storage_account_type`}}",
"name": "sig-{{user `build_name`}}",
"os_disk_size_gb": "{{user `os_disk_size_gb`}}",
"os_type": "Windows",
"private_virtual_network_with_public_ip": "{{user `private_virtual_network_with_public_ip`}}",
"shared_gallery_image_version_exclude_from_latest": "{{ user `exclude_from_latest` }}",
"shared_image_gallery": {
"community_gallery_image_id": "{{ user `community_gallery_image_id` }}",
"direct_shared_gallery_image_id": "{{ user `direct_shared_gallery_image_id` }}",
"gallery_name": "{{user `source_sig_name`}}",
"image_name": "{{user `source_sig_image_name`}}",
"image_version": "{{user `source_sig_image_version`}}",
"resource_group": "{{user `source_sig_resource_group_name`}}",
"subscription": "{{user `source_sig_subscription_id`}}"
},
"shared_image_gallery_destination": {
"gallery_name": "{{user `shared_image_gallery_name`}}",
"image_name": "{{user `image_name`}}-{{user `runtime`}}",
"image_version": "{{user `sig_image_version`}}",
"replication_regions": "{{user `replication_regions`}}",
"resource_group": "{{user `resource_group_name`}}",
"storage_account_type": "{{user `storage_account_type`}}"
},
"subscription_id": "{{user `subscription_id`}}",
"type": "azure-arm",
"virtual_network_name": "{{user `virtual_network_name`}}",
"virtual_network_resource_group_name": "{{user `virtual_network_resource_group_name`}}",
"virtual_network_subnet_name": "{{user `virtual_network_subnet_name`}}",
"vm_size": "{{user `vm_size`}}",
"winrm_insecure": true,
"winrm_timeout": "10m",
"winrm_use_ssl": true,
"winrm_username": "packer"
}
],
"post-processors": [
{
"custom_data": {
"build_date": "{{isotime}}",
"build_name": "{{user `build_name`}}",
"build_timestamp": "{{user `build_timestamp`}}",
"build_type": "node",
"containerd_version": "{{user `containerd_version`}}",
"kubernetes_cni_semver": "{{user `kubernetes_cni_semver`}}",
"kubernetes_semver": "{{user `kubernetes_semver`}}",
"kubernetes_source_type": "{{user `kubernetes_source_type`}}",
"os_name": "{{user `distro_name`}}",
"resource_group_name": "{{user `resource_group_name`}}",
"storage_account_name": "{{user `storage_account_name`}}"
},
"output": "{{user `manifest_output`}}",
"strip_path": true,
"type": "manifest"
}
],
"provisioners": [
{
"elevated_password": "{{.WinRMPassword}}",
"elevated_user": "packer",
"script": "ansible/windows/ansible_winrm.ps1",
"type": "powershell"
},
{
"extra_arguments": [
"-e",
"ansible_winrm_server_cert_validation=ignore ansible_winrm_operation_timeout_sec=120 ansible_winrm_read_timeout_sec=150",
"--extra-vars",
"{{user `ansible_common_vars`}}",
"--extra-vars",
"{{user `azure_extra_vars`}}",
"--extra-vars",
"{{user `ansible_extra_vars`}}",
"--extra-vars",
"{{user `ansible_user_vars`}}",
"--extra-vars",
"gmsa_keyvault_url={{user `gmsa_keyvault_url`}}"
],
"max_retries": 5,
"pause_before": "15s",
"playbook_file": "ansible/windows/node_windows.yml",
"type": "ansible",
"use_proxy": false,
"user": "packer"
},
{
"restart_timeout": "10m",
"type": "windows-restart"
},
{
"arch": "{{user `goss_arch`}}",
"download_path": "{{user `goss_download_path`}}",
"format": "{{user `goss_format`}}",
"format_options": "{{user `goss_format_options`}}",
"goss_file": "{{user `goss_entry_file`}}",
"inspect": "{{user `goss_inspect_mode`}}",
"remote_folder": "{{user `goss_remote_folder`}}",
"remote_path": "{{user `goss_remote_path`}}",
"skip_install": "{{user `goss_skip_install`}}",
"target_os": "Windows",
"tests": [
"{{user `goss_tests_dir`}}"
],
"type": "goss",
"url": "{{user `goss_url`}}",
"use_sudo": false,
"vars_env": {
"GOSS_MAX_CONCURRENT": "1",
"GOSS_USE_ALPHA": "1"
},
"vars_file": "{{user `goss_vars_file`}}",
"vars_inline": {
"OS": "{{user `distribution` | lower}}",
"PROVIDER": "azure",
"containerd_version": "{{user `containerd_version`}}",
"distribution_version": "{{user `distribution_version`}}",
"docker_ee_version": "{{user `docker_ee_version`}}",
"kubernetes_version": "{{user `kubernetes_semver`}}",
"pause_image": "{{user `pause_image`}}",
"runtime": "{{user `runtime`}}",
"ssh_source_url": "{{user `ssh_source_url`}}"
},
"version": "{{user `goss_version`}}"
},
{
"inline": [
"rm -Force -Recurse C:\\var\\log\\kubelet\\*"
],
"type": "powershell"
},
{
"elevated_password": "{{.WinRMPassword}}",
"elevated_user": "packer",
"script": "packer/azure/scripts/sysprep.ps1",
"type": "powershell"
}
],
"variables": {
"additional_debug_files": null,
"ansible_common_vars": "",
"ansible_extra_vars": "",
"ansible_user_vars": "",
"azure_extra_vars": "wire_server_users={{user `wire_server_users`}}",
"azure_location": null,
"build_name": null,
"build_timestamp": "{{timestamp}}",
"client_id": null,
"client_secret": null,
"cloudbase_init_url": "https://github.com/cloudbase/cloudbase-init/releases/download/{{user `cloudbase_init_version`}}/CloudbaseInitSetup_{{user `cloudbase_init_version` | replace_all `.` `_` }}_x64.msi",
"cloudbase_logging_serial_port": "COM2,115200,N,8",
"cloudbase_metadata_services": "cloudbaseinit.metadata.services.azureservice.AzureService",
"cloudbase_metadata_services_unattend": "cloudbaseinit.metadata.services.base.EmptyMetadataService",
"cloudbase_plugins": "cloudbaseinit.plugins.windows.createuser.CreateUserPlugin, cloudbaseinit.plugins.common.setuserpassword.SetUserPasswordPlugin, cloudbaseinit.plugins.windows.extendvolumes.ExtendVolumesPlugin, cloudbaseinit.plugins.common.ephemeraldisk.EphemeralDiskPlugin, cloudbaseinit.plugins.windows.azureguestagent.AzureGuestAgentPlugin, cloudbaseinit.plugins.common.mtu.MTUPlugin, cloudbaseinit.plugins.common.sethostname.SetHostNamePlugin",
"cloudbase_plugins_unattend": "cloudbaseinit.plugins.common.mtu.MTUPlugin",
"community_gallery_image_id": "",
"containerd_url": "",
"containerd_version": null,
"direct_shared_gallery_image_id": "",
"exclude_from_latest": "false",
"gmsa_keyvault_url": "https://kubernetesartifacts.azureedge.net/ccgakvplugin/v1.1.4/binaries/windows-gmsa-ccgakvplugin-v1.1.4.zip",
"ib_version": "{{env `IB_VERSION`}}",
"image_offer": "",
"image_publisher": "",
"image_sku": "",
"image_version": "latest",
"kubernetes_base_url": "https://kubernetesreleases.blob.core.windows.net/kubernetes/{{user `kubernetes_semver`}}/binaries/node/windows/{{user `kubernetes_goarch`}}",
"manifest_output": "manifest.json",
"nssm_url": null,
"os_disk_size_gb": "",
"prepull": null,
"private_virtual_network_with_public_ip": "",
"source_sig_image_name": "",
"source_sig_image_version": "",
"source_sig_name": "",
"source_sig_resource_group_name": "",
"source_sig_subscription_id": "",
"storage_account_type": "",
"subscription_id": null,
"virtual_network_name": "",
"virtual_network_resource_group_name": "",
"virtual_network_subnet_name": "",
"vm_size": "",
"windows_service_manager": null,
"windows_updates_kbs": null,
"wins_url": "https://github.com/rancher/wins/releases/download/v{{user `wins_version`}}/wins.exe",
"wire_server_users": ""
}
}

276
packer/azure/packer.json Normal file
View File

@ -0,0 +1,276 @@
{
"builders": [
{
"azure_tags": {
"build_date": "{{isotime}}",
"build_timestamp": "{{user `build_timestamp`}}",
"creationTimestamp": "{{isotime \"2006-01-02T15:04:05Z\"}}",
"distribution": "{{user `distribution`}}",
"distribution_release": "{{user `distribution_release`}}",
"distribution_version": "{{user `distribution_version`}}",
"image_builder_version": "{{user `ib_version`}}",
"kubernetes_version": "{{user `kubernetes_semver`}}"
},
"capture_container_name": "{{user `capture_container_name`}}",
"capture_name_prefix": "capi-{{user `build_timestamp`}}",
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"image_offer": "{{user `image_offer` }}",
"image_publisher": "{{user `image_publisher` }}",
"image_sku": "{{user `image_sku`}}",
"image_version": "{{user `image_version`}}",
"location": "{{user `azure_location`}}",
"name": "vhd-{{user `build_name`}}",
"os_disk_size_gb": "{{user `os_disk_size_gb`}}",
"os_type": "Linux",
"private_virtual_network_with_public_ip": "{{user `private_virtual_network_with_public_ip`}}",
"resource_group_name": "{{user `resource_group_name`}}",
"ssh_username": "packer",
"storage_account": "{{user `storage_account_name`}}",
"subscription_id": "{{user `subscription_id`}}",
"type": "azure-arm",
"virtual_network_name": "{{user `virtual_network_name`}}",
"virtual_network_resource_group_name": "{{user `virtual_network_resource_group_name`}}",
"virtual_network_subnet_name": "{{user `virtual_network_subnet_name`}}",
"vm_size": "{{user `vm_size`}}"
},
{
"azure_tags": {
"build_date": "{{isotime}}",
"build_timestamp": "{{user `build_timestamp`}}",
"creationTimestamp": "{{isotime \"2006-01-02T15:04:05Z\"}}",
"distribution": "{{user `distribution`}}",
"distribution_release": "{{user `distribution_release`}}",
"distribution_version": "{{user `distribution_version`}}",
"image_builder_version": "{{user `ib_version`}}",
"kubernetes_version": "{{user `kubernetes_semver`}}"
},
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"image_offer": "{{user `image_offer` }}",
"image_publisher": "{{user `image_publisher` }}",
"image_sku": "{{user `image_sku`}}",
"image_version": "{{user `image_version`}}",
"location": "{{user `azure_location`}}",
"managed_image_name": "{{user `image_name`}}-{{user `build_timestamp`}}",
"managed_image_resource_group_name": "{{user `resource_group_name`}}",
"managed_image_storage_account_type": "{{user `storage_account_type`}}",
"name": "sig-{{user `build_name`}}",
"os_disk_size_gb": "{{user `os_disk_size_gb`}}",
"os_type": "Linux",
"plan_info": {
"plan_name": "{{user `plan_image_sku`}}",
"plan_product": "{{user `plan_image_offer`}}",
"plan_publisher": "{{user `plan_image_publisher`}}"
},
"private_virtual_network_with_public_ip": "{{user `private_virtual_network_with_public_ip`}}",
"shared_gallery_image_version_exclude_from_latest": "{{ user `exclude_from_latest` }}",
"shared_image_gallery": {
"community_gallery_image_id": "{{ user `community_gallery_image_id` }}",
"direct_shared_gallery_image_id": "{{ user `direct_shared_gallery_image_id` }}",
"gallery_name": "{{user `source_sig_name`}}",
"image_name": "{{user `source_sig_image_name`}}",
"image_version": "{{user `source_sig_image_version`}}",
"resource_group": "{{user `source_sig_resource_group_name`}}",
"subscription": "{{user `source_sig_subscription_id`}}"
},
"shared_image_gallery_destination": {
"gallery_name": "{{user `shared_image_gallery_name`}}",
"image_name": "{{user `image_name`}}",
"image_version": "{{user `sig_image_version`}}",
"replication_regions": "{{user `replication_regions`}}",
"resource_group": "{{user `resource_group_name`}}",
"storage_account_type": "{{user `storage_account_type`}}"
},
"ssh_username": "packer",
"subscription_id": "{{user `subscription_id`}}",
"type": "azure-arm",
"virtual_network_name": "{{user `virtual_network_name`}}",
"virtual_network_resource_group_name": "{{user `virtual_network_resource_group_name`}}",
"virtual_network_subnet_name": "{{user `virtual_network_subnet_name`}}",
"vm_size": "{{user `vm_size`}}"
}
],
"post-processors": [
{
"custom_data": {
"build_date": "{{isotime}}",
"build_name": "{{user `build_name`}}",
"build_timestamp": "{{user `build_timestamp`}}",
"build_type": "node",
"containerd_version": "{{user `containerd_version`}}",
"kubernetes_cni_semver": "{{user `kubernetes_cni_semver`}}",
"kubernetes_semver": "{{user `kubernetes_semver`}}",
"kubernetes_source_type": "{{user `kubernetes_source_type`}}",
"os_name": "{{user `distro_name`}}",
"resource_group_name": "{{user `resource_group_name`}}",
"storage_account_name": "{{user `storage_account_name`}}"
},
"output": "{{user `manifest_output`}}",
"strip_path": true,
"type": "manifest"
}
],
"provisioners": [
{
"environment_vars": [
"BUILD_NAME={{user `build_name`}}"
],
"inline": [
"if [ $BUILD_NAME != \"ubuntu-1804\" ] && [ $BUILD_NAME != \"ubuntu-1804-gen2\" ]; then exit 0; fi",
"while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done",
"sudo apt-get -qq update && sudo DEBIAN_FRONTEND=noninteractive apt-get -qqy install python python-pip"
],
"type": "shell"
},
{
"ansible_env_vars": [
"ANSIBLE_SSH_ARGS='{{user `existing_ansible_ssh_args`}} {{user `ansible_common_ssh_args`}}'"
],
"extra_arguments": [
"--extra-vars",
"{{user `ansible_common_vars`}}",
"--extra-vars",
"{{user `ansible_extra_vars`}}",
"--extra-vars",
"{{user `ansible_user_vars`}}",
"--scp-extra-args",
"{{user `ansible_scp_extra_args`}}"
],
"playbook_file": "./ansible/python.yml",
"type": "ansible",
"user": "packer"
},
{
"ansible_env_vars": [
"ANSIBLE_SSH_ARGS='{{user `existing_ansible_ssh_args`}} {{user `ansible_common_ssh_args`}}'"
],
"extra_arguments": [
"--extra-vars",
"{{user `ansible_common_vars`}}",
"--extra-vars",
"{{user `ansible_extra_vars`}}",
"--extra-vars",
"{{user `ansible_user_vars`}}",
"--scp-extra-args",
"{{user `ansible_scp_extra_args`}}"
],
"playbook_file": "./ansible/node.yml",
"type": "ansible",
"user": "packer"
},
{
"arch": "{{user `goss_arch`}}",
"download_path": "{{user `goss_download_path`}}",
"format": "{{user `goss_format`}}",
"format_options": "{{user `goss_format_options`}}",
"goss_file": "{{user `goss_entry_file`}}",
"inspect": "{{user `goss_inspect_mode`}}",
"remote_folder": "{{user `goss_remote_folder`}}",
"remote_path": "{{user `goss_remote_path`}}",
"skip_install": "{{user `goss_skip_install`}}",
"tests": [
"{{user `goss_tests_dir`}}"
],
"type": "goss",
"url": "{{user `goss_url`}}",
"use_sudo": true,
"vars_file": "{{user `goss_vars_file`}}",
"vars_inline": {
"ARCH": "amd64",
"OS": "{{user `distribution` | lower}}",
"OS_VERSION": "{{user `distribution_version` | lower}}",
"PROVIDER": "azure",
"containerd_version": "{{user `containerd_version`}}",
"containerd_wasm_shims_runtimes": "{{user `containerd_wasm_shims_runtimes` }}",
"kubernetes_cni_deb_version": "{{ user `kubernetes_cni_deb_version` }}",
"kubernetes_cni_rpm_version": "{{ split (user `kubernetes_cni_rpm_version`) \"-\" 0 }}",
"kubernetes_cni_source_type": "{{user `kubernetes_cni_source_type`}}",
"kubernetes_cni_version": "{{user `kubernetes_cni_semver` | replace \"v\" \"\" 1}}",
"kubernetes_deb_version": "{{ user `kubernetes_deb_version` }}",
"kubernetes_rpm_version": "{{ split (user `kubernetes_rpm_version`) \"-\" 0 }}",
"kubernetes_source_type": "{{user `kubernetes_source_type`}}",
"kubernetes_version": "{{user `kubernetes_semver` | replace \"v\" \"\" 1}}"
},
"version": "{{user `goss_version`}}"
},
{
"environment_vars": [
"BUILD_NAME={{user `build_name`}}"
],
"inline": [
"if [[ $BUILD_NAME != \"flatcar\"* ]]; then exit 0; fi",
"sudo bash -c \"/usr/share/oem/python/bin/python /usr/share/oem/bin/waagent -force -deprovision+user && sync\""
],
"inline_shebang": "/bin/bash -x",
"remote_folder": "{{user `provisioner_remote_folder`}}",
"type": "shell"
}
],
"variables": {
"ansible_common_vars": "",
"ansible_extra_vars": "",
"ansible_scp_extra_args": "",
"ansible_user_vars": "",
"azure_location": null,
"build_name": null,
"build_resource_group_name": "{{ env `BUILD_RESOURCE_GROUP_NAME` }}",
"build_timestamp": "{{timestamp}}",
"client_id": null,
"client_secret": null,
"community_gallery_image_id": "",
"containerd_sha256": null,
"containerd_url": "https://github.com/containerd/containerd/releases/download/v{{user `containerd_version`}}/cri-containerd-cni-{{user `containerd_version`}}-linux-amd64.tar.gz",
"containerd_version": null,
"containerd_wasm_shims_runtimes": null,
"crictl_url": "https://github.com/kubernetes-sigs/cri-tools/releases/download/v{{user `crictl_version`}}/crictl-v{{user `crictl_version`}}-linux-amd64.tar.gz",
"crictl_version": null,
"direct_shared_gallery_image_id": "",
"distribution": null,
"distribution_release": null,
"distribution_version": null,
"exclude_from_latest": "false",
"existing_ansible_ssh_args": "{{env `ANSIBLE_SSH_ARGS`}}",
"ib_version": "{{env `IB_VERSION`}}",
"image_offer": "",
"image_publisher": "",
"image_sku": "",
"image_version": "latest",
"kubernetes_cni_deb_version": null,
"kubernetes_cni_http_source": null,
"kubernetes_cni_rpm_version": null,
"kubernetes_cni_semver": null,
"kubernetes_cni_source_type": null,
"kubernetes_container_registry": null,
"kubernetes_deb_gpg_key": null,
"kubernetes_deb_repo": null,
"kubernetes_deb_version": null,
"kubernetes_http_source": null,
"kubernetes_load_additional_imgs": null,
"kubernetes_rpm_gpg_check": null,
"kubernetes_rpm_gpg_key": null,
"kubernetes_rpm_repo": null,
"kubernetes_rpm_version": null,
"kubernetes_semver": null,
"kubernetes_series": null,
"kubernetes_source_type": null,
"manifest_output": "manifest.json",
"os_disk_size_gb": "",
"plan_image_offer": "",
"plan_image_publisher": "",
"plan_image_sku": "",
"private_virtual_network_with_public_ip": "",
"provisioner_remote_folder": "/tmp",
"source_sig_image_name": "",
"source_sig_image_version": "",
"source_sig_name": "",
"source_sig_resource_group_name": "",
"source_sig_subscription_id": "",
"storage_account_type": "",
"subscription_id": null,
"virtual_network_name": "",
"virtual_network_resource_group_name": "",
"virtual_network_subnet_name": "",
"vm_size": ""
}
}

11
packer/azure/rhel-8.json Normal file
View File

@ -0,0 +1,11 @@
{
"build_name": "rhel-8",
"distribution": "rhel",
"distribution_release": "rhel-8",
"distribution_version": "8",
"epel_rpm_gpg_key": "https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8",
"image_offer": "RHEL",
"image_publisher": "RedHat",
"image_sku": "8_7",
"redhat_epel_rpm": "https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm"
}

View File

@ -0,0 +1,156 @@
#!/bin/bash
# Copyright 2021 The Kubernetes Authors.
#
# 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.
# This script deletes unused Azure storage accounts created in the process of
# building CAPZ reference images. It also archives existing accounts into one
# main storage account to reduce the limited number of accounts in use.
# Usage:
# <DRYRUN=true|false> delete-unused-storage.sh
#
# The `pub` tool (https://github.com/devigned/pub) and the `az` CLI tool
# (https://docs.microsoft.com/en-us/cli/azure/install-azure-cli) must be found
# in the PATH.
#
# In order to run this script, log in to the publishing account with the
# `az account set -s <SUBSCRIPTION_ID>` command. Then export these environment
# variables to enable access to the storage accounts:
# AZURE_CLIENT_ID
# AZURE_CLIENT_SECRET
# AZURE_SUBSCRIPTION_ID
# AZURE_TENANT_ID
#
# By default, the script will not modify any resources. Pass the environment variable
# DRYRUN=false to enable the script to archive and to delete the storage accounts.
set -o errexit
set -o nounset
set -o pipefail
[[ -n ${DEBUG:-} ]] && set -o xtrace
RESOURCE_GROUP=${RESOURCE_GROUP:-cluster-api-images}
PUBLISHER=${PUBLISHER:-cncf-upstream}
OFFERS=${OFFERS:-capi capi-windows}
PREFIX=${PREFIX:-capi}
LONG_PREFIX=${LONG_PREFIX:-${PREFIX}[0-9]{10\}}
ARCHIVE_STORAGE_ACCOUNT=${ARCHIVE_STORAGE_ACCOUNT:-${PREFIX}archive}
DRYRUN=${DRYRUN:-true}
RED='\033[0;31m'
NC='\033[0m'
if ${DRYRUN}; then
echo "DRYRUN: This script will not copy or delete any resources."
ECHO=echo
else
ECHO=
fi
which pub &> /dev/null || (echo "Please install pub from https://github.com/devigned/pub/releases" && exit 1)
# Get URLs in use by the marketplace offers
URLS=""
for name in ${OFFERS}; do
echo "Getting URLs for ${name}..."
offer=$(pub offers show -p "$PUBLISHER" -o "$name")
# Capture "label" as well as "osVhdUrl" so we can archive storage accounts with something readable.
urls=$(echo "${offer}" | jq -r '.definition["plans"][]."microsoft-azure-corevm.vmImagesPublicAzure"[] | [.label, .osVhdUrl] | @csv')
if [[ -z $URLS ]]; then
URLS=${urls}
else
URLS=${URLS}$'\n'${urls}
fi
done
NOW=$(date +%s)
# ensure the existence of the archive storage account
if ! az storage account show -g "${RESOURCE_GROUP}" -n "${ARCHIVE_STORAGE_ACCOUNT}" &> /dev/null; then
echo "Creating archive storage account ${ARCHIVE_STORAGE_ACCOUNT}..."
$ECHO az storage account create -g "${RESOURCE_GROUP}" -n "${ARCHIVE_STORAGE_ACCOUNT}" --access-tier Cool --allow-blob-public-access false
fi
IFS=$'\n'
archived=0
deleted=0
# For each storage account in the subscription,
for account in $(az storage account list -g "${RESOURCE_GROUP}" -o tsv --query "[?starts_with(name, '${PREFIX}')].[name,creationTime]"); do
IFS=$'\t' read -r storage_account creation_time <<< "$account"
created=$(date -d "${creation_time}" +%s 2>/dev/null || date -j -f "%F" "${creation_time}" +%s 2>/dev/null)
age=$(( (NOW - created) / 86400 ))
# if it's older than a month
if [[ $age -gt 30 ]]; then
# and it has the right naming pattern
if [[ ${storage_account} =~ ^${LONG_PREFIX} ]]; then
# but isn't referenced in the offer osVhdUrls
if [[ ! ${URLS} =~ ${storage_account} ]]; then
# delete it.
echo "Deleting unreferenced storage account ${storage_account} that is ${age} days old"
${ECHO} az storage account delete -g "${RESOURCE_GROUP}" -n "${storage_account}" -y
deleted=$((deleted+1))
else
# archive it.
for URL in ${URLS}; do
IFS=$',' read -r label url <<< "${URL}"
# container names are somewhat strict, so transform the label into a valid container name
# See https://github.com/MicrosoftDocs/azure-docs/blob/master/includes/storage-container-naming-rules-include.md
dest_label=${label//[ .]/-}
dest_label=${dest_label//[^a-zA-Z0-9-]/}
dest_label=$(echo "${dest_label}" | tr '[:upper:]' '[:lower:]')
if [[ ${url} =~ ${storage_account} ]]; then
echo "Archiving storage account ${storage_account} (${label}) that is ${age} days old"
# create a destination container
if [[ $(az storage container exists --account-name "${ARCHIVE_STORAGE_ACCOUNT}" -n "${dest_label}" -o tsv 2>/dev/null) != "True" ]]; then
${ECHO} az storage container create --only-show-errors --public-access=container \
-n ${dest_label} -g "${RESOURCE_GROUP}" --account-name "${ARCHIVE_STORAGE_ACCOUNT}" 2>/dev/null
fi
# for each source container
for container in $(az storage container list --only-show-errors --account-name ${storage_account} --query "[].name" -o tsv 2>/dev/null); do
# copy it to the destination container
${ECHO} az storage blob copy start-batch \
--account-name ${ARCHIVE_STORAGE_ACCOUNT} \
--destination-container ${dest_label} \
--destination-path ${container} \
--source-container ${container} \
--source-account-name ${storage_account} \
--pattern '*capi-*' \
2>/dev/null
done
# poll the target container until all blobs have "succeeded" copy status
for target in $(az storage blob list --account-name ${ARCHIVE_STORAGE_ACCOUNT} -c ${dest_label} --query '[].name' -o tsv 2>/dev/null); do
while true; do
status=$(az storage blob show --account-name ${ARCHIVE_STORAGE_ACCOUNT} --container-name ${dest_label} --name $target -o tsv --query 'properties.copy.status' 2>/dev/null)
if [[ ${status} == "success" ]]; then
echo "Copied ${dest_label}/${target}"
break
else
echo "Copying ${dest_label}/${target} ..."
sleep 20
fi
done
done
echo "Deleting source storage account ${storage_account}..."
${ECHO} az storage account delete -g "${RESOURCE_GROUP}" -n "${storage_account}" -y
archived=$((archived+1))
fi
done
echo -e "Pausing for 10 seconds. ${RED}Hit Ctrl-C to stop.${NC}"
sleep 10
echo
fi
fi
fi
done
echo "Deleted ${deleted} storage accounts."
echo "Archived ${archived} storage accounts."

View File

@ -0,0 +1,3 @@
{
"prepull": "false"
}

View File

@ -0,0 +1,42 @@
#!/usr/bin/env bash
# Copyright 2022 The Kubernetes Authors.
#
# 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.
set -o errexit
set -o nounset
set -o pipefail
[[ -n ${DEBUG:-} ]] && set -o xtrace
# Change directories to the parent directory of the one in which this
# script is located.
CAPI_ROOT=$(dirname "${BASH_SOURCE[0]}")/../../..
cd "${CAPI_ROOT}" || exit 1
source hack/utils.sh
if command -v kustomize >/dev/null 2>&1; then exit 0; fi
mkdir -p .local/bin && cd .local/bin
KUSTOMIZE_VERSION=4.5.2
_binfile="kustomize-v${KUSTOMIZE_VERSION}.tar.gz"
echo "installing kustomize"
curl -sLo "${_binfile}" "https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${KUSTOMIZE_VERSION}/kustomize_v${KUSTOMIZE_VERSION}_${HOSTOS}_${HOSTARCH}.tar.gz"
tar -zvxf "${_binfile}" -C "./"
chmod +x "./kustomize"
rm "${_binfile}"
echo "'kustomize' has been installed to $(pwd), make sure this directory is in your \$PATH"

100
packer/azure/scripts/init-sig.sh Executable file
View File

@ -0,0 +1,100 @@
#!/bin/bash
[[ -n ${DEBUG:-} ]] && set -o xtrace
tracestate="$(shopt -po xtrace)"
set +o xtrace
az login --service-principal -u ${AZURE_CLIENT_ID} -p ${AZURE_CLIENT_SECRET} --tenant ${AZURE_TENANT_ID} >/dev/null 2>&1
az account set -s ${AZURE_SUBSCRIPTION_ID} >/dev/null 2>&1
eval "$tracestate"
export RESOURCE_GROUP_NAME="${RESOURCE_GROUP_NAME:-cluster-api-images}"
export AZURE_LOCATION="${AZURE_LOCATION:-southcentralus}"
if ! az group show -n ${RESOURCE_GROUP_NAME} -o none 2>/dev/null; then
az group create -n ${RESOURCE_GROUP_NAME} -l ${AZURE_LOCATION} --tags ${TAGS:-}
fi
CREATE_TIME="$(date +%s)"
RANDOM_SUFFIX="$(head /dev/urandom | LC_ALL=C tr -dc a-z | head -c 4 ; echo '')"
export GALLERY_NAME="${GALLERY_NAME:-ClusterAPI${CREATE_TIME}${RANDOM_SUFFIX}}"
# Hack to set only build_resource_group_name or location, a better solution is welcome
# https://developer.hashicorp.com/packer/plugins/builders/azure/arm#build_resource_group_name
PACKER_FILE_PATH=packer/azure/
TMP_PACKER_FILE=$PACKER_FILE_PATH"packer.json.tmp"
PACKER_FILE=$PACKER_FILE_PATH"packer.json"
if [ ${BUILD_RESOURCE_GROUP_NAME} ]; then
if ! az group show -n ${BUILD_RESOURCE_GROUP_NAME} -o none 2>/dev/null; then
az group create -n ${BUILD_RESOURCE_GROUP_NAME} -l ${AZURE_LOCATION} --tags ${TAGS:-}
fi
jq '(.builders | map(if .name | contains("sig") then del(.location) + {"build_resource_group_name": "{{user `build_resource_group_name`}}"} else . end)) as $updated | .builders = $updated' $PACKER_FILE > $TMP_PACKER_FILE
mv $TMP_PACKER_FILE $PACKER_FILE
fi
packer validate -syntax-only $PACKER_FILE || exit 1
az sig create --resource-group ${RESOURCE_GROUP_NAME} --gallery-name ${GALLERY_NAME}
create_image_definition() {
az sig image-definition create \
--resource-group ${RESOURCE_GROUP_NAME} \
--gallery-name ${GALLERY_NAME} \
--gallery-image-definition capi-${1} \
--publisher capz \
--offer capz-demo \
--sku ${2} \
--hyper-v-generation ${3} \
--os-type ${4}
}
SIG_TARGET=$1
case ${SIG_TARGET} in
ubuntu-1804)
create_image_definition ${SIG_TARGET} "18.04-LTS" "V1" "Linux"
;;
ubuntu-2004)
create_image_definition ${SIG_TARGET} "20_04-lts" "V1" "Linux"
;;
ubuntu-2204)
create_image_definition ${SIG_TARGET} "22_04-lts" "V1" "Linux"
;;
centos-7)
create_image_definition "centos-7" "centos-7" "V1" "Linux"
;;
rhel-8)
create_image_definition "rhel-8" "rhel-8" "V1" "Linux"
;;
windows-2019)
create_image_definition "windows-2019-docker-ee" "win-2019-docker-ee" "V1" "Windows"
;;
windows-2019-containerd)
create_image_definition ${SIG_TARGET} "win-2019-containerd" "V1" "Windows"
;;
windows-2022-containerd)
create_image_definition ${SIG_TARGET} "win-2022-containerd" "V1" "Windows"
;;
flatcar)
SKU="flatcar-${FLATCAR_CHANNEL}-${FLATCAR_VERSION}"
create_image_definition ${SKU} ${SKU} "V1" "Linux"
;;
ubuntu-1804-gen2)
create_image_definition ${SIG_TARGET} "18.04-lts-gen2" "V2" "Linux"
;;
ubuntu-2004-gen2)
create_image_definition ${SIG_TARGET} "20_04-lts-gen2" "V2" "Linux"
;;
ubuntu-2204-gen2)
create_image_definition ${SIG_TARGET} "22_04-lts-gen2" "V2" "Linux"
;;
centos-7-gen2)
create_image_definition "centos-7-gen2" "centos-7-gen2" "V2" "Linux"
;;
flatcar-gen2)
SKU="flatcar-${FLATCAR_CHANNEL}-${FLATCAR_VERSION}-gen2"
create_image_definition "${SKU}" "${SKU}" "V2" "Linux"
;;
*)
>&2 echo "Unsupported SIG target: '${SIG_TARGET}'"
exit 1
;;
esac

View File

@ -0,0 +1,32 @@
#!/bin/bash
[[ -n ${DEBUG:-} ]] && set -o xtrace
echo "Sign into Azure"
tracestate="$(shopt -po xtrace)"
set +o xtrace
az login --service-principal -u ${AZURE_CLIENT_ID} -p ${AZURE_CLIENT_SECRET} --tenant ${AZURE_TENANT_ID} >/dev/null 2>&1
az account set -s ${AZURE_SUBSCRIPTION_ID} >/dev/null 2>&1
eval "$tracestate"
echo "Create storage account"
export RESOURCE_GROUP_NAME="${RESOURCE_GROUP_NAME:-cluster-api-images}"
export AZURE_LOCATION="${AZURE_LOCATION:-southcentralus}"
if ! az group show -n ${RESOURCE_GROUP_NAME} -o none 2>/dev/null; then
az group create -n ${RESOURCE_GROUP_NAME} -l ${AZURE_LOCATION} --tags ${TAGS:-}
fi
CREATE_TIME="$(date +%s)"
RANDOM_SUFFIX="$(head /dev/urandom | LC_ALL=C tr -dc a-z | head -c 4 ; echo '')"
get_random_region() {
local REGIONS=("canadacentral" "eastus" "eastus2" "northeurope" "uksouth" "westeurope" "westus2" "westus3")
echo "${REGIONS[${RANDOM} % ${#REGIONS[@]}]}"
}
RANDOMIZE_STORAGE_ACCOUNT="${RANDOMIZE_STORAGE_ACCOUNT:-"false"}"
if [ "$RANDOMIZE_STORAGE_ACCOUNT" == "true" ]; then
export AZURE_LOCATION="$(get_random_region)"
fi
export STORAGE_ACCOUNT_NAME="${STORAGE_ACCOUNT_NAME:-capi${CREATE_TIME}${RANDOM_SUFFIX}}"
az storage account check-name --name ${STORAGE_ACCOUNT_NAME}
az storage account create -n ${STORAGE_ACCOUNT_NAME} -g ${RESOURCE_GROUP_NAME} -l ${AZURE_LOCATION} --allow-blob-public-access false
echo "done"

View File

@ -0,0 +1,107 @@
#!/bin/bash -e
[[ -n ${DEBUG:-} ]] && set -o xtrace
echo "PWD: $PWD"
OS=${OS:-"Ubuntu"}
OS_VERSION=${OS_VERSION:-"18.04"}
PUB_VERSION=${PUB_VERSION:-"v0.3.3"}
required_env_vars=(
"AZURE_CLIENT_ID"
"AZURE_CLIENT_SECRET"
"AZURE_TENANT_ID"
"OS"
"OS_VERSION"
"PUB_VERSION"
)
for v in "${required_env_vars[@]}"
do
if [ -z "${!v}" ]; then
echo "$v was not set!"
exit 1
fi
done
SKU_INFO="sku/sku-publishing-info.json"
VHD_INFO="vhd/vhd-publishing-info.json"
required_files=(
"SKU_INFO"
"VHD_INFO"
)
for f in "${required_files[@]}"
do
if [ ! -f "${!f}" ]; then
echo "could not find file: ${!f}"
exit 1
fi
done
echo "Getting pub..."
(set -x ; curl -fsSL https://github.com/devigned/pub/releases/download/${PUB_VERSION}/pub_${PUB_VERSION}_linux_amd64.tar.gz -o pub; tar -xzf pub)
echo "SKU publishing info:"
cat $SKU_INFO
echo
echo "VHD publishing info:"
cat $VHD_INFO
echo
# get Kubernetes version and split into major, minor, and patch
k8s_version=$(< $SKU_INFO jq -r ".k8s_version")
IFS='.' # set period (.) as delimiter
read -ra ADDR <<< "${k8s_version}" # str is read into an array as tokens separated by IFS
IFS=' ' # reset to default value after usage
major=${ADDR[0]}
minor=${ADDR[1]}
patch=${ADDR[2]}
# generate image version
image_version=${major}${minor}.${patch}.$(date +"%Y%m%d")
# generate media name
sku_id=$(< $SKU_INFO jq -r ".sku_id")
media_name="${sku_id}-${image_version}"
# generate published date
published_date=$(date +"%m/%d/%Y")
# get vhd url
vhd_url=$(< $VHD_INFO jq -r ".vhd_url")
label="Kubernetes $k8s_version $OS $OS_VERSION"
description="Kubernetes $k8s_version $OS $OS_VERSION"
# create version.json
cat <<EOF > version.json
{
"$image_version" : {
"mediaName": "$media_name",
"showInGui": false,
"publishedDate": "$published_date",
"label": "$label",
"description": "$description",
"osVHdUrl": "$vhd_url"
}
}
EOF
echo "Version info:"
cat version.json
publisher=$(< $SKU_INFO jq -r ".publisher")
offer=$(< $SKU_INFO jq -r ".offer")
sku=$(< $SKU_INFO jq -r ".sku_id")
# TODO: Update pub versions put to take in version.json as a file
echo "Create new disk version"
set -x
./pub_linux_amd64 versions put corevm -p $publisher -o $offer -s $sku --version $image_version --vhd-uri $vhd_url --media-name $media_name --label "$label" --desc "$description" --published-date "$published_date"
set +x
echo -e "\nCreated disk version"

80
packer/azure/scripts/new-sku.sh Executable file
View File

@ -0,0 +1,80 @@
#!/bin/bash -e
OS=${OS:-"Ubuntu"}
OS_VERSION=${OS_VERSION:-"18.04"}
PUB_VERSION=${PUB_VERSION:-"v0.3.3"}
VM_GENERATION=${VM_GENERATION:-"gen1"}
[[ -n ${DEBUG:-} ]] && set -o xtrace
required_env_vars=(
"AZURE_CLIENT_ID"
"AZURE_CLIENT_SECRET"
"AZURE_TENANT_ID"
"KUBERNETES_VERSION"
"OFFER"
"OS"
"OS_VERSION"
"PUB_VERSION"
"PUBLISHER"
"SKU_TEMPLATE_FILE"
"VM_GENERATION"
)
for v in "${required_env_vars[@]}"
do
if [ -z "${!v}" ]; then
echo "$v was not set!"
exit 1
fi
done
if [ ! -f "$SKU_TEMPLATE_FILE" ]; then
echo "Could not find sku template file: ${SKU_TEMPLATE_FILE}!"
exit 1
fi
os=$(echo "$OS" | tr '[:upper:]' '[:lower:]')
version=$(echo "$OS_VERSION" | tr '[:upper:]' '[:lower:]' | tr -d .)
sku_id="${os}-${version}-${VM_GENERATION}"
if [ "$OS" == "Ubuntu" ]; then
os_type="Ubuntu"
os_family="Linux"
elif [ "$OS" == "Windows" ]; then
os_type="Other"
os_family="Windows"
else
echo "Cannot configure unknown OS: ${OS}!"
exit 1
fi
< $SKU_TEMPLATE_FILE sed s/{{ID}}/"$sku_id"/ \
| sed s/{{KUBERNETES_VERSION}}/"$KUBERNETES_VERSION/" \
| sed s/{{OS}}/"$OS/" \
| sed s/{{OS_VERSION}}/"$OS_VERSION/" \
| sed s/{{OS_TYPE}}/"$os_type/" \
| sed s/{{OS_FAMILY}}/"$os_family/" \
> sku.json
cat sku.json
echo
echo "Getting pub..."
(set -x ; curl -fsSL https://github.com/devigned/pub/releases/download/${PUB_VERSION}/pub_${PUB_VERSION}_linux_amd64.tar.gz -o pub; tar -xzf pub)
echo "Creating new SKU"
set -x
./pub_linux_amd64 skus put -p $PUBLISHER -o "$OFFER" -f sku.json
set +x
echo -e "\nCreated sku"
echo "Writing publishing info"
cat <<EOF > sku-publishing-info.json
{
"publisher" : "$PUBLISHER",
"offer" : "$OFFER",
"sku_id" : "$sku_id",
"k8s_version" : "$KUBERNETES_VERSION"
}
EOF
cat sku-publishing-info.json

View File

@ -0,0 +1,33 @@
#!/bin/bash
# Copyright 2020 The Kubernetes Authors.
#
# 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.
set -o errexit
set -o nounset
set -o pipefail
set +o xtrace
parse_cred() {
grep -E -o "\b$1[[:blank:]]*=[[:blank:]]*\"[^[:space:]\"]+\"" | cut -d '"' -f 2
}
# for Prow we use the provided AZURE_CREDENTIALS file.
# the file is expected to be in toml format.
if [[ -n "${AZURE_CREDENTIALS:-}" ]]; then
export AZURE_SUBSCRIPTION_ID="$(cat ${AZURE_CREDENTIALS} | parse_cred SubscriptionID)"
export AZURE_TENANT_ID="$(cat ${AZURE_CREDENTIALS} | parse_cred TenantID)"
export AZURE_CLIENT_ID="$(cat ${AZURE_CREDENTIALS} | parse_cred ClientID)"
export AZURE_CLIENT_SECRET="$(cat ${AZURE_CREDENTIALS} | parse_cred ClientSecret)"
fi

View File

@ -0,0 +1,46 @@
# Copyright 2020 The Kubernetes Authors.
# 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.
# Modified from https://docs.microsoft.com/en-us/azure/virtual-machines/linux/image-builder-troubleshoot#sysprep-command-windows
# The Windows Azure Guest Agent is required for sysprep: https://www.packer.io/docs/builders/azure/arm#windows
Write-Output '>>> Waiting for GA Service (RdAgent) to start ...'
while ((Get-Service RdAgent).Status -ne 'Running') { Start-Sleep -s 5 }
Write-Output '>>> Waiting for GA Service (WindowsAzureTelemetryService) to start ...'
while ((Get-Service WindowsAzureTelemetryService) -and ((Get-Service WindowsAzureTelemetryService).Status -ne 'Running')) { Start-Sleep -s 5 }
Write-Output '>>> Waiting for GA Service (WindowsAzureGuestAgent) to start ...'
while ((Get-Service WindowsAzureGuestAgent).Status -ne 'Running') { Start-Sleep -s 5 }
Write-Output '>>> Sysprepping VM ...'
if( Test-Path $Env:SystemRoot\system32\Sysprep\unattend.xml ) {
Remove-Item $Env:SystemRoot\system32\Sysprep\unattend.xml -Force
}
$unattendedXml = "$ENV:ProgramFiles\Cloudbase Solutions\Cloudbase-Init\conf\Unattend.xml"
$FileExists = Test-Path $unattendedXml
If ($FileExists -eq $True) {
# Use the Cloudbase-init provided unattend file during install
Write-Output "Using cloudbase-init unattend file for sysprep: $unattendedXml"
& $Env:SystemRoot\System32\Sysprep\Sysprep.exe /oobe /generalize /mode:vm /quit /quiet /unattend:$unattendedXml
}else {
& $Env:SystemRoot\System32\Sysprep\Sysprep.exe /oobe /generalize /mode:vm /quit /quiet
}
# Wait for the image to be reset
while($true) {
$imageState = (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\State).ImageState
Write-Output $imageState
if ($imageState -eq 'IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE') { break }
Start-Sleep -s 5
}
Write-Output '>>> Sysprep complete ...'

View File

@ -0,0 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- https://github.com/kubernetes-sigs/cluster-api-provider-azure/releases/download/v1.6.0/cluster-template.yaml
patchesStrategicMerge:
- ../patches/azuremachinetemplate-controlplane.yaml
- ../patches/azuremachinetemplate-workload.yaml

View File

@ -0,0 +1,11 @@
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachineTemplate
metadata:
name: ${CLUSTER_NAME}-control-plane
namespace: default
spec:
template:
spec:
image:
id: ${MANAGED_IMAGE_ID}
---

View File

@ -0,0 +1,11 @@
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachineTemplate
metadata:
name: ${CLUSTER_NAME}-md-win
namespace: default
spec:
template:
spec:
image:
id: ${MANAGED_IMAGE_ID}
---

View File

@ -0,0 +1,11 @@
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AzureMachineTemplate
metadata:
name: ${CLUSTER_NAME}-md-0
namespace: default
spec:
template:
spec:
image:
id: ${MANAGED_IMAGE_ID}
---

View File

@ -0,0 +1,8 @@
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: KubeadmControlPlane
metadata:
name: ${CLUSTER_NAME}-control-plane
namespace: default
spec:
version: ${KUBERNETES_BOOTSTRAP_VERSION}
---

View File

@ -0,0 +1,8 @@
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
name: ${CLUSTER_NAME}-md-0
namespace: default
spec:
replicas: 0
---

View File

@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- https://github.com/kubernetes-sigs/cluster-api-provider-azure/releases/download/v1.6.0/cluster-template-windows.yaml
patchesStrategicMerge:
- ../patches/azuremachinetemplate-windows.yaml
- ../patches/kubeadmcontrolplane-windows.yaml
- ../patches/machinedeployment-windows.yaml

View File

@ -0,0 +1,41 @@
{
"microsoft-azure-corevm.cloudAvailability": [
"PublicAzure",
"Mooncake",
"Fairfax"
],
"microsoft-azure-corevm.defaultImageSizeGB": "30",
"microsoft-azure-corevm.deploymentModels": [
"ARM"
],
"microsoft-azure-corevm.freeTierEligible": true,
"microsoft-azure-corevm.generation": "1",
"microsoft-azure-corevm.hardened": false,
"microsoft-azure-corevm.hideSKUForSolutionTemplate": true,
"microsoft-azure-corevm.imageType": "VmImage",
"microsoft-azure-corevm.imageVisibility": true,
"microsoft-azure-corevm.isPremiumThirdParty": false,
"microsoft-azure-corevm.largeLogo": "https://capiofferlogos.blob.core.windows.net/logos/large216x216",
"microsoft-azure-corevm.mediumLogo": "https://capiofferlogos.blob.core.windows.net/logos/medium90x90",
"microsoft-azure-corevm.migratedOffer": false,
"microsoft-azure-corevm.operatingSystemFamily": "{{OS_FAMILY}}",
"microsoft-azure-corevm.osType": "{{OS_TYPE}}",
"microsoft-azure-corevm.privacyURL": "https://github.com/cncf/foundation/blob/master/copyright-notices.md",
"microsoft-azure-corevm.skuDescriptionFairfax": "Base Image for building Kubernetes cluster on Azure with Cluster API. This image is not intended for use outside of https://github.com/kubernetes-sigs/cluster-api-provider-azure.",
"microsoft-azure-corevm.skuDescriptionMooncake": "Base Image for building Kubernetes cluster on Azure with Cluster API. This image is not intended for use outside of https://github.com/kubernetes-sigs/cluster-api-provider-azure.",
"microsoft-azure-corevm.skuDescriptionPublicAzure": "Base Image for building Kubernetes cluster on Azure with Cluster API. This image is not intended for use outside of https://github.com/kubernetes-sigs/cluster-api-provider-azure.",
"microsoft-azure-corevm.skuLongSummary": "Cluster API Kubernetes {{OS}} {{OS_VERSION}} Base Image",
"microsoft-azure-corevm.skuSummary": "Cluster API Kubernetes {{OS}} {{OS_VERSION}} Base Image",
"microsoft-azure-corevm.skuTitle": "Kubernetes {{OS}} {{OS_VERSION}}",
"microsoft-azure-corevm.smallLogo": "https://capiofferlogos.blob.core.windows.net/logos/small48x48",
"microsoft-azure-corevm.supportsAADLogin": false,
"microsoft-azure-corevm.supportsBackup": false,
"microsoft-azure-corevm.supportsClientHub": false,
"microsoft-azure-corevm.supportsHub": false,
"microsoft-azure-corevm.supportsHubOnOffSwitch": false,
"microsoft-azure-corevm.supportsSriov": false,
"microsoft-azure-corevm.termsOfUseURL": "https://github.com/cncf/foundation/blob/master/copyright-notices.md",
"microsoft-azure-corevm.vmImagesPublicAzure": {},
"microsoft-azure-corevm.wideLogo": "https://capiofferlogos.blob.core.windows.net/logos/wide255x115",
"planId": "{{ID}}"
}

View File

@ -0,0 +1,9 @@
{
"build_name": "ubuntu-1804-gen2",
"distribution": "ubuntu",
"distribution_release": "bionic",
"distribution_version": "1804",
"image_offer": "UbuntuServer",
"image_publisher": "Canonical",
"image_sku": "18_04-lts-gen2"
}

View File

@ -0,0 +1,9 @@
{
"build_name": "ubuntu-1804",
"distribution": "ubuntu",
"distribution_release": "bionic",
"distribution_version": "1804",
"image_offer": "UbuntuServer",
"image_publisher": "Canonical",
"image_sku": "18.04-LTS"
}

View File

@ -0,0 +1,9 @@
{
"build_name": "ubuntu-2004-gen2",
"distribution": "ubuntu",
"distribution_release": "focal",
"distribution_version": "2004",
"image_offer": "0001-com-ubuntu-server-focal",
"image_publisher": "Canonical",
"image_sku": "20_04-lts-gen2"
}

View File

@ -0,0 +1,9 @@
{
"build_name": "ubuntu-2004",
"distribution": "ubuntu",
"distribution_release": "focal",
"distribution_version": "2004",
"image_offer": "0001-com-ubuntu-server-focal",
"image_publisher": "Canonical",
"image_sku": "20_04-lts"
}

View File

@ -0,0 +1,9 @@
{
"build_name": "ubuntu-2204-gen2",
"distribution": "ubuntu",
"distribution_release": "jammy",
"distribution_version": "2204",
"image_offer": "0001-com-ubuntu-server-jammy",
"image_publisher": "Canonical",
"image_sku": "22_04-lts-gen2"
}

View File

@ -0,0 +1,9 @@
{
"build_name": "ubuntu-2204",
"distribution": "ubuntu",
"distribution_release": "jammy",
"distribution_version": "2204",
"image_offer": "0001-com-ubuntu-server-jammy",
"image_publisher": "Canonical",
"image_sku": "22_04-lts"
}

View File

@ -0,0 +1,10 @@
{
"build_name": "windows-2004",
"distribution": "windows",
"distribution_version": "2004",
"image_offer": "WindowsServer",
"image_publisher": "MicrosoftWindowsServer",
"image_sku": "Datacenter-Core-2004-with-Containers-smalldisk",
"vm_size": "Standard_D4s_v3",
"windows_updates_kbs": ""
}

View File

@ -0,0 +1,16 @@
{
"additional_registry_images": "false",
"additional_registry_images_list": "",
"build_name": "windows-2019-containerd",
"distribution": "windows",
"distribution_version": "2019",
"image_offer": "WindowsServer",
"image_publisher": "MicrosoftWindowsServer",
"image_sku": "2019-Datacenter-Core-smalldisk",
"image_version": "latest",
"load_additional_components": "false",
"runtime": "containerd",
"vm_size": "Standard_D4s_v3",
"windows_updates_kbs": "",
"wins_url": ""
}

View File

@ -0,0 +1,14 @@
{
"additional_registry_images": "true",
"additional_registry_images_list": "docker.io/sigwindowstools/flannel:v0.13.0-nanoserver,docker.io/sigwindowstools/kube-proxy:{{user `kubernetes_semver`}}-nanoserver",
"build_name": "windows-2019",
"distribution": "windows",
"distribution_version": "2019",
"image_offer": "WindowsServer",
"image_publisher": "MicrosoftWindowsServer",
"image_sku": "2019-Datacenter-Core-smalldisk",
"image_version": "latest",
"load_additional_components": "true",
"vm_size": "Standard_D4s_v3",
"windows_updates_kbs": ""
}

View File

@ -0,0 +1,16 @@
{
"additional_registry_images": "false",
"additional_registry_images_list": "",
"build_name": "windows-2022-containerd",
"distribution": "windows",
"distribution_version": "2022",
"image_offer": "WindowsServer",
"image_publisher": "MicrosoftWindowsServer",
"image_sku": "2022-Datacenter-Core-smalldisk",
"image_version": "latest",
"load_additional_components": "false",
"runtime": "containerd",
"vm_size": "Standard_D4s_v3",
"windows_updates_kbs": "",
"wins_url": ""
}

View File

@ -0,0 +1,10 @@
{
"additional_executables": "false",
"additional_executables_destination_path": "",
"additional_executables_list": "",
"additional_registry_images": "false",
"additional_registry_images_list": "",
"additional_url_images": "false",
"additional_url_images_list": "",
"load_additional_components": "false"
}

View File

@ -0,0 +1,5 @@
{
"ansible_common_ssh_args": "-o IdentitiesOnly=yes -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa",
"ansible_common_vars": "containerd_url={{user `containerd_url`}} containerd_sha256={{user `containerd_sha256`}} pause_image={{user `pause_image`}} containerd_additional_settings={{user `containerd_additional_settings`}} containerd_cri_socket={{user `containerd_cri_socket`}} containerd_version={{user `containerd_version`}} containerd_wasm_shims_url={{user `containerd_wasm_shims_url`}} containerd_wasm_shims_version={{user `containerd_wasm_shims_version`}} containerd_wasm_shims_sha256={{user `containerd_wasm_shims_sha256`}} containerd_wasm_shims_runtimes=\"{{user `containerd_wasm_shims_runtimes`}}\" crictl_url={{user `crictl_url`}} crictl_sha256={{user `crictl_sha256`}} crictl_source_type={{user `crictl_source_type`}} custom_role_names=\"{{user `custom_role_names`}}\" firstboot_custom_roles_pre=\"{{user `firstboot_custom_roles_pre`}}\" firstboot_custom_roles_post=\"{{user `firstboot_custom_roles_post`}}\" node_custom_roles_pre=\"{{user `node_custom_roles_pre`}}\" node_custom_roles_post=\"{{user `node_custom_roles_post`}}\" disable_public_repos={{user `disable_public_repos`}} extra_debs=\"{{user `extra_debs`}}\" extra_repos=\"{{user `extra_repos`}}\" extra_rpms=\"{{user `extra_rpms`}}\" http_proxy={{user `http_proxy`}} https_proxy={{user `https_proxy`}} kubeadm_template={{user `kubeadm_template`}} kubernetes_cni_http_source={{user `kubernetes_cni_http_source`}} kubernetes_cni_http_checksum={{user `kubernetes_cni_http_checksum`}} kubernetes_http_source={{user `kubernetes_http_source`}} kubernetes_container_registry={{user `kubernetes_container_registry`}} kubernetes_rpm_repo={{user `kubernetes_rpm_repo`}} kubernetes_rpm_gpg_key={{user `kubernetes_rpm_gpg_key`}} kubernetes_rpm_gpg_check={{user `kubernetes_rpm_gpg_check`}} kubernetes_deb_repo={{user `kubernetes_deb_repo`}} kubernetes_deb_gpg_key={{user `kubernetes_deb_gpg_key`}} kubernetes_cni_deb_version={{user `kubernetes_cni_deb_version`}} kubernetes_cni_rpm_version={{user `kubernetes_cni_rpm_version`}} kubernetes_cni_semver={{user `kubernetes_cni_semver`}} kubernetes_cni_source_type={{user `kubernetes_cni_source_type`}} kubernetes_semver={{user `kubernetes_semver`}} kubernetes_source_type={{user `kubernetes_source_type`}} kubernetes_load_additional_imgs={{user `kubernetes_load_additional_imgs`}} kubernetes_deb_version={{user `kubernetes_deb_version`}} kubernetes_rpm_version={{user `kubernetes_rpm_version`}} no_proxy={{user `no_proxy`}} pip_conf_file={{user `pip_conf_file`}} python_path={{user `python_path`}} redhat_epel_rpm={{user `redhat_epel_rpm`}} epel_rpm_gpg_key={{user `epel_rpm_gpg_key`}} reenable_public_repos={{user `reenable_public_repos`}} remove_extra_repos={{user `remove_extra_repos`}} systemd_prefix={{user `systemd_prefix`}} sysusr_prefix={{user `sysusr_prefix`}} sysusrlocal_prefix={{user `sysusrlocal_prefix`}} load_additional_components={{ user `load_additional_components`}} additional_registry_images={{ user `additional_registry_images`}} additional_registry_images_list={{ user `additional_registry_images_list`}} additional_url_images={{ user `additional_url_images`}} additional_url_images_list={{ user `additional_url_images_list`}} additional_executables={{ user `additional_executables`}} additional_executables_list={{ user `additional_executables_list`}} additional_executables_destination_path={{ user `additional_executables_destination_path`}} build_target={{ user `build_target`}} amazon_ssm_agent_rpm={{ user `amazon_ssm_agent_rpm` }}",
"ansible_scp_extra_args": "{{env `ANSIBLE_SCP_EXTRA_ARGS`}}"
}

9
packer/config/cni.json Normal file
View File

@ -0,0 +1,9 @@
{
"kubernetes_cni_deb_version": "1.2.0-00",
"kubernetes_cni_http_checksum": "sha256:https://storage.googleapis.com/k8s-artifacts-cni/release/v1.2.0/cni-plugins-linux-{{user `kubernetes_cni_http_checksum_arch`}}-v1.2.0.tgz.sha256",
"kubernetes_cni_http_checksum_arch": "amd64",
"kubernetes_cni_http_source": "https://github.com/containernetworking/plugins/releases/download",
"kubernetes_cni_rpm_version": "1.2.0-0",
"kubernetes_cni_semver": "v1.2.0",
"kubernetes_cni_source_type": "pkg"
}

19
packer/config/common.json Normal file
View File

@ -0,0 +1,19 @@
{
"build_target": "virt",
"disable_public_repos": "false",
"extra_debs": "",
"extra_repos": "",
"extra_rpms": "",
"firstboot_custom_roles_post": "",
"firstboot_custom_roles_pre": "",
"http_proxy": "",
"https_proxy": "",
"no_proxy": "",
"node_custom_roles_post": "",
"node_custom_roles_pre": "",
"pause_image": "registry.k8s.io/pause:3.9",
"pip_conf_file": "",
"redhat_epel_rpm": "https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm",
"reenable_public_repos": "true",
"remove_extra_repos": "false"
}

View File

@ -0,0 +1,7 @@
{
"containerd_additional_settings": null,
"containerd_cri_socket": "/var/run/containerd/containerd.sock",
"containerd_sha256": "152c8479fc0054db63ff0175fea014da227279b8d3dcab5f2f4b4876317ffe26",
"containerd_sha256_windows": "5b723eb58f7678a63928ec6eadc4a837d52a727e264f365a888d1ee97046bc7f",
"containerd_version": "1.6.15"
}

View File

@ -0,0 +1,15 @@
{
"goss_arch": "amd64",
"goss_download_path": "",
"goss_entry_file": "goss/goss.yaml",
"goss_format": "json",
"goss_format_options": "pretty",
"goss_inspect_mode": "true",
"goss_remote_folder": "",
"goss_remote_path": "",
"goss_skip_install": "false",
"goss_tests_dir": "packer/goss",
"goss_url": "",
"goss_vars_file": "packer/goss/goss-vars.yaml",
"goss_version": "0.3.16"
}

View File

@ -0,0 +1,25 @@
{
"crictl_arch": "amd64",
"crictl_sha256": "https://github.com/kubernetes-sigs/cri-tools/releases/download/v{{user `crictl_version`}}/crictl-v{{user `crictl_version`}}-linux-{{user `crictl_arch`}}.tar.gz.sha256",
"crictl_source_type": "pkg",
"crictl_url": "https://github.com/kubernetes-sigs/cri-tools/releases/download/v{{user `crictl_version`}}/crictl-v{{user `crictl_version`}}-linux-{{user `crictl_arch`}}.tar.gz",
"crictl_version": "1.26.0",
"kubeadm_template": "etc/kubeadm.yml",
"kubernetes_container_registry": "registry.k8s.io",
"kubernetes_deb_gpg_key": "https://packages.cloud.google.com/apt/doc/apt-key.gpg",
"kubernetes_deb_repo": "\"https://apt.kubernetes.io/ kubernetes-xenial\"",
"kubernetes_deb_version": "1.23.15-00",
"kubernetes_http_source": "https://dl.k8s.io/release",
"kubernetes_load_additional_imgs": "false",
"kubernetes_rpm_gpg_check": "True",
"kubernetes_rpm_gpg_key": "\"https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg\"",
"kubernetes_rpm_repo": "https://packages.cloud.google.com/yum/repos/kubernetes-el7-{{user `kubernetes_rpm_repo_arch`}}",
"kubernetes_rpm_repo_arch": "x86_64",
"kubernetes_rpm_version": "1.23.15-0",
"kubernetes_semver": "v1.23.15",
"kubernetes_series": "v1.23",
"kubernetes_source_type": "pkg",
"systemd_prefix": "/usr/lib/systemd",
"sysusr_prefix": "/usr",
"sysusrlocal_prefix": "/usr/local"
}

View File

@ -0,0 +1,3 @@
{
"kubernetes_cni_http_checksum_arch": "ppc64le"
}

View File

@ -0,0 +1,3 @@
{
"build_target": "raw"
}

View File

@ -0,0 +1,5 @@
{
"containerd_sha256": "49e46a2b8a1fe8b0406e49d745c955b91360f1d024063e0dbe0d9b9873649631",
"containerd_url": "https://oplab9.parqtec.unicamp.br/pub/ppc64el/containerd-cri/containerd-cri-{{user `containerd_version`}}/cri-containerd-cni-{{user `containerd_version`}}-linux-ppc64le.tar.gz",
"containerd_version": "1.6.2"
}

View File

@ -0,0 +1,4 @@
{
"crictl_arch": "ppc64le",
"kubernetes_rpm_repo_arch": "ppc64le"
}

View File

@ -0,0 +1,6 @@
{
"containerd_wasm_shims_runtimes": "",
"containerd_wasm_shims_sha256": "da84b1c065a58f95a841d39e143cd7115d43e6faedcce7a8782f2942388260d7",
"containerd_wasm_shims_url": "https://github.com/deislabs/containerd-wasm-shims/releases/download/{{user `containerd_wasm_shims_version`}}/containerd-wasm-shims-v1-linux-x86_64.tar.gz",
"containerd_wasm_shims_version": "v0.3.3"
}

View File

@ -0,0 +1,4 @@
# See the OWNERS docs at https://go.k8s.io/owners
approvers:
- image-builder-windows-maintainers

View File

@ -0,0 +1,3 @@
{
"ansible_common_vars": "runtime={{user `runtime`}} docker_ee_version={{user `docker_ee_version`}} containerd_url={{user `containerd_url`}} containerd_sha256={{user `containerd_sha256_windows`}} pause_image={{user `pause_image`}} additional_debug_files=\"{{user `additional_debug_files`}}\" containerd_additional_settings={{user `containerd_additional_settings`}} custom_role_names=\"{{user `custom_role_names`}}\" http_proxy={{user `http_proxy`}} https_proxy={{user `https_proxy`}} no_proxy={{user `no_proxy`}} kubernetes_base_url={{user `kubernetes_base_url`}} kubernetes_semver={{user `kubernetes_semver`}} kubernetes_install_path={{user `kubernetes_install_path`}} cloudbase_init_url=\"{{user `cloudbase_init_url`}}\" cloudbase_plugins=\"{{user `cloudbase_plugins`}}\" cloudbase_metadata_services=\"{{user `cloudbase_metadata_services`}}\" cloudbase_plugins_unattend=\"{{user `cloudbase_plugins_unattend`}}\" cloudbase_metadata_services_unattend=\"{{user `cloudbase_metadata_services_unattend`}}\" prepull={{user `prepull`}} wins_url={{user `wins_url`}} windows_updates_kbs=\"{{user `windows_updates_kbs`}}\" windows_updates_categories=\"{{user `windows_updates_categories`}}\" windows_service_manager={{user `windows_service_manager`}} nssm_url={{user `nssm_url`}} distribution_version={{user `distribution_version`}} netbios_host_name_compatibility={{user `netbios_host_name_compatibility`}} disable_hypervisor={{ user `disable_hypervisor` }} cloudbase_logging_serial_port={{ user `cloudbase_logging_serial_port` }} load_additional_components={{ user `load_additional_components`}} additional_registry_images={{ user `additional_registry_images`}} additional_registry_images_list={{ user `additional_registry_images_list`}} additional_url_images={{ user `additional_url_images`}} additional_url_images_list={{ user `additional_url_images_list`}} additional_executables={{ user `additional_executables`}} additional_executables_list={{ user `additional_executables_list`}} additional_executables_destination_path={{ user `additional_executables_destination_path`}} ssh_source_url={{user `ssh_source_url` }} debug_tools={{user `debug_tools`}}"
}

View File

@ -0,0 +1,3 @@
{
"cloudbase_init_version": "1.1.2"
}

View File

@ -0,0 +1,17 @@
{
"additional_debug_files": "",
"debug_tools": "true",
"disable_hypervisor": "false",
"http_proxy": "",
"https_proxy": "",
"netbios_host_name_compatibility": "true",
"no_proxy": "",
"nssm_url": "https://upstreamartifacts.azureedge.net/nssm/nssm.exe",
"prepull": "true",
"runtime": "docker-ee",
"ssh_source_url": "",
"windows_service_manager": "nssm",
"windows_updates_categories": "",
"windows_updates_kbs": "",
"wins_version": "0.0.4"
}

View File

@ -0,0 +1,4 @@
{
"containerd_additional_settings": null,
"containerd_url": "https://github.com/containerd/containerd/releases/download/v{{user `containerd_version`}}/containerd-{{user `containerd_version`}}-windows-amd64.tar.gz"
}

View File

@ -0,0 +1,3 @@
{
"docker_ee_version": "19.03.12"
}

View File

@ -0,0 +1,4 @@
{
"kubernetes_goarch": "amd64",
"kubernetes_install_path": "c:\\k"
}

View File

@ -0,0 +1,6 @@
# See the OWNERS docs at https://go.k8s.io/owners
approvers:
- cluster-api-digitalocean-maintainers
reviewers:
- cluster-api-digitalocean-maintainers

View File

@ -0,0 +1,5 @@
{
"build_name": "centos-7",
"snapshot_name_suffix": "on CentOS 7",
"source_image": "centos-7-x64"
}

View File

@ -0,0 +1,95 @@
{
"builders": [
{
"api_token": "{{ user `access_token` }}",
"image": "{{ user `source_image` }}",
"name": "{{user `build_name`}}",
"region": "{{ user `region` }}",
"size": "{{ user `size` }}",
"snapshot_name": "Cluster API Kubernetes {{ user `kubernetes_semver` }} {{ user `snapshot_name_suffix` }}",
"snapshot_regions": [
"nyc1"
],
"ssh_username": "root",
"tags": [
"cluster-api-{{ user `build_name` }}:{{ user `kubernetes_semver` | replace_all `.` `-` }}"
],
"type": "digitalocean"
}
],
"provisioners": [
{
"environment_vars": [
"BUILD_NAME={{user `build_name`}}"
],
"inline": [
"if [ $BUILD_NAME != \"ubuntu-1804\" ]; then exit 0; fi",
"while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done",
"sudo apt-get -qq update && sudo DEBIAN_FRONTEND=noninteractive apt-get -qqy install python python-pip"
],
"type": "shell"
},
{
"environment_vars": [
"BUILD_NAME={{user `build_name`}}"
],
"inline": [
"if [ $BUILD_NAME != \"ubuntu-2004\" ]; then exit 0; fi",
"while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done",
"sudo apt-get -qq update"
],
"type": "shell"
},
{
"ansible_env_vars": [
"ANSIBLE_SSH_ARGS='{{user `existing_ansible_ssh_args`}} {{user `ansible_common_ssh_args`}}'"
],
"extra_arguments": [
"--extra-vars",
"{{user `ansible_common_vars`}}",
"--extra-vars",
"{{user `ansible_extra_vars`}}",
"--extra-vars",
"{{user `ansible_user_vars`}}",
"--scp-extra-args",
"{{user `ansible_scp_extra_args`}}"
],
"playbook_file": "./ansible/node.yml",
"type": "ansible",
"user": "packer"
}
],
"variables": {
"access_token": "{{env `DIGITALOCEAN_ACCESS_TOKEN`}}",
"ansible_common_vars": "",
"ansible_extra_vars": "",
"ansible_scp_extra_args": "",
"build_timestamp": "{{timestamp}}",
"containerd_sha256": null,
"containerd_url": "https://github.com/containerd/containerd/releases/download/v{{user `containerd_version`}}/cri-containerd-cni-{{user `containerd_version`}}-linux-amd64.tar.gz",
"containerd_version": null,
"crictl_url": "https://github.com/kubernetes-sigs/cri-tools/releases/download/v{{user `crictl_version`}}/crictl-v{{user `crictl_version`}}-linux-amd64.tar.gz",
"crictl_version": null,
"existing_ansible_ssh_args": "{{env `ANSIBLE_SSH_ARGS`}}",
"kubernetes_cni_deb_version": null,
"kubernetes_cni_http_source": null,
"kubernetes_cni_rpm_version": null,
"kubernetes_cni_semver": null,
"kubernetes_cni_source_type": null,
"kubernetes_container_registry": null,
"kubernetes_deb_gpg_key": null,
"kubernetes_deb_repo": null,
"kubernetes_deb_version": null,
"kubernetes_http_source": null,
"kubernetes_load_additional_imgs": null,
"kubernetes_rpm_gpg_check": null,
"kubernetes_rpm_gpg_key": null,
"kubernetes_rpm_repo": null,
"kubernetes_rpm_version": null,
"kubernetes_semver": null,
"kubernetes_series": null,
"kubernetes_source_type": null,
"region": "nyc1",
"size": "s-1vcpu-1gb"
}
}

View File

@ -0,0 +1,5 @@
{
"build_name": "ubuntu-1804",
"snapshot_name_suffix": "on Ubuntu 18.04",
"source_image": "ubuntu-18-04-x64"
}

View File

@ -0,0 +1,5 @@
{
"build_name": "ubuntu-2004",
"snapshot_name_suffix": "on Ubuntu 20.04",
"source_image": "ubuntu-20-04-x64"
}

View File

@ -0,0 +1,42 @@
# Flatcar-Related Build Files
This directory contains files needed for building Flatcar Container Linux CAPI images.
The following subdirectories exist:
- `clc` - contains [Container Linux Config][1] files.
- `ignition` - contains [Ignition][2] files generated from the CLC files in the `clc` directory.
- `scripts` - contains scripts which are used by the various Flatcar builds.
## Ignition Files
Some Flatcar builds (e.g. QEMU) require Ignition files during OS installation. These files can be
consumed directly from the `ignition` directory. Ignition files are generated from CLC files by the
[Container Linux Config Transpiler][3].
### Adding New Files
To add a new Ignition file, do the following:
1. Place a CLC YAML file with the desired config in `clc`.
1. Add the name of the file without an extension to the `ignition_files` variable under the
`gen-ignition` target in the [Makefile](../../../Makefile). For example, for a CLC file named
`foo.yaml`, add `foo` to the Make target.
1. Run `make gen-ignition` under `images/capi`. A new Ignition file is generated under `ignition`.
1. Commit both the CLC file and the resulting Ignition file and open a PR to merge the changes.
Once the changes are merged, the new Ignition file can be referenced in Flatcar builds and consumed
as a raw file directly from GitHub.
### Changing Existing Files
To change an existing Ignition file, do the following:
1. Edit the relevant CLC YAML file in `clc`.
1. Run `make gen-ignition` under `images/capi`. The corresponding Ignition file is updated under
`ignition`.
1. Commit the changes and open a PR to merge them.
[1]: https://flatcar.org/docs/latest/provisioning/cl-config/
[2]: https://flatcar.org/docs/latest/provisioning/ignition/
[3]: https://flatcar.org/docs/latest/provisioning/config-transpiler/

View File

@ -0,0 +1,26 @@
# This file is used for initial provisioning of a Flatcar machine, before Packer provisioners (e.g.
# Ansible) are executed.
passwd:
users:
- name: builder
# "BUILDERPASSWORDHASH" gets overwritten by Packer on platforms where SSH password auth is used.
password_hash: BUILDERPASSWORDHASH
# "BUILDERSSHAUTHKEY" gets overwritten by Packer on platforms where SSH key auth is used.
# TODO: Once https://github.com/kubernetes-sigs/image-builder/pull/882 is merged we can remove
# the ssh_authorized_keys key altogether since the QEMU and raw targets would be using password
# auth and the rest of the targets have provider-specific authorization mechanisms, meaning SSH
# keys don't have to be specified in this CLC file.
ssh_authorized_keys: ["BUILDERSSHAUTHKEY"]
groups:
- wheel
- sudo
- docker
systemd:
units:
- name: docker.service
enable: true
# Mask update-engine and locksmithd to disable automatic updates during image creation.
- name: update-engine.service
mask: true
- name: locksmithd.service
mask: true

View File

@ -0,0 +1,44 @@
{
"ignition": {
"config": {},
"security": {
"tls": {}
},
"timeouts": {},
"version": "2.3.0"
},
"networkd": {},
"passwd": {
"users": [
{
"groups": [
"wheel",
"sudo",
"docker"
],
"name": "builder",
"passwordHash": "BUILDERPASSWORDHASH",
"sshAuthorizedKeys": [
"BUILDERSSHAUTHKEY"
]
}
]
},
"storage": {},
"systemd": {
"units": [
{
"enable": true,
"name": "docker.service"
},
{
"mask": true,
"name": "update-engine.service"
},
{
"mask": true,
"name": "locksmithd.service"
}
]
}
}

View File

@ -0,0 +1,45 @@
#!/usr/bin/env bash
#
# This script installs PyPy as a Python interpreter on a Flatcar instance.
set -o errexit
set -o nounset
set -o pipefail
[[ -n ${DEBUG:-} ]] && set -o xtrace
BINDIR="/opt/bin"
BUILDER_ENV="/opt/bin/builder-env"
set -x
mkdir -p ${BINDIR}
cd ${BINDIR}
if [[ -e ${BINDIR}/.bootstrapped ]]; then
exit 0
fi
PYPY_VERSION=7.2.0
PYTHON3_VERSION=3.6
curl -sfL https://github.com/squeaky-pl/portable-pypy/releases/download/pypy-${PYPY_VERSION}/pypy-${PYPY_VERSION}-linux_x86_64-portable.tar.bz2 | tar -xjf -
mv -n pypy-${PYPY_VERSION}-linux_x86_64-portable pypy2
ln -s ./pypy2/bin/pypy python2
ln -s ./pypy2/bin/pypy python
curl -sfL https://github.com/squeaky-pl/portable-pypy/releases/download/pypy${PYTHON3_VERSION}-${PYPY_VERSION}/pypy${PYTHON3_VERSION}-${PYPY_VERSION}-linux_x86_64-portable.tar.bz2 | tar -xjf -
mv -n pypy${PYTHON3_VERSION}-${PYPY_VERSION}-linux_x86_64-portable pypy3
ln -s ./pypy3/bin/pypy3 python3
${BINDIR}/python --version
${BINDIR}/pypy2/bin/virtualenv-pypy ${BUILDER_ENV}
chown -R core ${BUILDER_ENV}
ln -s builder-env/bin/pip ${BINDIR}/pip
# need to have symlink pip3 required by ansible/roles/providers/tasks/aws.yml
ln -s builder-env/bin/pip ${BINDIR}/pip3
touch ${BINDIR}/.bootstrapped

4
packer/gce/OWNERS Normal file
View File

@ -0,0 +1,4 @@
# See the OWNERS docs at https://go.k8s.io/owners
approvers:
- cluster-api-gcp-maintainers

View File

@ -0,0 +1,5 @@
## Configs for nightly builds
The configurations in the directory is being used for the nightly job to build the images for GCE.
The script that runs is [ci-gce-nightly.sh](../../../../scripts/ci-gce-nightly.sh)

View File

@ -0,0 +1,8 @@
{
"build_timestamp": "nightly",
"kubernetes_deb_version": "1.23.15-00",
"kubernetes_rpm_version": "1.23.15-0",
"kubernetes_semver": "v1.23.15",
"kubernetes_series": "v1.23",
"service_account_email": "gcb-builder-cluster-api-gcp@k8s-staging-cluster-api-gcp.iam.gserviceaccount.com"
}

View File

@ -0,0 +1,8 @@
{
"build_timestamp": "nightly",
"kubernetes_deb_version": "1.24.9-00",
"kubernetes_rpm_version": "1.24.9-0",
"kubernetes_semver": "v1.24.9",
"kubernetes_series": "v1.24",
"service_account_email": "gcb-builder-cluster-api-gcp@k8s-staging-cluster-api-gcp.iam.gserviceaccount.com"
}

View File

@ -0,0 +1,8 @@
{
"build_timestamp": "nightly",
"kubernetes_deb_version": "1.25.5-00",
"kubernetes_rpm_version": "1.25.5-0",
"kubernetes_semver": "v1.25.5",
"kubernetes_series": "v1.25",
"service_account_email": "gcb-builder-cluster-api-gcp@k8s-staging-cluster-api-gcp.iam.gserviceaccount.com"
}

View File

@ -0,0 +1,8 @@
{
"build_timestamp": "nightly",
"kubernetes_deb_version": "1.26.0-00",
"kubernetes_rpm_version": "1.26.0-0",
"kubernetes_semver": "v1.26.0",
"kubernetes_series": "v1.26",
"service_account_email": "gcb-builder-cluster-api-gcp@k8s-staging-cluster-api-gcp.iam.gserviceaccount.com"
}

126
packer/gce/packer.json Normal file
View File

@ -0,0 +1,126 @@
{
"builders": [
{
"disable_default_service_account": "{{ user `disable_default_service_account` }}",
"image_family": "{{user `image_family` | clean_resource_name}}",
"image_name": "{{user `image_name` | clean_resource_name}}",
"labels": {
"build_timestamp": "{{user `build_timestamp`}}",
"distribution": "ubuntu",
"distribution_release": "{{user `distribution_release`}}",
"distribution_version": "{{user `distribution_version`}}",
"kubernetes_version": "{{user `kubernetes_semver` | clean_resource_name}}"
},
"machine_type": "{{ user `machine_type` }}",
"name": "{{user `build_name`}}",
"project_id": "{{ user `project_id` }}",
"service_account_email": "{{ user `service_account_email` }}",
"source_image_family": "{{ user `source_image_family` }}",
"ssh_username": "ubuntu",
"type": "googlecompute",
"use_internal_ip": "{{ user `use_internal_ip`}}",
"zone": "{{ user `zone` }}"
}
],
"provisioners": [
{
"environment_vars": [
"BUILD_NAME={{user `build_name`}}"
],
"inline": [
"if [ $BUILD_NAME != \"ubuntu-1804\" ] || [ $BUILD_NAME != \"ubuntu-2004\" ]; then exit 0; fi",
"while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done",
"sudo apt-get -qq update && sudo DEBIAN_FRONTEND=noninteractive apt-get -qqy install python python-pip"
],
"type": "shell"
},
{
"ansible_env_vars": [
"ANSIBLE_SSH_ARGS='{{user `existing_ansible_ssh_args`}} {{user `ansible_common_ssh_args`}}'"
],
"extra_arguments": [
"--extra-vars",
"{{user `ansible_common_vars`}}",
"--extra-vars",
"{{user `ansible_extra_vars`}}",
"--scp-extra-args",
"{{user `ansible_scp_extra_args`}}"
],
"playbook_file": "./ansible/node.yml",
"type": "ansible"
},
{
"arch": "{{user `goss_arch`}}",
"download_path": "{{user `goss_download_path`}}",
"format": "{{user `goss_format`}}",
"format_options": "{{user `goss_format_options`}}",
"goss_file": "{{user `goss_entry_file`}}",
"inspect": "{{user `goss_inspect_mode`}}",
"remote_folder": "{{user `goss_remote_folder`}}",
"remote_path": "{{user `goss_remote_path`}}",
"skip_install": "{{user `goss_skip_install`}}",
"tests": [
"{{user `goss_tests_dir`}}"
],
"type": "goss",
"url": "{{user `goss_url`}}",
"use_sudo": true,
"vars_file": "{{user `goss_vars_file`}}",
"vars_inline": {
"ARCH": "amd64",
"OS": "ubuntu",
"PROVIDER": "gcp",
"containerd_version": "{{user `containerd_version`}}",
"kubernetes_cni_deb_version": "{{ user `kubernetes_cni_deb_version` }}",
"kubernetes_cni_rpm_version": "{{ split (user `kubernetes_cni_rpm_version`) \"-\" 0 }}",
"kubernetes_cni_source_type": "{{user `kubernetes_cni_source_type`}}",
"kubernetes_cni_version": "{{user `kubernetes_cni_semver` | replace \"v\" \"\" 1}}",
"kubernetes_deb_version": "{{ user `kubernetes_deb_version` }}",
"kubernetes_rpm_version": "{{ split (user `kubernetes_rpm_version`) \"-\" 0 }}",
"kubernetes_source_type": "{{user `kubernetes_source_type`}}",
"kubernetes_version": "{{user `kubernetes_semver` | replace \"v\" \"\" 1}}"
},
"version": "{{user `goss_version`}}"
}
],
"variables": {
"ansible_common_vars": "",
"ansible_extra_vars": "",
"ansible_scp_extra_args": "",
"build_timestamp": "{{timestamp}}",
"containerd_sha256": null,
"containerd_url": "https://github.com/containerd/containerd/releases/download/v{{user `containerd_version`}}/cri-containerd-cni-{{user `containerd_version`}}-linux-amd64.tar.gz",
"containerd_version": null,
"crictl_url": "https://github.com/kubernetes-sigs/cri-tools/releases/download/v{{user `crictl_version`}}/crictl-v{{user `crictl_version`}}-linux-amd64.tar.gz",
"crictl_version": null,
"disable_default_service_account": "",
"encrypted": "false",
"existing_ansible_ssh_args": "{{env `ANSIBLE_SSH_ARGS`}}",
"image_family": "capi-{{user `build_name`}}-k8s-{{user `kubernetes_series`}}",
"image_name": "cluster-api-{{user `build_name`}}-{{user `kubernetes_semver`}}-{{user `build_timestamp`}}",
"kubernetes_cni_deb_version": null,
"kubernetes_cni_http_source": null,
"kubernetes_cni_rpm_version": null,
"kubernetes_cni_semver": null,
"kubernetes_cni_source_type": null,
"kubernetes_container_registry": null,
"kubernetes_deb_gpg_key": null,
"kubernetes_deb_repo": null,
"kubernetes_deb_version": null,
"kubernetes_http_source": null,
"kubernetes_load_additional_imgs": null,
"kubernetes_rpm_gpg_check": null,
"kubernetes_rpm_gpg_key": null,
"kubernetes_rpm_repo": null,
"kubernetes_rpm_version": null,
"kubernetes_semver": null,
"kubernetes_series": null,
"kubernetes_source_type": null,
"machine_type": "n1-standard-1",
"project_id": "{{env `GCP_PROJECT_ID`}}",
"service_account_email": "",
"source_image_family": "{{user `build_name`}}-lts",
"use_internal_ip": "false",
"zone": null
}
}

Some files were not shown because too many files have changed in this diff Show More