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
67ee03af
Unverified
Commit
67ee03af
authored
Apr 12, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Apr 12, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #76440 from mm4tt/gce_private_clusters
Ability to set up Private GCE Test Clusters with NAT.
parents
0da72a1e
2efea762
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
4 deletions
+55
-4
config-default.sh
cluster/gce/config-default.sh
+3
-0
config-test.sh
cluster/gce/config-test.sh
+3
-0
util.sh
cluster/gce/util.sh
+49
-4
No files found.
cluster/gce/config-default.sh
View file @
67ee03af
...
@@ -489,3 +489,6 @@ fi
...
@@ -489,3 +489,6 @@ fi
# Taint Windows nodes by default to prevent Linux workloads from being
# Taint Windows nodes by default to prevent Linux workloads from being
# scheduled onto them.
# scheduled onto them.
WINDOWS_NODE_TAINTS
=
"
${
WINDOWS_NODE_TAINTS
:-
node
.kubernetes.io/os=win1809
:NoSchedule
}
"
WINDOWS_NODE_TAINTS
=
"
${
WINDOWS_NODE_TAINTS
:-
node
.kubernetes.io/os=win1809
:NoSchedule
}
"
# Whether to set up a private GCE cluster, i.e. a cluster where nodes have only private IPs.
GCE_PRIVATE_CLUSTER
=
"
${
KUBE_GCE_PRIVATE_CLUSTER
:-
false
}
"
cluster/gce/config-test.sh
View file @
67ee03af
...
@@ -511,3 +511,6 @@ fi
...
@@ -511,3 +511,6 @@ fi
# Taint Windows nodes by default to prevent Linux workloads from being
# Taint Windows nodes by default to prevent Linux workloads from being
# scheduled onto them.
# scheduled onto them.
WINDOWS_NODE_TAINTS
=
"
${
WINDOWS_NODE_TAINTS
:-
node
.kubernetes.io/os=win1809
:NoSchedule
}
"
WINDOWS_NODE_TAINTS
=
"
${
WINDOWS_NODE_TAINTS
:-
node
.kubernetes.io/os=win1809
:NoSchedule
}
"
# Whether to set up a private GCE cluster, i.e. a cluster where nodes have only private IPs.
GCE_PRIVATE_CLUSTER
=
"
${
KUBE_GCE_PRIVATE_CLUSTER
:-
false
}
"
cluster/gce/util.sh
View file @
67ee03af
...
@@ -1892,8 +1892,11 @@ function make-gcloud-network-argument() {
...
@@ -1892,8 +1892,11 @@ function make-gcloud-network-argument() {
if
[[
"
${
enable_ip_alias
}
"
==
'true'
]]
;
then
if
[[
"
${
enable_ip_alias
}
"
==
'true'
]]
;
then
ret
=
"--network-interface"
ret
=
"--network-interface"
ret
=
"
${
ret
}
network=
${
networkURL
}
"
ret
=
"
${
ret
}
network=
${
networkURL
}
"
# If address is omitted, instance will not receive an external IP.
if
[[
"
${
address
:-}
"
==
"no-address"
]]
;
then
ret
=
"
${
ret
}
,address=
${
address
:-}
"
ret
=
"
${
ret
}
,no-address"
else
ret
=
"
${
ret
}
,address=
${
address
:-}
"
fi
ret
=
"
${
ret
}
,subnet=
${
subnetURL
}
"
ret
=
"
${
ret
}
,subnet=
${
subnetURL
}
"
ret
=
"
${
ret
}
,aliases=pods-default:
${
alias_size
}
"
ret
=
"
${
ret
}
,aliases=pods-default:
${
alias_size
}
"
ret
=
"
${
ret
}
--no-can-ip-forward"
ret
=
"
${
ret
}
--no-can-ip-forward"
...
@@ -1905,7 +1908,7 @@ function make-gcloud-network-argument() {
...
@@ -1905,7 +1908,7 @@ function make-gcloud-network-argument() {
fi
fi
ret
=
"
${
ret
}
--can-ip-forward"
ret
=
"
${
ret
}
--can-ip-forward"
if
[[
-n
${
address
:-}
]]
;
then
if
[[
-n
${
address
:-}
]]
&&
[[
"
$address
"
!=
"no-address"
]]
;
then
ret
=
"
${
ret
}
--address
${
address
}
"
ret
=
"
${
ret
}
--address
${
address
}
"
fi
fi
fi
fi
...
@@ -2010,13 +2013,17 @@ function create-node-template() {
...
@@ -2010,13 +2013,17 @@ function create-node-template() {
fi
fi
fi
fi
local
address
=
""
if
[[
${
GCE_PRIVATE_CLUSTER
:-}
==
"true"
]]
;
then
address
=
"no-address"
fi
local
network
=
$(
make-gcloud-network-argument
\
local
network
=
$(
make-gcloud-network-argument
\
"
${
NETWORK_PROJECT
}
"
\
"
${
NETWORK_PROJECT
}
"
\
"
${
REGION
}
"
\
"
${
REGION
}
"
\
"
${
NETWORK
}
"
\
"
${
NETWORK
}
"
\
"
${
SUBNETWORK
:-}
"
\
"
${
SUBNETWORK
:-}
"
\
""
\
"
${
address
}
"
\
"
${
ENABLE_IP_ALIASES
:-}
"
\
"
${
ENABLE_IP_ALIASES
:-}
"
\
"
${
IP_ALIAS_SIZE
:-}
"
)
"
${
IP_ALIAS_SIZE
:-}
"
)
...
@@ -2113,6 +2120,7 @@ function kube-up() {
...
@@ -2113,6 +2120,7 @@ function kube-up() {
create-network
create-network
create-subnetworks
create-subnetworks
detect-subnetworks
detect-subnetworks
create-cloud-nat-router
write-cluster-location
write-cluster-location
write-cluster-name
write-cluster-name
create-autoscaler-config
create-autoscaler-config
...
@@ -2302,6 +2310,26 @@ function detect-subnetworks() {
...
@@ -2302,6 +2310,26 @@ function detect-subnetworks() {
echo
"
${
color_red
}
Could not find subnetwork with region
${
REGION
}
, network
${
NETWORK
}
, and project
${
NETWORK_PROJECT
}
"
echo
"
${
color_red
}
Could not find subnetwork with region
${
REGION
}
, network
${
NETWORK
}
, and project
${
NETWORK_PROJECT
}
"
}
}
# Sets up Cloud NAT for the network.
# Assumed vars:
# NETWORK_PROJECT
# REGION
# NETWORK
function
create-cloud-nat-router
()
{
if
[[
${
GCE_PRIVATE_CLUSTER
:-}
==
"true"
]]
;
then
gcloud compute routers create
"
$NETWORK
-nat-router"
\
--project
$NETWORK_PROJECT
\
--region
$REGION
\
--network
$NETWORK
gcloud compute routers nats create
"
$NETWORK
-nat-config"
\
--project
$NETWORK_PROJECT
\
--router-region
$REGION
\
--router
"
$NETWORK
-nat-router"
\
--nat-all-subnet-ip-ranges
\
--auto-allocate-nat-external-ips
fi
}
function
delete-all-firewall-rules
()
{
function
delete-all-firewall-rules
()
{
if
fws
=
$(
gcloud compute firewall-rules list
--project
"
${
NETWORK_PROJECT
}
"
--filter
=
"network=
${
NETWORK
}
"
--format
=
"value(name)"
)
;
then
if
fws
=
$(
gcloud compute firewall-rules list
--project
"
${
NETWORK_PROJECT
}
"
--filter
=
"network=
${
NETWORK
}
"
--format
=
"value(name)"
)
;
then
echo
"Deleting firewall rules remaining in network
${
NETWORK
}
:
${
fws
}
"
echo
"Deleting firewall rules remaining in network
${
NETWORK
}
:
${
fws
}
"
...
@@ -2333,6 +2361,15 @@ function delete-network() {
...
@@ -2333,6 +2361,15 @@ function delete-network() {
fi
fi
}
}
function
delete-cloud-nat-router
()
{
if
[[
${
GCE_PRIVATE_CLUSTER
:-}
==
"true"
]]
;
then
if
[[
-n
$(
gcloud compute routers describe
--project
"
${
NETWORK_PROJECT
}
"
--region
"
${
REGION
}
"
"
${
NETWORK
}
-nat-router"
--format
=
'value(name)'
2>/dev/null
||
true
)
]]
;
then
echo
"Deleting Cloud NAT router..."
gcloud compute routers delete
--project
"
${
NETWORK_PROJECT
}
"
--region
"
${
REGION
}
"
--quiet
"
${
NETWORK
}
-nat-router"
fi
fi
}
function
delete-subnetworks
()
{
function
delete-subnetworks
()
{
# If running in custom mode network we need to delete subnets manually.
# If running in custom mode network we need to delete subnets manually.
mode
=
"
$(
check-network-mode
)
"
mode
=
"
$(
check-network-mode
)
"
...
@@ -3209,6 +3246,7 @@ function kube-down() {
...
@@ -3209,6 +3246,7 @@ function kube-down() {
"
${
NETWORK
}
-default-internal"
# Pre-1.5 clusters
"
${
NETWORK
}
-default-internal"
# Pre-1.5 clusters
if
[[
"
${
KUBE_DELETE_NETWORK
}
"
==
"true"
]]
;
then
if
[[
"
${
KUBE_DELETE_NETWORK
}
"
==
"true"
]]
;
then
delete-cloud-nat-router
# Delete all remaining firewall rules in the network.
# Delete all remaining firewall rules in the network.
delete-all-firewall-rules
||
true
delete-all-firewall-rules
||
true
delete-subnetworks
||
true
delete-subnetworks
||
true
...
@@ -3404,6 +3442,13 @@ function check-resources() {
...
@@ -3404,6 +3442,13 @@ function check-resources() {
return
1
return
1
fi
fi
if
[[
${
GCE_PRIVATE_CLUSTER
:-}
==
"true"
]]
;
then
if
gcloud compute routers describe
--project
"
${
NETWORK_PROJECT
}
"
--region
"
${
REGION
}
"
"
${
NETWORK
}
-nat-router"
&>/dev/null
;
then
KUBE_RESOURCE_FOUND
=
"Cloud NAT router"
return
1
fi
fi
# No resources found.
# No resources found.
return
0
return
0
}
}
...
...
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