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
8b3099ce
Commit
8b3099ce
authored
Oct 01, 2018
by
Walter Fender
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Differentiate multizone zonal from Regional Cluster.
Fixed go format and unit test. Collapse lines. Switched to using regional throughout and added warning for HA Zonal.
parent
48086eb7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
13 deletions
+53
-13
configure-helper.sh
cluster/gce/gci/configure-helper.sh
+9
-0
gce.go
pkg/cloudprovider/providers/gce/gce.go
+10
-1
gce_clusters.go
pkg/cloudprovider/providers/gce/gce_clusters.go
+17
-12
gce_test.go
pkg/cloudprovider/providers/gce/gce_test.go
+17
-0
No files found.
cluster/gce/gci/configure-helper.sh
View file @
8b3099ce
...
...
@@ -663,6 +663,15 @@ EOF
multizone =
${
MULTIZONE
}
EOF
fi
# Multimaster indicates that the cluster is HA.
# Currently the only HA clusters are regional.
# If we introduce zonal multimaster this will need to be revisited.
if
[[
-n
"
${
MULTIMASTER
:-}
"
]]
;
then
use_cloud_config
=
"true"
cat
<<
EOF
>>/etc/gce.conf
regional =
${
MULTIMASTER
}
EOF
fi
if
[[
-n
"
${
GCE_ALPHA_FEATURES
:-}
"
]]
;
then
use_cloud_config
=
"true"
# split GCE_ALPHA_FEATURES into an array by comma.
...
...
pkg/cloudprovider/providers/gce/gce.go
View file @
8b3099ce
...
...
@@ -114,6 +114,7 @@ type GCECloud struct {
eventRecorder
record
.
EventRecorder
projectID
string
region
string
regional
bool
localZone
string
// The zone in which we are running
// managedZones will be set to the 1 zone if running a single zone cluster
// it will be set to ALL zones in region for any multi-zone cluster
...
...
@@ -174,6 +175,7 @@ type ConfigGlobal struct {
SecondaryRangeName
string
`gcfg:"secondary-range-name"`
NodeTags
[]
string
`gcfg:"node-tags"`
NodeInstancePrefix
string
`gcfg:"node-instance-prefix"`
Regional
bool
`gcfg:"regional"`
Multizone
bool
`gcfg:"multizone"`
// ApiEndpoint is the GCE compute API endpoint to use. If this is blank,
// then the default endpoint is used.
...
...
@@ -202,6 +204,7 @@ type CloudConfig struct {
ProjectID
string
NetworkProjectID
string
Region
string
Regional
bool
Zone
string
ManagedZones
[]
string
NetworkName
string
...
...
@@ -332,9 +335,14 @@ func generateCloudConfig(configFile *ConfigFile) (cloudConfig *CloudConfig, err
return
nil
,
err
}
// Determine if its a regional cluster
if
configFile
!=
nil
&&
configFile
.
Global
.
Regional
{
cloudConfig
.
Regional
=
true
}
// generate managedZones
cloudConfig
.
ManagedZones
=
[]
string
{
cloudConfig
.
Zone
}
if
configFile
!=
nil
&&
configFile
.
Global
.
Multizone
{
if
configFile
!=
nil
&&
(
configFile
.
Global
.
Multizone
||
configFile
.
Global
.
Regional
)
{
cloudConfig
.
ManagedZones
=
nil
// Use all zones in region
}
...
...
@@ -512,6 +520,7 @@ func CreateGCECloud(config *CloudConfig) (*GCECloud, error) {
networkProjectID
:
netProjID
,
onXPN
:
onXPN
,
region
:
config
.
Region
,
regional
:
config
.
Regional
,
localZone
:
config
.
Zone
,
managedZones
:
config
.
ManagedZones
,
networkURL
:
networkURL
,
...
...
pkg/cloudprovider/providers/gce/gce_clusters.go
View file @
8b3099ce
...
...
@@ -45,22 +45,27 @@ func (gce *GCECloud) ListClusters(ctx context.Context) ([]string, error) {
}
func
(
gce
*
GCECloud
)
GetManagedClusters
(
ctx
context
.
Context
)
([]
*
container
.
Cluster
,
error
)
{
var
location
string
if
len
(
gce
.
managedZones
)
>
1
{
// Multiple managed zones means this is a regional cluster
// so use the regional location and not the zone.
location
=
gce
.
region
}
else
if
len
(
gce
.
managedZones
)
==
1
{
location
=
gce
.
managedZones
[
0
]
managedClusters
:=
[]
*
container
.
Cluster
{}
if
gce
.
regional
{
var
err
error
managedClusters
,
err
=
gce
.
getClustersInLocation
(
gce
.
region
)
if
err
!=
nil
{
return
nil
,
err
}
}
else
if
len
(
gce
.
managedZones
)
>=
1
{
for
_
,
zone
:=
range
gce
.
managedZones
{
clusters
,
err
:=
gce
.
getClustersInLocation
(
zone
)
if
err
!=
nil
{
return
nil
,
err
}
managedClusters
=
append
(
managedClusters
,
clusters
...
)
}
}
else
{
return
nil
,
errors
.
New
(
fmt
.
Sprintf
(
"no zones associated with this cluster(%s)"
,
gce
.
ProjectID
()))
}
clusters
,
err
:=
gce
.
getClustersInLocation
(
location
)
if
err
!=
nil
{
return
nil
,
err
}
return
c
lusters
,
nil
return
managedC
lusters
,
nil
}
func
(
gce
*
GCECloud
)
Master
(
ctx
context
.
Context
,
clusterName
string
)
(
string
,
error
)
{
...
...
pkg/cloudprovider/providers/gce/gce_test.go
View file @
8b3099ce
...
...
@@ -39,6 +39,7 @@ secondary-range-name = my-secondary-range
node-tags = my-node-tag1
node-instance-prefix = my-prefix
multizone = true
regional = true
`
reader
:=
strings
.
NewReader
(
s
)
config
,
err
:=
readConfig
(
reader
)
...
...
@@ -57,6 +58,7 @@ multizone = true
NodeTags
:
[]
string
{
"my-node-tag1"
},
NodeInstancePrefix
:
"my-prefix"
,
Multizone
:
true
,
Regional
:
true
,
}}
if
!
reflect
.
DeepEqual
(
expected
,
config
)
{
...
...
@@ -328,6 +330,7 @@ func TestGenerateCloudConfigs(t *testing.T) {
NodeTags
:
[]
string
{
"node-tag"
},
NodeInstancePrefix
:
"node-prefix"
,
Multizone
:
false
,
Regional
:
false
,
ApiEndpoint
:
""
,
LocalZone
:
"us-central1-a"
,
AlphaFeatures
:
[]
string
{},
...
...
@@ -447,6 +450,20 @@ func TestGenerateCloudConfigs(t *testing.T) {
},
},
{
name
:
"Regional"
,
config
:
func
()
ConfigGlobal
{
v
:=
configBoilerplate
v
.
Regional
=
true
return
v
},
cloud
:
func
()
CloudConfig
{
v
:=
cloudBoilerplate
v
.
Regional
=
true
v
.
ManagedZones
=
nil
return
v
},
},
{
name
:
"Secondary Range Name"
,
config
:
func
()
ConfigGlobal
{
v
:=
configBoilerplate
...
...
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