Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated annotations #873

Merged
merged 4 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/guides/upstream-mtls.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ server that it talks to.

To configure a different client certificate for each service or only for a
subset of services, you can do so using the
[`configuration.konghq.com/client-cert`](../references/annotations.md#configurationkonghqcom/client-cert)
[`konghq.com/client-cert`](../references/annotations.md#konghqcom/client-cert)
annotation.

To use the annotation, you first need to create a TLS secret with the
Expand All @@ -96,7 +96,7 @@ Service to which Kong should authenticate itself.
Once the secret is in place, add the follow annotation on the service:

```
configuration.konghq.com/client-cert: <name-of-secret>
konghq.com/client-cert: <name-of-secret>
```

Kong will then use the TLS key-pair to authenticate itself against that service.
38 changes: 0 additions & 38 deletions docs/references/annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ Following annotations are supported on Ingress resources:
| [`konghq.com/regex-priority`](#konghqcomregex-priority) | Set the route's regex priority. |
| [`konghq.com/methods`](#konghqcommethods) | Set methods matched by this Ingress. |
| [`konghq.com/override`](#konghqcomoverride) | Control other routing attributes via `KongIngress` resource. |
| DEPRECATED [`plugins.konghq.com`](#pluginskonghqcom) | Please use [`konghq.com/plugins`](#konghqcomplugins) |
| DEPRECATED [`configuration.konghq.com`](#configurationkonghqcom) | Please use [`konghq.com/override`](#konghqcomoverride) |
| DEPRECATED [`configuration.konghq.com/protocols`](#configurationkonghqcomprotocols) | Please use [`konghq.com/protocols`](#konghqcomprotocols) |

`kubernetes.io/ingress.class` is normally required, and its value should match
the value of the `--ingress-class` controller argument ("kong" by default).
Expand All @@ -44,10 +41,6 @@ Following annotations are supported on Service resources:
| [`konghq.com/host-header`](#konghqcomhost-header) | Set the value sent in the `Host` header when proxying requests upstream |
| [`konghq.com/override`](#konghqcomoverride) | Fine grained routing and load-balancing |
| [`ingress.kubernetes.io/service-upstream`](#ingresskubernetesioservice-upstream) | Offload load-balancing to kube-proxy or sidecar |
| DEPRECATED [`plugins.konghq.com`](#pluginskonghqcom) | Please use [`konghq.com/plugins`](#konghqcomplugins) |
| DEPRECATED [`configuration.konghq.com`](#configurationkonghqcom) | Please use [`konghq.com/override`](#konghqcomoverride) |
| DEPRECATED [`configuration.konghq.com/protocol`](#configurationkonghqcomprotocol) | Please use [`konghq.com/protocol`](#konghqcomprotocol) |
| DEPRECATED [`configuration.konghq.com/client-cert`](#configurationkonghqcomclient-cert) | Please use [`konghq.com/client-cert`](#konghqcomclient-cert) |

## KongConsumer resource

Expand All @@ -57,7 +50,6 @@ Following annotaitons are supported on KongConsumer resources:
|-----------------|-------------|
| REQUIRED [`kubernetes.io/ingress.class`](#kubernetesioingressclass) | Restrict the KongConsumers that a controller should satisfy |
| [`konghq.com/plugins`](#konghqcomplugins) | Run plugins for a specific consumer |
| DEPRECATED [`plugins.konghq.com`](#pluginskonghqcom) | Please use [`konghq.com/plugins`](#konghqcomplugins) |

`kubernetes.io/ingress.class` is normally required, and its value should match
the value of the `--ingress-class` controller argument ("kong" by default).
Expand Down Expand Up @@ -430,33 +422,3 @@ annotations:
```

You need Kong Ingress Controller >= 0.6 for this annotation.

### `plugins.konghq.com`

> DEPRECATED in Controller 0.8

Please instead use [`konghq.com/plugins`](#konghqcomplugins).

### `configuration.konghq.com`

> DEPRECATED in Controller 0.8

Please instead use [`konghq.com/override`](#konghqcomoverride).

### `configuration.konghq.com/protocol`

> DEPRECATED in Controller 0.8

Please instead use [`konghq.com/protocol`](#konghqcomprotocol).

### `configuration.konghq.com/protocols`

> DEPRECATED in Controller 0.8

Please instead use [`konghq.com/protocols`](#konghqcomprotocols).

### `configuration.konghq.com/client-cert`

> DEPRECATED in Controller 0.8

Please instead use [`konghq.com/client-cert`](#konghqcomclient-cert).
86 changes: 30 additions & 56 deletions internal/ingress/annotations/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,20 @@ const (
const (
IngressClassKey = "kubernetes.io/ingress.class"

deprecatedAnnotationPrefix = "configuration.konghq.com"
annotationPrefix = "konghq.com"

DeprecatedPluginsKey = "plugins.konghq.com"
deprecatedConfigurationKey = deprecatedAnnotationPrefix

configurationKey = "/override"
pluginsKey = "/plugins"
protocolKey = "/protocol"
protocolsKey = "/protocols"
clientCertKey = "/client-cert"
stripPathKey = "/strip-path"
pathKey = "/path"
httpsRedirectCodeKey = "/https-redirect-status-code"
preserveHostKey = "/preserve-host"
regexPriorityKey = "/regex-priority"
hostHeaderKey = "/host-header"
methodsKey = "/methods"
AnnotationPrefix = "konghq.com"

ConfigurationKey = "/override"
PluginsKey = "/plugins"
ProtocolKey = "/protocol"
ProtocolsKey = "/protocols"
ClientCertKey = "/client-cert"
StripPathKey = "/strip-path"
PathKey = "/path"
HTTPSRedirectCodeKey = "/https-redirect-status-code"
PreserveHostKey = "/preserve-host"
RegexPriorityKey = "/regex-priority"
HostHeaderKey = "/host-header"
MethodsKey = "/methods"

// DefaultIngressClass defines the default class used
// by Kong's ingress controller.
Expand Down Expand Up @@ -111,35 +107,17 @@ func IngressClassValidatorFuncFromV1Ingress(
}
}

// valueFromAnnotation returns the value of an annotation with key.
// key is without the annotation prefix of configuration.konghq.com or
// konghq.com.
// It first looks up key under the konghq.com group and if one doesn't
// exist then it looks up the configuration.konghq.com annotation group.
func valueFromAnnotation(key string, anns map[string]string) string {
value, exists := anns[annotationPrefix+key]
if exists {
return value
}
return anns[deprecatedAnnotationPrefix+key]
}

func pluginsFromAnnotations(anns map[string]string) (string, bool) {
value, exists := anns[annotationPrefix+pluginsKey]
if exists {
return value, exists
}
value, exists = anns[DeprecatedPluginsKey]
return value, exists
func pluginsFromAnnotations(anns map[string]string) string {
return anns[AnnotationPrefix+PluginsKey]
}

// ExtractKongPluginsFromAnnotations extracts information about Kong
// Plugins configured using plugins.konghq.com annotation.
// Plugins configured using konghq.com/plugins annotation.
// This returns a list of KongPlugin resource names that should be applied.
func ExtractKongPluginsFromAnnotations(anns map[string]string) []string {
var kongPluginCRs []string
v, ok := pluginsFromAnnotations(anns)
if !ok {
v := pluginsFromAnnotations(anns)
if v == "" {
return kongPluginCRs
}
for _, kongPlugin := range strings.Split(v, ",") {
Expand All @@ -154,46 +132,42 @@ func ExtractKongPluginsFromAnnotations(anns map[string]string) []string {
// ExtractConfigurationName extracts the name of the KongIngress object that holds
// information about the configuration to use in Routes, Services and Upstreams
func ExtractConfigurationName(anns map[string]string) string {
value, exists := anns[annotationPrefix+configurationKey]
if exists {
return value
}
return anns[deprecatedConfigurationKey]
return anns[AnnotationPrefix+ConfigurationKey]
}

// ExtractProtocolName extracts the protocol supplied in the annotation
func ExtractProtocolName(anns map[string]string) string {
return valueFromAnnotation(protocolKey, anns)
return anns[AnnotationPrefix+ProtocolKey]
}

// ExtractProtocolNames extracts the protocols supplied in the annotation
func ExtractProtocolNames(anns map[string]string) []string {
val := valueFromAnnotation(protocolsKey, anns)
val := anns[AnnotationPrefix+ProtocolsKey]
return strings.Split(val, ",")
}

// ExtractClientCertificate extracts the secret name containing the
// client-certificate to use.
func ExtractClientCertificate(anns map[string]string) string {
return valueFromAnnotation(clientCertKey, anns)
return anns[AnnotationPrefix+ClientCertKey]
}

// ExtractStripPath extracts the strip-path annotations containing the
// the boolean string "true" or "false".
func ExtractStripPath(anns map[string]string) string {
return valueFromAnnotation(stripPathKey, anns)
return anns[AnnotationPrefix+StripPathKey]
}

// ExtractPath extracts the path annotations containing the
// HTTP path.
func ExtractPath(anns map[string]string) string {
return valueFromAnnotation(pathKey, anns)
return anns[AnnotationPrefix+PathKey]
}

// ExtractHTTPSRedirectStatusCode extracts the https redirect status
// code annotation value.
func ExtractHTTPSRedirectStatusCode(anns map[string]string) string {
return valueFromAnnotation(httpsRedirectCodeKey, anns)
return anns[AnnotationPrefix+HTTPSRedirectCodeKey]
}

// HasForceSSLRedirectAnnotation returns true if the annotation
Expand All @@ -204,7 +178,7 @@ func HasForceSSLRedirectAnnotation(anns map[string]string) bool {

// ExtractPreserveHost extracts the preserve-host annotation value.
func ExtractPreserveHost(anns map[string]string) string {
return valueFromAnnotation(preserveHostKey, anns)
return anns[AnnotationPrefix+PreserveHostKey]
}

// HasServiceUpstreamAnnotation returns true if the annotation
Expand All @@ -215,17 +189,17 @@ func HasServiceUpstreamAnnotation(anns map[string]string) bool {

// ExtractRegexPriority extracts the host-header annotation value.
func ExtractRegexPriority(anns map[string]string) string {
return valueFromAnnotation(regexPriorityKey, anns)
return anns[AnnotationPrefix+RegexPriorityKey]
}

// ExtractHostHeader extracts the regex-priority annotation value.
func ExtractHostHeader(anns map[string]string) string {
return valueFromAnnotation(hostHeaderKey, anns)
return anns[AnnotationPrefix+HostHeaderKey]
}

// ExtractMethods extracts the methods annotation value.
func ExtractMethods(anns map[string]string) []string {
val := valueFromAnnotation(methodsKey, anns)
val := anns[AnnotationPrefix+MethodsKey]
if val == "" {
return []string{}
}
Expand Down
Loading