generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Windows 2019/2022 to OCI capi provider image builder
- Loading branch information
Showing
17 changed files
with
439 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
{ | ||
"builders": [ | ||
{ | ||
"availability_domain": "{{user `availability_domain`}}", | ||
"base_image_filter": { | ||
"operating_system": "{{user `operating_system`}}", | ||
"operating_system_version": "{{user `operating_system_version`}}" | ||
}, | ||
"base_image_ocid": "{{user `base_image_ocid`}}", | ||
"communicator": "winrm", | ||
"compartment_ocid": "{{user `compartment_ocid`}}", | ||
"image_name": "cluster-api-{{user `build_name`}}-{{user `kubernetes_semver`}}-{{user `build_timestamp`}}", | ||
"shape": "{{user `shape`}}", | ||
"shape_config": { | ||
"ocpus": "{{user `ocpus`}}" | ||
}, | ||
"subnet_ocid": "{{user `subnet_ocid`}}", | ||
"tenancy_ocid": "{{user `tenancy_ocid`}}", | ||
"type": "oracle-oci", | ||
"user_data_file": "packer/oci/scripts/winrm_bootstrap.txt", | ||
"user_ocid": "{{user `user_ocid`}}", | ||
"winrm_insecure": true, | ||
"winrm_password": "{{user `opc_user_password`}}", | ||
"winrm_port": 5986, | ||
"winrm_timeout": "10m", | ||
"winrm_use_ntlm": true, | ||
"winrm_use_ssl": true, | ||
"winrm_username": "opc" | ||
} | ||
], | ||
"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": "opc", | ||
"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`}}" | ||
], | ||
"max_retries": 5, | ||
"pause_before": "15s", | ||
"playbook_file": "ansible/windows/node_windows.yml", | ||
"type": "ansible", | ||
"use_proxy": false, | ||
"user": "opc" | ||
}, | ||
{ | ||
"restart_timeout": "10m", | ||
"type": "windows-restart" | ||
}, | ||
{ | ||
"destination": "C:\\Users\\opc\\", | ||
"source": "./packer/oci/scripts/sysprep.ps1", | ||
"type": "file" | ||
}, | ||
{ | ||
"destination": "C:\\Users\\opc\\", | ||
"source": "./packer/oci/scripts/attach_secondary_vnic.ps1", | ||
"type": "file" | ||
}, | ||
{ | ||
"destination": "C:\\Windows\\Setup\\Scripts\\", | ||
"source": "./packer/oci/scripts/enable_second_nic.ps1", | ||
"type": "file" | ||
}, | ||
{ | ||
"inline": [ | ||
"rm -Force -Recurse C:\\var\\log\\kubelet\\*" | ||
], | ||
"type": "powershell" | ||
}, | ||
{ | ||
"elevated_password": "{{.WinRMPassword}}", | ||
"elevated_user": "opc", | ||
"inline": [ | ||
"C:\\Users\\opc\\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`}}", | ||
"build_name": null, | ||
"build_timestamp": "{{timestamp}}", | ||
"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": "COM1,9600,N,8", | ||
"cloudbase_metadata_services": "cloudbaseinit.metadata.services.httpservice.HttpService", | ||
"cloudbase_metadata_services_unattend": "cloudbaseinit.metadata.services.httpservice.HttpService", | ||
"cloudbase_plugins": "cloudbaseinit.plugins.common.ephemeraldisk.EphemeralDiskPlugin, cloudbaseinit.plugins.common.mtu.MTUPlugin, cloudbaseinit.plugins.common.sethostname.SetHostNamePlugin", | ||
"cloudbase_plugins_unattend": "cloudbaseinit.plugins.common.mtu.MTUPlugin", | ||
"containerd_url": "", | ||
"containerd_version": null, | ||
"ib_version": "{{env `IB_VERSION`}}", | ||
"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, | ||
"ocpus": "2", | ||
"opc_user_password": "{{env `OPC_USER_PASSWORD`}}", | ||
"prepull": null, | ||
"private_virtual_network_with_public_ip": "", | ||
"runtime": "containerd", | ||
"shape": "VM.Standard.E4.Flex", | ||
"virtual_network_name": "", | ||
"virtual_network_resource_group_name": "", | ||
"virtual_network_subnet_name": "", | ||
"vm_size": "", | ||
"windows_service_manager": null, | ||
"windows_updates_kbs": null, | ||
"wins_url": "", | ||
"wire_server_users": "" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
function Get-Second-Vnic-Ocid() { | ||
$ocid = "" | ||
$vnics = Invoke-RestMethod -Uri "http://169.254.169.254/opc/v1/vnics/" | ||
if ($vnics.Count -eq 2) { | ||
$ocid = $vnics[1].vnicId | ||
} else { | ||
Write-Host "vnics count not equal 2" | ||
} | ||
return $ocid | ||
} | ||
|
||
$vnicId = Get-Second-Vnic-Ocid | ||
Write-Host "found vnic id: ${vnicId}" | ||
|
||
|
||
$retryDelaySeconds = 30 | ||
# We should continue to retry indefinitely until the vnic is | ||
# detected by IMDS | ||
# https://docs.oracle.com/en-us/iaas/Content/Compute/Tasks/gettingmetadata.htm | ||
while($vnicId -eq "") { | ||
$vnicId = Get-Second-Vnic-Ocid | ||
Write-Host("Getting second vnic failed. Waiting " + $retryDelaySeconds + " seconds before next attempt.") | ||
Start-Sleep -Seconds $retryDelaySeconds | ||
} | ||
|
||
if ($vnicId -ne "") { | ||
Write-Host "Pulling down the secondary_vnic_windows_configure.ps1" | ||
Invoke-WebRequest -Uri "https://docs.oracle.com/en-us/iaas/Content/Resources/Assets/secondary_vnic_windows_configure.ps1" -OutFile "C:\Users\opc\secondary_vnic_windows_configure.ps1" | ||
|
||
Write-Host "calling script using ${vnicId}" | ||
|
||
, 'Y', 'A' | powershell "C:\Users\opc\secondary_vnic_windows_configure.ps1 ${vnicId}" | ||
Write-Error "secondary_vnic_windows_configure.ps1 - done" | ||
|
||
$ipconfig = ipconfig | ||
Write-Error "${ipconfig}" | ||
}else{ | ||
Write-Error "VNIC OCID is empty. Can't configure." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
$newNetAdapterName = "Ethernet 2" | ||
|
||
# check for two nics | ||
$netAdapters = Get-NetAdapter | ||
if ($netAdapters.Length -le 1) { | ||
Write-Output "Could not find multiple Network Adapters." | ||
Exit 1 | ||
} | ||
|
||
$secondNic = $netAdapters[1] | ||
|
||
# make sure the network adapter is known | ||
if ($secondNic.Name -ne "") { | ||
Write-Output "Changing ${secondNic.Name} to ${newNetAdapterName} ..." | ||
try | ||
{ | ||
Rename-NetAdapter -Name $secondNic.Name -NewName "${newNetAdapterName}" | ||
$secondNic.Name = $newNetAdapterName | ||
} | ||
catch | ||
{ | ||
Write-Output "Could not rename net adapter" | ||
Write-Output $_ | ||
} | ||
} else { | ||
Write-Output "Can not change network adapter named: ${secondNic.Name}" | ||
} | ||
|
||
# check that second is disabled | ||
if ($secondNic.Status -ne "up") { | ||
|
||
try | ||
{ | ||
Enable-NetAdapter -Name $secondNic.Name | ||
Write-Output "${secondNic.Name} enabled ..." | ||
} | ||
catch | ||
{ | ||
Write-Output "Could not enable net adapter" | ||
Write-Output $_ | ||
} | ||
} else { | ||
Write-Output "${secondNic.Name} already enabled ..." | ||
} | ||
|
||
Remove-Item -Path .\enable_second_nic.ps1 |
Oops, something went wrong.