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
5882c35e
Commit
5882c35e
authored
Aug 06, 2015
by
CJ Cullen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use full URLs for GCE networks
parent
bee48f4c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
8 deletions
+13
-8
gce.go
pkg/cloudprovider/gce/gce.go
+13
-8
No files found.
pkg/cloudprovider/gce/gce.go
View file @
5882c35e
...
...
@@ -59,7 +59,7 @@ type GCECloud struct {
zone
string
instanceID
string
externalID
string
network
Name
string
network
URL
string
// Used for accessing the metadata server
metadataAccess
func
(
string
)
(
string
,
error
)
...
...
@@ -166,6 +166,7 @@ func newGCECloud(config io.Reader) (*GCECloud, error) {
if
err
!=
nil
{
return
nil
,
err
}
networkURL
:=
gceNetworkURL
(
projectID
,
networkName
)
tokenSource
:=
google
.
ComputeTokenSource
(
""
)
if
config
!=
nil
{
var
cfg
Config
...
...
@@ -177,7 +178,11 @@ func newGCECloud(config io.Reader) (*GCECloud, error) {
projectID
=
cfg
.
Global
.
ProjectID
}
if
cfg
.
Global
.
NetworkName
!=
""
{
networkName
=
cfg
.
Global
.
NetworkName
if
strings
.
Contains
(
cfg
.
Global
.
NetworkName
,
"/"
)
{
networkURL
=
cfg
.
Global
.
NetworkName
}
else
{
networkURL
=
gceNetworkURL
(
cfg
.
Global
.
ProjectID
,
cfg
.
Global
.
NetworkName
)
}
}
if
cfg
.
Global
.
TokenURL
!=
""
{
tokenSource
=
newAltTokenSource
(
cfg
.
Global
.
TokenURL
)
...
...
@@ -199,7 +204,7 @@ func newGCECloud(config io.Reader) (*GCECloud, error) {
zone
:
zone
,
instanceID
:
instanceID
,
externalID
:
externalID
,
network
Name
:
networkName
,
network
URL
:
networkURL
,
metadataAccess
:
getMetadata
,
},
nil
}
...
...
@@ -426,7 +431,7 @@ func (gce *GCECloud) CreateTCPLoadBalancer(name, region string, externalIP net.I
firewall
:=
&
compute
.
Firewall
{
Name
:
makeFirewallName
(
name
),
Description
:
fmt
.
Sprintf
(
"KubernetesAutoGenerated_OnlyAllowTrafficForDestinationIP_%s"
,
fwd
.
IPAddress
),
Network
:
gce
.
gceNetworkName
()
,
Network
:
gce
.
networkURL
,
SourceRanges
:
[]
string
{
"0.0.0.0/0"
},
TargetTags
:
[]
string
{
hostTag
},
Allowed
:
[]
*
compute
.
FirewallAllowed
{
...
...
@@ -759,7 +764,7 @@ func (gce *GCECloud) ListRoutes(clusterName string) ([]*cloudprovider.Route, err
}
var
routes
[]
*
cloudprovider
.
Route
for
_
,
r
:=
range
res
.
Items
{
if
path
.
Base
(
r
.
Network
)
!=
gce
.
networkName
{
if
r
.
Network
!=
gce
.
networkURL
{
continue
}
// Not managed if route description != "k8s-node-route"
...
...
@@ -777,8 +782,8 @@ func (gce *GCECloud) ListRoutes(clusterName string) ([]*cloudprovider.Route, err
return
routes
,
nil
}
func
(
gce
*
GCECloud
)
gceNetworkName
(
)
string
{
return
fmt
.
Sprintf
(
"
global/networks/%s"
,
gce
.
networkName
)
func
gceNetworkURL
(
project
,
network
string
)
string
{
return
fmt
.
Sprintf
(
"
https://www.googleapis.com/compute/v1/projects/%s/global/networks/%s"
,
project
,
network
)
}
func
(
gce
*
GCECloud
)
CreateRoute
(
clusterName
string
,
nameHint
string
,
route
*
cloudprovider
.
Route
)
error
{
...
...
@@ -789,7 +794,7 @@ func (gce *GCECloud) CreateRoute(clusterName string, nameHint string, route *clo
Name
:
routeName
,
DestRange
:
route
.
DestinationCIDR
,
NextHopInstance
:
fmt
.
Sprintf
(
"zones/%s/instances/%s"
,
gce
.
zone
,
instanceName
),
Network
:
gce
.
gceNetworkName
()
,
Network
:
gce
.
networkURL
,
Priority
:
1000
,
Description
:
k8sNodeRouteTag
,
})
.
Do
()
...
...
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