Skip to content

Commit 518fd87

Browse files
authored
Merge pull request #90 from phillc/master
Remove deprecated annotation for tls and protocol
2 parents 680fdd9 + f4cb294 commit 518fd87

6 files changed

+20
-1419
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ These annotations are deprecated, and will be removed in a future release.
6262

6363
Annotation (Suffix) | Values | Default | Description | Scheduled Removal
6464
---|---|---|---|---
65-
`protocol` | `tcp`, `http`, `https` | `tcp` | This annotation is used to specify the default protocol for Linode NodeBalancer. For ports specified in the `linode-loadbalancer-tls-ports` annotation, this protocol is overwritten to `https` | Q4 2020
6665
`proxy-protcol` | `none`, `v1`, `v2` | `none` | Specifies whether to use a version of Proxy Protocol on the underlying NodeBalancer | Q4 2021
67-
`tls` | json array (e.g. `[ { "tls-secret-name": "prod-app-tls", "port": 443}, {"tls-secret-name": "dev-app-tls", "port": 8443} ]`) | | Specifies TLS ports with their corresponding secrets, the secret type should be `kubernetes.io/tls | Q4 2020
6866

6967
#### Annotation bool values
7068

cloud/linode/loadbalancers.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ func getPortConfig(service *v1.Service, port int) (portConfig, error) {
647647
proxyProtocol := portConfigAnnotation.ProxyProtocol
648648
if proxyProtocol == "" {
649649
var ok bool
650-
for _, ann := range []string{annLinodeDefaultProxyProtocol, annLinodeProxyProtocol} {
650+
for _, ann := range []string{annLinodeDefaultProxyProtocol, annLinodeProxyProtocolDeprecated} {
651651
proxyProtocol, ok = service.Annotations[ann]
652652
if ok {
653653
break
@@ -688,13 +688,14 @@ func getHealthCheckType(service *v1.Service) (linodego.ConfigCheck, error) {
688688
}
689689

690690
func getPortConfigAnnotation(service *v1.Service, port int) (portConfigAnnotation, error) {
691+
annotation := portConfigAnnotation{}
691692
annotationKey := annLinodePortConfigPrefix + strconv.Itoa(port)
692693
annotationJSON, ok := service.Annotations[annotationKey]
694+
693695
if !ok {
694-
return tryDeprecatedTLSAnnotation(service, port)
696+
return annotation, nil
695697
}
696698

697-
annotation := portConfigAnnotation{}
698699
err := json.Unmarshal([]byte(annotationJSON), &annotation)
699700
if err != nil {
700701
return annotation, err
Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,5 @@
11
package linode
22

3-
import (
4-
"encoding/json"
5-
6-
v1 "k8s.io/api/core/v1"
7-
)
8-
93
const (
10-
annLinodeProtocolDeprecated = "service.beta.kubernetes.io/linode-loadbalancer-protocol"
11-
annLinodeLoadBalancerTLSDeprecated = "service.beta.kubernetes.io/linode-loadbalancer-tls"
12-
annLinodeProxyProtocol = "service.beta.kubernetes.io/linode-loadbalancer-proxy-protocol"
4+
annLinodeProxyProtocolDeprecated = "service.beta.kubernetes.io/linode-loadbalancer-proxy-protocol"
135
)
14-
15-
type tlsAnnotationDeprecated struct {
16-
TLSSecretName string `json:"tls-secret-name"`
17-
Port int `json:"port"`
18-
}
19-
20-
func tryDeprecatedTLSAnnotation(service *v1.Service, port int) (portConfigAnnotation, error) {
21-
annotation := portConfigAnnotation{}
22-
tlsAnnotation, err := getTLSAnnotationDeprecated(service, port)
23-
if err != nil {
24-
return annotation, err
25-
}
26-
27-
if tlsAnnotation != nil {
28-
annotation.Protocol = "https"
29-
annotation.TLSSecretName = tlsAnnotation.TLSSecretName
30-
} else if protocol, ok := service.Annotations[annLinodeProtocolDeprecated]; ok {
31-
annotation.Protocol = protocol
32-
}
33-
return annotation, nil
34-
}
35-
36-
func getTLSAnnotationDeprecated(service *v1.Service, port int) (*tlsAnnotationDeprecated, error) {
37-
annotationJSON, ok := service.Annotations[annLinodeLoadBalancerTLSDeprecated]
38-
if !ok {
39-
return nil, nil
40-
}
41-
tlsAnnotations := make([]*tlsAnnotationDeprecated, 0)
42-
err := json.Unmarshal([]byte(annotationJSON), &tlsAnnotations)
43-
if err != nil {
44-
return nil, err
45-
}
46-
for _, tlsAnnotation := range tlsAnnotations {
47-
if tlsAnnotation.Port == port {
48-
return tlsAnnotation, nil
49-
}
50-
}
51-
return nil, nil
52-
}

0 commit comments

Comments
 (0)