Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
98c0d15f
Unverified
Commit
98c0d15f
authored
Mar 01, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Mar 01, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #74762 from pjh/gce-windows-dump-versions
Dump Windows version information during cluster bringup.
parents
983cf51c
18a2a98d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
12 deletions
+38
-12
common.psm1
cluster/gce/windows/common.psm1
+14
-3
configure.ps1
cluster/gce/windows/configure.ps1
+7
-5
k8s-node-setup.psm1
cluster/gce/windows/k8s-node-setup.psm1
+16
-3
install-ssh.psm1
cluster/gce/windows/testonly/install-ssh.psm1
+1
-1
No files found.
cluster/gce/windows/common.psm1
View file @
98c0d15f
...
@@ -71,14 +71,13 @@ function ShouldWrite-File {
...
@@ -71,14 +71,13 @@ function ShouldWrite-File {
# Returns the GCE instance metadata value for $Key. If the key is not present
# Returns the GCE instance metadata value for $Key. If the key is not present
# in the instance metadata returns $Default if set, otherwise returns $null.
# in the instance metadata returns $Default if set, otherwise returns $null.
function
Get-InstanceMetadata
Value
{
function
Get-InstanceMetadata
{
param
(
param
(
[
parameter
(
Mandatory
=
$true
)]
[
string
]
$Key
,
[
parameter
(
Mandatory
=
$true
)]
[
string
]
$Key
,
[
parameter
(
Mandatory
=
$false
)]
[
string
]
$Default
[
parameter
(
Mandatory
=
$false
)]
[
string
]
$Default
)
)
$url
=
(
"http://metadata.google.internal/computeMetadata/v1/instance/"
+
$url
=
"http://metadata.google.internal/computeMetadata/v1/instance/
$Key
"
"attributes/
$Key
"
)
try
{
try
{
$client
=
New-Object
Net.WebClient
$client
=
New-Object
Net.WebClient
$client
.Headers.Add
(
'Metadata-Flavor'
,
'Google'
)
$client
.Headers.Add
(
'Metadata-Flavor'
,
'Google'
)
...
@@ -95,6 +94,18 @@ function Get-InstanceMetadataValue {
...
@@ -95,6 +94,18 @@ function Get-InstanceMetadataValue {
}
}
}
}
# Returns the GCE instance metadata value for $Key where key is an "attribute"
# of the instance. If the key is not present in the instance metadata returns
# $Default if set, otherwise returns $null.
function
Get-InstanceMetadataAttribute
{
param
(
[
parameter
(
Mandatory
=
$true
)]
[
string
]
$Key
,
[
parameter
(
Mandatory
=
$false
)]
[
string
]
$Default
)
return
Get-InstanceMetadata
"attributes/
$Key
"
$Default
}
function
Validate-SHA1
{
function
Validate-SHA1
{
param
(
param
(
[
parameter
(
Mandatory
=
$true
)]
[
string
]
$Hash
,
[
parameter
(
Mandatory
=
$true
)]
[
string
]
$Hash
,
...
...
cluster/gce/windows/configure.ps1
View file @
98c0d15f
...
@@ -33,9 +33,10 @@ $ErrorActionPreference = 'Stop'
...
@@ -33,9 +33,10 @@ $ErrorActionPreference = 'Stop'
[
Net.ServicePointManager]::SecurityProtocol
=
[
Net.SecurityProtocolType]::Tls12
[
Net.ServicePointManager]::SecurityProtocol
=
[
Net.SecurityProtocolType]::Tls12
$ProgressPreference
=
'SilentlyContinue'
$ProgressPreference
=
'SilentlyContinue'
# Returns the GCE instance metadata value for $Key. If the key is not present
# Returns the GCE instance metadata value for $Key where key is an "attribute"
# in the instance metadata returns $Default if set, otherwise returns $null.
# of the instance. If the key is not present in the instance metadata returns
function
Get-InstanceMetadataValue
{
# $Default if set, otherwise returns $null.
function
Get-InstanceMetadataAttribute
{
param
(
param
(
[
parameter
(
Mandatory
=
$true
)]
[
string
]
$Key
,
[
parameter
(
Mandatory
=
$true
)]
[
string
]
$Key
,
[
parameter
(
Mandatory
=
$false
)]
[
string
]
$Default
[
parameter
(
Mandatory
=
$false
)]
[
string
]
$Default
...
@@ -69,7 +70,7 @@ function FetchAndImport-ModuleFromMetadata {
...
@@ -69,7 +70,7 @@ function FetchAndImport-ModuleFromMetadata {
[
parameter
(
Mandatory
=
$true
)]
[
string
]
$Filename
[
parameter
(
Mandatory
=
$true
)]
[
string
]
$Filename
)
)
$module
=
Get-InstanceMetadata
Valu
e
$MetadataKey
$module
=
Get-InstanceMetadata
Attribut
e
$MetadataKey
if
(
Test-Path
C:\
$Filename
)
{
if
(
Test-Path
C:\
$Filename
)
{
if
(
-not
$REDO_STEPS
)
{
if
(
-not
$REDO_STEPS
)
{
Log-Output
"Skip: C:\
$Filename
already exists, not overwriting"
Log-Output
"Skip: C:\
$Filename
already exists, not overwriting"
...
@@ -87,7 +88,7 @@ try {
...
@@ -87,7 +88,7 @@ try {
# Don't use FetchAndImport-ModuleFromMetadata for common.psm1 - the common
# Don't use FetchAndImport-ModuleFromMetadata for common.psm1 - the common
# module includes variables and functions that any other function may depend
# module includes variables and functions that any other function may depend
# on.
# on.
$module
=
Get-InstanceMetadata
Valu
e
'common-psm1'
$module
=
Get-InstanceMetadata
Attribut
e
'common-psm1'
New-Item
-ItemType file -Force C:\common.psm1 | Out-Null
New-Item
-ItemType file -Force C:\common.psm1 | Out-Null
Set-Content
C:\common.psm1
$module
Set-Content
C:\common.psm1
$module
Import-Module -Force C:\common.psm1
Import-Module -Force C:\common.psm1
...
@@ -96,6 +97,7 @@ try {
...
@@ -96,6 +97,7 @@ try {
# then put these calls into a loop over a list of XYZ-psm1 keys.
# then put these calls into a loop over a list of XYZ-psm1 keys.
FetchAndImport-ModuleFromMetadata
'k8s-node-setup-psm1'
'k8s-node-setup.psm1'
FetchAndImport-ModuleFromMetadata
'k8s-node-setup-psm1'
'k8s-node-setup.psm1'
Dump-DebugInfoToConsole
Set
-PrerequisiteOptions
Set
-PrerequisiteOptions
$kube_env
=
Fetch-KubeEnv
$kube_env
=
Fetch-KubeEnv
Disable-WindowsDefender
Disable-WindowsDefender
...
...
cluster/gce/windows/k8s-node-setup.psm1
View file @
98c0d15f
...
@@ -134,6 +134,19 @@ function Add_GceMetadataServerRoute {
...
@@ -134,6 +134,19 @@ function Add_GceMetadataServerRoute {
}
}
}
}
# Writes debugging information, such as Windows version and patch info, to the
# console.
function
Dump-DebugInfoToConsole
{
Try
{
$version
=
"
$(
[
System.Environment]::OSVersion.Version |
Out-String
)
"
$hotfixes
=
"
$(
Get-Hotfix
|
Out-String
)
"
$image
=
"
$(
Get-InstanceMetadata
'image'
|
Out-String
)
"
Log-Output
"Windows version:
`n
$version
"
Log-Output
"Installed hotfixes:
`n
$hotfixes
"
Log-Output
"GCE Windows image:
`n
$image
"
}
Catch
{
}
}
# Fetches the kube-env from the instance metadata.
# Fetches the kube-env from the instance metadata.
#
#
# Returns: a PowerShell Hashtable object containing the key-value pairs from
# Returns: a PowerShell Hashtable object containing the key-value pairs from
...
@@ -141,7 +154,7 @@ function Add_GceMetadataServerRoute {
...
@@ -141,7 +154,7 @@ function Add_GceMetadataServerRoute {
function
Fetch-KubeEnv
{
function
Fetch-KubeEnv
{
# Testing / debugging:
# Testing / debugging:
# First:
# First:
# ${kube_env} = Get-InstanceMetadata
Valu
e 'kube-env'
# ${kube_env} = Get-InstanceMetadata
Attribut
e 'kube-env'
# or:
# or:
# ${kube_env} = [IO.File]::ReadAllText(".\kubeEnv.txt")
# ${kube_env} = [IO.File]::ReadAllText(".\kubeEnv.txt")
# ${kube_env_table} = ConvertFrom-Yaml ${kube_env}
# ${kube_env_table} = ConvertFrom-Yaml ${kube_env}
...
@@ -149,7 +162,7 @@ function Fetch-KubeEnv {
...
@@ -149,7 +162,7 @@ function Fetch-KubeEnv {
# ${kube_env_table}.GetType()
# ${kube_env_table}.GetType()
# The type of kube_env is a powershell String.
# The type of kube_env is a powershell String.
$kube_env
=
Get-InstanceMetadata
Valu
e
'kube-env'
$kube_env
=
Get-InstanceMetadata
Attribut
e
'kube-env'
$kube_env_table
=
ConvertFrom-Yaml
${
kube_env
}
$kube_env_table
=
ConvertFrom-Yaml
${
kube_env
}
return
${
kube_env_table
}
return
${
kube_env_table
}
}
}
...
@@ -888,7 +901,7 @@ function Configure-Kubelet {
...
@@ -888,7 +901,7 @@ function Configure-Kubelet {
# The Kubelet config is built by build-kubelet-config() in
# The Kubelet config is built by build-kubelet-config() in
# cluster/gce/util.sh, and stored in the metadata server under the
# cluster/gce/util.sh, and stored in the metadata server under the
# 'kubelet-config' key.
# 'kubelet-config' key.
$kubelet_config
=
Get-InstanceMetadata
Valu
e
'kubelet-config'
$kubelet_config
=
Get-InstanceMetadata
Attribut
e
'kubelet-config'
Set-Content
${
env
:KUBELET_CONFIG
}
$kubelet_config
Set-Content
${
env
:KUBELET_CONFIG
}
$kubelet_config
Log-Output
"Kubelet config:
`n
$(
Get-Content
-Raw
${
env
:KUBELET_CONFIG
})
"
Log-Output
"Kubelet config:
`n
$(
Get-Content
-Raw
${
env
:KUBELET_CONFIG
})
"
}
}
...
...
cluster/gce/windows/testonly/install-ssh.psm1
View file @
98c0d15f
...
@@ -112,7 +112,7 @@ function Setup_WriteSshKeysScript {
...
@@ -112,7 +112,7 @@ function Setup_WriteSshKeysScript {
# Fetch helper module for manipulating Windows user profiles.
# Fetch helper module for manipulating Windows user profiles.
if
(
ShouldWrite-File
$USER_PROFILE_MODULE
)
{
if
(
ShouldWrite-File
$USER_PROFILE_MODULE
)
{
$module
=
Get-InstanceMetadata
Valu
e
'user-profile-psm1'
$module
=
Get-InstanceMetadata
Attribut
e
'user-profile-psm1'
New-Item
-ItemType file -Force
$USER_PROFILE_MODULE
| Out-Null
New-Item
-ItemType file -Force
$USER_PROFILE_MODULE
| Out-Null
Set-Content
$USER_PROFILE_MODULE
$module
Set-Content
$USER_PROFILE_MODULE
$module
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment