Skip to content

Commit

Permalink
Remove deprecated annotation for tls and protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
phillc committed Jan 26, 2021
1 parent 680fdd9 commit f4cb294
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 1,419 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ These annotations are deprecated, and will be removed in a future release.

Annotation (Suffix) | Values | Default | Description | Scheduled Removal
---|---|---|---|---
`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
`proxy-protcol` | `none`, `v1`, `v2` | `none` | Specifies whether to use a version of Proxy Protocol on the underlying NodeBalancer | Q4 2021
`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

#### Annotation bool values

Expand Down
7 changes: 4 additions & 3 deletions cloud/linode/loadbalancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ func getPortConfig(service *v1.Service, port int) (portConfig, error) {
proxyProtocol := portConfigAnnotation.ProxyProtocol
if proxyProtocol == "" {
var ok bool
for _, ann := range []string{annLinodeDefaultProxyProtocol, annLinodeProxyProtocol} {
for _, ann := range []string{annLinodeDefaultProxyProtocol, annLinodeProxyProtocolDeprecated} {
proxyProtocol, ok = service.Annotations[ann]
if ok {
break
Expand Down Expand Up @@ -688,13 +688,14 @@ func getHealthCheckType(service *v1.Service) (linodego.ConfigCheck, error) {
}

func getPortConfigAnnotation(service *v1.Service, port int) (portConfigAnnotation, error) {
annotation := portConfigAnnotation{}
annotationKey := annLinodePortConfigPrefix + strconv.Itoa(port)
annotationJSON, ok := service.Annotations[annotationKey]

if !ok {
return tryDeprecatedTLSAnnotation(service, port)
return annotation, nil
}

annotation := portConfigAnnotation{}
err := json.Unmarshal([]byte(annotationJSON), &annotation)
if err != nil {
return annotation, err
Expand Down
49 changes: 1 addition & 48 deletions cloud/linode/loadbalancers_deprecated.go
Original file line number Diff line number Diff line change
@@ -1,52 +1,5 @@
package linode

import (
"encoding/json"

v1 "k8s.io/api/core/v1"
)

const (
annLinodeProtocolDeprecated = "service.beta.kubernetes.io/linode-loadbalancer-protocol"
annLinodeLoadBalancerTLSDeprecated = "service.beta.kubernetes.io/linode-loadbalancer-tls"
annLinodeProxyProtocol = "service.beta.kubernetes.io/linode-loadbalancer-proxy-protocol"
annLinodeProxyProtocolDeprecated = "service.beta.kubernetes.io/linode-loadbalancer-proxy-protocol"
)

type tlsAnnotationDeprecated struct {
TLSSecretName string `json:"tls-secret-name"`
Port int `json:"port"`
}

func tryDeprecatedTLSAnnotation(service *v1.Service, port int) (portConfigAnnotation, error) {
annotation := portConfigAnnotation{}
tlsAnnotation, err := getTLSAnnotationDeprecated(service, port)
if err != nil {
return annotation, err
}

if tlsAnnotation != nil {
annotation.Protocol = "https"
annotation.TLSSecretName = tlsAnnotation.TLSSecretName
} else if protocol, ok := service.Annotations[annLinodeProtocolDeprecated]; ok {
annotation.Protocol = protocol
}
return annotation, nil
}

func getTLSAnnotationDeprecated(service *v1.Service, port int) (*tlsAnnotationDeprecated, error) {
annotationJSON, ok := service.Annotations[annLinodeLoadBalancerTLSDeprecated]
if !ok {
return nil, nil
}
tlsAnnotations := make([]*tlsAnnotationDeprecated, 0)
err := json.Unmarshal([]byte(annotationJSON), &tlsAnnotations)
if err != nil {
return nil, err
}
for _, tlsAnnotation := range tlsAnnotations {
if tlsAnnotation.Port == port {
return tlsAnnotation, nil
}
}
return nil, nil
}
Loading

0 comments on commit f4cb294

Please sign in to comment.