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
3ea26e74
Commit
3ea26e74
authored
Jun 13, 2017
by
Nick Sardo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Annotation for opting into backend sharing; Use hash suffix for sharing; Fix resource GC
parent
d97d80fb
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
12 deletions
+29
-12
gce_annotations.go
pkg/cloudprovider/providers/gce/gce_annotations.go
+15
-1
gce_loadbalancer_internal.go
pkg/cloudprovider/providers/gce/gce_loadbalancer_internal.go
+0
-0
gce_loadbalancer_naming.go
pkg/cloudprovider/providers/gce/gce_loadbalancer_naming.go
+14
-11
No files found.
pkg/cloudprovider/providers/gce/gce_annotations.go
View file @
3ea26e74
...
...
@@ -21,12 +21,17 @@ import "k8s.io/kubernetes/pkg/api/v1"
type
LoadBalancerType
string
const
(
// ServiceAnnotationLoadBalancerType is
the annotation us
ed on a service with type LoadBalancer
// ServiceAnnotationLoadBalancerType is
annotat
ed on a service with type LoadBalancer
// dictates what specific kind of GCP LB should be assembled.
// Currently, only "internal" is supported.
ServiceAnnotationLoadBalancerType
=
"cloud.google.com/load-balancer-type"
LBTypeInternal
LoadBalancerType
=
"internal"
// ServiceAnnotationInternalBackendShare is annotated on a service with "true" when users
// want to share GCP Backend Services for a set of internal load balancers.
// ALPHA feature - this may be removed in a future release.
ServiceAnnotationILBBackendShare
=
"cloud.google.com/load-balancer-backend-share"
)
// GetLoadBalancerAnnotationType returns the type of GCP load balancer which should be assembled.
...
...
@@ -49,3 +54,12 @@ func GetLoadBalancerAnnotationType(service *v1.Service) (LoadBalancerType, bool)
return
v
,
false
}
}
func
GetLoadBalancerAnnotationBackendShare
(
service
*
v1
.
Service
)
bool
{
l
,
exists
:=
service
.
Annotations
[
ServiceAnnotationILBBackendShare
]
if
exists
&&
l
==
"true"
{
return
true
}
return
false
}
pkg/cloudprovider/providers/gce/gce_loadbalancer_internal.go
View file @
3ea26e74
This diff is collapsed.
Click to expand it.
pkg/cloudprovider/providers/gce/gce_loadbalancer_naming.go
View file @
3ea26e74
...
...
@@ -17,6 +17,8 @@ limitations under the License.
package
gce
import
(
"crypto/sha1"
"encoding/hex"
"fmt"
"strings"
...
...
@@ -33,15 +35,16 @@ func makeInstanceGroupName(clusterID string) string {
func
makeBackendServiceName
(
loadBalancerName
,
clusterID
string
,
shared
bool
,
scheme
lbScheme
,
protocol
v1
.
Protocol
,
svcAffinity
v1
.
ServiceAffinity
)
string
{
if
shared
{
affinity
:=
""
switch
svcAffinity
{
case
v1
.
ServiceAffinityClientIP
:
affinity
=
"clientip"
default
:
affinity
=
"noaffinity"
}
return
fmt
.
Sprintf
(
"k8s-%s-%s-%s-%s"
,
clusterID
,
strings
.
ToLower
(
string
(
scheme
)),
strings
.
ToLower
(
string
(
protocol
)),
affinity
)
hash
:=
sha1
.
New
()
// For every non-nil option, hash its value. Currently, only service affinity is relevant.
hash
.
Write
([]
byte
(
string
(
svcAffinity
)))
hashed
:=
hex
.
EncodeToString
(
hash
.
Sum
(
nil
))
hashed
=
hashed
[
:
16
]
// 3 + 1 + 16 + 1 + 8 + 1 + 3 + 16
return
fmt
.
Sprintf
(
"k8s-%s-%s-%s-nmv1-%s"
,
clusterID
,
strings
.
ToLower
(
string
(
scheme
)),
strings
.
ToLower
(
string
(
protocol
)),
hashed
)
}
return
loadBalancerName
}
...
...
@@ -54,11 +57,11 @@ func makeHealthCheckName(loadBalancerName, clusterID string, shared bool) string
return
loadBalancerName
}
func
makeHealthCheckFirewall
k
NameFromHC
(
healthCheckName
string
)
string
{
func
makeHealthCheckFirewallNameFromHC
(
healthCheckName
string
)
string
{
return
healthCheckName
+
"-hc"
}
func
makeHealthCheckFirewall
k
Name
(
loadBalancerName
,
clusterID
string
,
shared
bool
)
string
{
func
makeHealthCheckFirewallName
(
loadBalancerName
,
clusterID
string
,
shared
bool
)
string
{
if
shared
{
return
fmt
.
Sprintf
(
"k8s-%s-node-hc"
,
clusterID
)
}
...
...
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