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
028f155b
Commit
028f155b
authored
Aug 09, 2018
by
Pengfei Ni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add node affinity for unzoned managed disks
parent
fbb2dfcc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
10 deletions
+47
-10
azure.go
pkg/cloudprovider/providers/azure/azure.go
+5
-0
azure_dd.go
pkg/volume/azure_dd/azure_dd.go
+3
-0
azure_provision.go
pkg/volume/azure_dd/azure_provision.go
+39
-10
No files found.
pkg/cloudprovider/providers/azure/azure.go
View file @
028f155b
...
...
@@ -525,3 +525,8 @@ func (az *Cloud) GetActiveZones() (sets.String, error) {
}
return
zones
,
nil
}
// GetLocation returns the location in which k8s cluster is currently running.
func
(
az
*
Cloud
)
GetLocation
()
string
{
return
az
.
Location
}
pkg/volume/azure_dd/azure_dd.go
View file @
028f155b
...
...
@@ -66,6 +66,9 @@ type DiskController interface {
// GetActiveZones returns all the zones in which k8s nodes are currently running.
GetActiveZones
()
(
sets
.
String
,
error
)
// GetLocation returns the location in which k8s cluster is currently running.
GetLocation
()
string
}
type
azureDataDiskPlugin
struct
{
...
...
pkg/volume/azure_dd/azure_provision.go
View file @
028f155b
...
...
@@ -29,6 +29,7 @@ import (
utilfeature
"k8s.io/apiserver/pkg/util/feature"
"k8s.io/kubernetes/pkg/cloudprovider/providers/azure"
"k8s.io/kubernetes/pkg/features"
kubeletapis
"k8s.io/kubernetes/pkg/kubelet/apis"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
)
...
...
@@ -195,8 +196,8 @@ func (p *azureDiskProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
}
}
if
!
zoned
&&
(
zonePresent
||
zonesPresent
)
{
return
nil
,
fmt
.
Errorf
(
"zone
or zon
es StorageClass parameters must be used together with zoned parameter"
)
if
!
zoned
&&
(
zonePresent
||
zonesPresent
||
len
(
allowedTopologies
)
>
0
)
{
return
nil
,
fmt
.
Errorf
(
"zone
, zones and allowedTopologi
es StorageClass parameters must be used together with zoned parameter"
)
}
if
cachingMode
,
err
=
normalizeCachingMode
(
cachingMode
);
err
!=
nil
{
...
...
@@ -298,18 +299,46 @@ func (p *azureDiskProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
},
}
if
zoned
&&
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
VolumeScheduling
)
{
requirements
:=
make
([]
v1
.
NodeSelectorRequirement
,
0
)
for
k
,
v
:=
range
labels
{
requirements
=
append
(
requirements
,
v1
.
NodeSelectorRequirement
{
Key
:
k
,
Operator
:
v1
.
NodeSelectorOpIn
,
Values
:
[]
string
{
v
}})
}
if
kind
==
v1
.
AzureManagedDisk
&&
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
VolumeScheduling
)
{
nodeSelectorTerms
:=
make
([]
v1
.
NodeSelectorTerm
,
0
)
if
zoned
{
// Set node affinity labels based on availability zone labels.
requirements
:=
make
([]
v1
.
NodeSelectorRequirement
,
0
)
for
k
,
v
:=
range
labels
{
requirements
=
append
(
requirements
,
v1
.
NodeSelectorRequirement
{
Key
:
k
,
Operator
:
v1
.
NodeSelectorOpIn
,
Values
:
[]
string
{
v
}})
}
nodeSelectorTerm
:=
v1
.
NodeSelectorTerm
{
MatchExpressions
:
requirements
,
nodeSelectorTerms
=
append
(
nodeSelectorTerms
,
v1
.
NodeSelectorTerm
{
MatchExpressions
:
requirements
,
})
}
else
{
// Set node affinity labels based on fault domains.
// This is required because unzoned AzureDisk can't be attached to zoned nodes.
// There are at most 3 fault domains available in each region.
// Refer https://docs.microsoft.com/en-us/azure/virtual-machines/windows/manage-availability.
for
i
:=
0
;
i
<
3
;
i
++
{
requirements
:=
[]
v1
.
NodeSelectorRequirement
{
{
Key
:
kubeletapis
.
LabelZoneRegion
,
Operator
:
v1
.
NodeSelectorOpIn
,
Values
:
[]
string
{
diskController
.
GetLocation
()},
},
{
Key
:
kubeletapis
.
LabelZoneFailureDomain
,
Operator
:
v1
.
NodeSelectorOpIn
,
Values
:
[]
string
{
strconv
.
Itoa
(
i
)},
},
}
nodeSelectorTerms
=
append
(
nodeSelectorTerms
,
v1
.
NodeSelectorTerm
{
MatchExpressions
:
requirements
,
})
}
}
pv
.
Spec
.
NodeAffinity
=
&
v1
.
VolumeNodeAffinity
{
Required
:
&
v1
.
NodeSelector
{
NodeSelectorTerms
:
[]
v1
.
NodeSelectorTerm
{
nodeSelectorTerm
}
,
NodeSelectorTerms
:
nodeSelectorTerms
,
},
}
}
...
...
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