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
b7813b15
Commit
b7813b15
authored
Mar 21, 2018
by
Pengfei Ni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add verification of supported service tags
parent
7d9d5716
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
4 deletions
+26
-4
azure_loadbalancer.go
pkg/cloudprovider/providers/azure/azure_loadbalancer.go
+26
-4
No files found.
pkg/cloudprovider/providers/azure/azure_loadbalancer.go
View file @
b7813b15
...
@@ -75,6 +75,13 @@ const (
...
@@ -75,6 +75,13 @@ const (
ServiceAnnotationAllowedServiceTag
=
"service.beta.kubernetes.io/azure-allowed-service-tags"
ServiceAnnotationAllowedServiceTag
=
"service.beta.kubernetes.io/azure-allowed-service-tags"
)
)
var
(
// supportedServiceTags holds a list of supported service tags on Azure.
// Refer https://docs.microsoft.com/en-us/azure/virtual-network/security-overview#service-tags for more information.
supportedServiceTags
=
sets
.
NewString
(
"VirtualNetwork"
,
"VIRTUAL_NETWORK"
,
"AzureLoadBalancer"
,
"AZURE_LOADBALANCER"
,
"Internet"
,
"INTERNET"
,
"AzureTrafficManager"
,
"Storage"
,
"Sql"
)
)
// GetLoadBalancer returns whether the specified load balancer exists, and
// GetLoadBalancer returns whether the specified load balancer exists, and
// if so, what its status is.
// if so, what its status is.
func
(
az
*
Cloud
)
GetLoadBalancer
(
ctx
context
.
Context
,
clusterName
string
,
service
*
v1
.
Service
)
(
status
*
v1
.
LoadBalancerStatus
,
exists
bool
,
err
error
)
{
func
(
az
*
Cloud
)
GetLoadBalancer
(
ctx
context
.
Context
,
clusterName
string
,
service
*
v1
.
Service
)
(
status
*
v1
.
LoadBalancerStatus
,
exists
bool
,
err
error
)
{
...
@@ -842,7 +849,10 @@ func (az *Cloud) reconcileSecurityGroup(clusterName string, service *v1.Service,
...
@@ -842,7 +849,10 @@ func (az *Cloud) reconcileSecurityGroup(clusterName string, service *v1.Service,
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
serviceTags
:=
getServiceTags
(
service
)
serviceTags
,
err
:=
getServiceTags
(
service
)
if
err
!=
nil
{
return
nil
,
err
}
var
sourceAddressPrefixes
[]
string
var
sourceAddressPrefixes
[]
string
if
(
sourceRanges
==
nil
||
serviceapi
.
IsAllowAll
(
sourceRanges
))
&&
len
(
serviceTags
)
==
0
{
if
(
sourceRanges
==
nil
||
serviceapi
.
IsAllowAll
(
sourceRanges
))
&&
len
(
serviceTags
)
==
0
{
if
!
requiresInternalLoadBalancer
(
service
)
{
if
!
requiresInternalLoadBalancer
(
service
)
{
...
@@ -1328,10 +1338,22 @@ func useSharedSecurityRule(service *v1.Service) bool {
...
@@ -1328,10 +1338,22 @@ func useSharedSecurityRule(service *v1.Service) bool {
return
false
return
false
}
}
func
getServiceTags
(
service
*
v1
.
Service
)
[]
string
{
func
getServiceTags
(
service
*
v1
.
Service
)
([]
string
,
error
)
{
if
serviceTags
,
found
:=
service
.
Annotations
[
ServiceAnnotationAllowedServiceTag
];
found
{
if
serviceTags
,
found
:=
service
.
Annotations
[
ServiceAnnotationAllowedServiceTag
];
found
{
return
strings
.
Split
(
strings
.
TrimSpace
(
serviceTags
),
","
)
tags
:=
strings
.
Split
(
strings
.
TrimSpace
(
serviceTags
),
","
)
for
_
,
tag
:=
range
tags
{
// Storage and Sql service tags support setting regions with suffix ".Region"
if
strings
.
HasPrefix
(
tag
,
"Storage."
)
||
strings
.
HasPrefix
(
tag
,
"Sql."
)
{
continue
}
if
!
supportedServiceTags
.
Has
(
tag
)
{
return
nil
,
fmt
.
Errorf
(
"only %q are allowed in service tags"
,
supportedServiceTags
.
List
())
}
}
return
tags
,
nil
}
}
return
nil
return
nil
,
nil
}
}
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