@@ -74,6 +74,7 @@ const (
74
74
75
75
// ServiceAnnotationAllowedServiceTag is the annotation used on the service
76
76
// to specify a list of allowed service tags separated by comma
77
+ // Refer https://docs.microsoft.com/en-us/azure/virtual-network/security-overview#service-tags for all supported service tags.
77
78
ServiceAnnotationAllowedServiceTag = "service.beta.kubernetes.io/azure-allowed-service-tags"
78
79
79
80
// ServiceAnnotationLoadBalancerIdleTimeout is the annotation used on the service
@@ -90,13 +91,6 @@ const (
90
91
clusterNameKey = "kubernetes-cluster-name"
91
92
)
92
93
93
- var (
94
- // supportedServiceTags holds a list of supported service tags on Azure.
95
- // Refer https://docs.microsoft.com/en-us/azure/virtual-network/security-overview#service-tags for more information.
96
- supportedServiceTags = sets .NewString ("VirtualNetwork" , "VIRTUAL_NETWORK" , "AzureLoadBalancer" , "AZURE_LOADBALANCER" ,
97
- "Internet" , "INTERNET" , "AzureTrafficManager" , "Storage" , "Sql" )
98
- )
99
-
100
94
// GetLoadBalancer returns whether the specified load balancer exists, and
101
95
// if so, what its status is.
102
96
func (az * Cloud ) GetLoadBalancer (ctx context.Context , clusterName string , service * v1.Service ) (status * v1.LoadBalancerStatus , exists bool , err error ) {
@@ -1028,10 +1022,7 @@ func (az *Cloud) reconcileSecurityGroup(clusterName string, service *v1.Service,
1028
1022
if err != nil {
1029
1023
return nil , err
1030
1024
}
1031
- serviceTags , err := getServiceTags (service )
1032
- if err != nil {
1033
- return nil , err
1034
- }
1025
+ serviceTags := getServiceTags (service )
1035
1026
var sourceAddressPrefixes []string
1036
1027
if (sourceRanges == nil || servicehelpers .IsAllowAll (sourceRanges )) && len (serviceTags ) == 0 {
1037
1028
if ! requiresInternalLoadBalancer (service ) {
@@ -1609,24 +1600,25 @@ func useSharedSecurityRule(service *v1.Service) bool {
1609
1600
return false
1610
1601
}
1611
1602
1612
- func getServiceTags (service * v1.Service ) ([]string , error ) {
1603
+ func getServiceTags (service * v1.Service ) []string {
1604
+ if service == nil {
1605
+ return nil
1606
+ }
1607
+
1613
1608
if serviceTags , found := service .Annotations [ServiceAnnotationAllowedServiceTag ]; found {
1609
+ result := []string {}
1614
1610
tags := strings .Split (strings .TrimSpace (serviceTags ), "," )
1615
1611
for _ , tag := range tags {
1616
- // Storage and Sql service tags support setting regions with suffix ".Region"
1617
- if strings .HasPrefix (tag , "Storage." ) || strings .HasPrefix (tag , "Sql." ) {
1618
- continue
1619
- }
1620
-
1621
- if ! supportedServiceTags .Has (tag ) {
1622
- return nil , fmt .Errorf ("only %q are allowed in service tags" , supportedServiceTags .List ())
1612
+ serviceTag := strings .TrimSpace (tag )
1613
+ if serviceTag != "" {
1614
+ result = append (result , serviceTag )
1623
1615
}
1624
1616
}
1625
1617
1626
- return tags , nil
1618
+ return result
1627
1619
}
1628
1620
1629
- return nil , nil
1621
+ return nil
1630
1622
}
1631
1623
1632
1624
func serviceOwnsPublicIP (pip * network.PublicIPAddress , clusterName , serviceName string ) bool {
0 commit comments