Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add option to override the hostname for kubeadm #321

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions hostprocess/PrepareNode.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@ This script assists with joining a Windows node to a cluster.
.PARAMETER KubernetesVersion
Kubernetes version to download and use

.PARAMETER HostnameOverride
Overrides the hostname for kubeadm. Defaults to the value determined by the hostname command.

.EXAMPLE
PS> .\PrepareNode.ps1 -KubernetesVersion v1.25.3

#>

Param(
[parameter(Mandatory = $true, HelpMessage="Kubernetes version to use")]
[string] $KubernetesVersion
[string] $KubernetesVersion,
[parameter(HelpMessage="Hostname override for kubeadm")]
[string] $HostnameOverride = "$(hostname)"
)
$ErrorActionPreference = 'Stop'

Expand Down Expand Up @@ -63,7 +68,7 @@ New-Item -path C:\var\lib\kubelet\etc\kubernetes\pki -type SymbolicLink -value C
# dockershim related flags (--image-pull-progress-deadline=20m and --network-plugin=cni) are removed in k8s v1.24
# Link to changelog: https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.24.md

$cmd_commands=@("C:\k\kubelet.exe ", '$global:KubeletArgs ', '--cert-dir=$env:SYSTEMDRIVE\var\lib\kubelet\pki ', "--config=/var/lib/kubelet/config.yaml ", "--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf ", "--kubeconfig=/etc/kubernetes/kubelet.conf ", '--hostname-override=$(hostname) ', '--pod-infra-container-image=`"mcr.microsoft.com/oss/kubernetes/pause:3.6`" ', "--enable-debugging-handlers ", "--cgroups-per-qos=false ", '--enforce-node-allocatable=`"`" ', '--resolv-conf=`"`" ')
$cmd_commands=@("C:\k\kubelet.exe ", '$global:KubeletArgs ', '--cert-dir=$env:SYSTEMDRIVE\var\lib\kubelet\pki ', "--config=/var/lib/kubelet/config.yaml ", "--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf ", "--kubeconfig=/etc/kubernetes/kubelet.conf ", "--hostname-override=$HostnameOverride ", '--pod-infra-container-image=`"mcr.microsoft.com/oss/kubernetes/pause:3.6`" ', "--enable-debugging-handlers ", "--cgroups-per-qos=false ", '--enforce-node-allocatable=`"`" ', '--resolv-conf=`"`" ')
[version]$CurrentVersion = $($KubernetesVersion.Split("v") | Select -Index 1)
[version]$V1_24_Version = '1.24'
if ($CurrentVersion -lt $V1_24_Version) {
Expand Down