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
621df2cd
Commit
621df2cd
authored
Feb 22, 2019
by
Peter Hornyack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable Windows Defender on Windows test nodes.
parent
fba3c54b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
20 deletions
+35
-20
common.psm1
cluster/gce/windows/common.psm1
+15
-0
configure.ps1
cluster/gce/windows/configure.ps1
+2
-13
k8s-node-setup.psm1
cluster/gce/windows/k8s-node-setup.psm1
+18
-7
No files found.
cluster/gce/windows/common.psm1
View file @
621df2cd
...
@@ -146,5 +146,20 @@ function MustDownload-File {
...
@@ -146,5 +146,20 @@ function MustDownload-File {
}
}
}
}
# Returns true if this node is part of a test cluster (see
# cluster/gce/config-test.sh). $KubeEnv is a hash table containing the kube-env
# metadata keys+values.
function
Test-IsTestCluster
{
param
(
[
parameter
(
Mandatory
=
$true
)]
[
hashtable]
$KubeEnv
)
if
(
$KubeEnv
.Contains
(
'TEST_CLUSTER'
)
-and
`
(
$KubeEnv
[
'TEST_CLUSTER'
]
-eq
'true'
))
{
return
$true
}
return
$false
}
# Export all public functions:
# Export all public functions:
Export-ModuleMember -Function
*
-
*
Export-ModuleMember -Function
*
-
*
cluster/gce/windows/configure.ps1
View file @
621df2cd
...
@@ -77,18 +77,6 @@ function FetchAndImport-ModuleFromMetadata {
...
@@ -77,18 +77,6 @@ function FetchAndImport-ModuleFromMetadata {
Import-Module -Force C:\
$Filename
Import-Module -Force C:\
$Filename
}
}
# Returns true if this node is part of a test cluster (see
# cluster/gce/config-test.sh).
#
# $kube_env must be set before calling this function.
function
Test-IsTestCluster
{
if
(
$kube_env
.Contains
(
'TEST_CLUSTER'
)
-and
`
(
$kube_env
[
'TEST_CLUSTER'
]
-eq
'true'
))
{
return
$true
}
return
$false
}
try
{
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
...
@@ -104,8 +92,9 @@ try {
...
@@ -104,8 +92,9 @@ try {
Set
-PrerequisiteOptions
Set
-PrerequisiteOptions
$kube_env
=
Fetch-KubeEnv
$kube_env
=
Fetch-KubeEnv
Disable-WindowsDefender
if
(
Test-IsTestCluster
)
{
if
(
Test-IsTestCluster
$kube_env
)
{
Log-Output
'Test cluster detected, installing OpenSSH.'
Log-Output
'Test cluster detected, installing OpenSSH.'
FetchAndImport-ModuleFromMetadata
'install-ssh-psm1'
'install-ssh.psm1'
FetchAndImport-ModuleFromMetadata
'install-ssh-psm1'
'install-ssh.psm1'
InstallAndStart-OpenSsh
InstallAndStart-OpenSsh
...
...
cluster/gce/windows/k8s-node-setup.psm1
View file @
621df2cd
...
@@ -221,13 +221,6 @@ function Set-PrerequisiteOptions {
...
@@ -221,13 +221,6 @@ function Set-PrerequisiteOptions {
sc.exe config wuauserv
start
=
disabled
sc.exe config wuauserv
start
=
disabled
sc.exe stop wuauserv
sc.exe stop wuauserv
# Windows Defender periodically consumes 100% of the CPU.
# TODO(pjh): this (all of a sudden, ugh) started failing with "The term
# 'Set-MpPreference' is not recognized...". Investigate and fix or remove.
#Log-Output "Disabling Windows Defender service"
#Set-MpPreference -DisableRealtimeMonitoring $true
#Uninstall-WindowsFeature -Name 'Windows-Defender'
# Use TLS 1.2: needed for Invoke-WebRequest downloads from github.com.
# Use TLS 1.2: needed for Invoke-WebRequest downloads from github.com.
[
Net.ServicePointManager]::SecurityProtocol
=
`
[
Net.ServicePointManager]::SecurityProtocol
=
`
[
Net.SecurityProtocolType]::Tls12
[
Net.SecurityProtocolType]::Tls12
...
@@ -237,6 +230,24 @@ function Set-PrerequisiteOptions {
...
@@ -237,6 +230,24 @@ function Set-PrerequisiteOptions {
Install-Module -Name powershell-yaml -Force
Install-Module -Name powershell-yaml -Force
}
}
# Disables Windows Defender realtime scanning if this Windows node is part of a
# test cluster.
#
# ${kube_env} must have already been set.
function
Disable-WindowsDefender
{
# Windows Defender periodically consumes 100% of the CPU, so disable realtime
# scanning. Uninstalling the Windows Feature will prevent the service from
# starting after a reboot.
# TODO(pjh): move this step to image preparation, since we don't want to do a
# full reboot here.
if
((
Test-IsTestCluster
${
kube_env
}
)
-and
((
Get-WindowsFeature
-Name
'Windows-Defender'
)
.Installed
))
{
Log-Output
"Disabling Windows Defender service"
Set-MpPreference
-DisableRealtimeMonitoring
$true
Uninstall-WindowsFeature
-Name
'Windows-Defender'
}
}
# Creates directories where other functions in this module will read and write
# Creates directories where other functions in this module will read and write
# data.
# data.
function
Create-Directories
{
function
Create-Directories
{
...
...
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