Deprecate and remove influxdb feature (#9861)
This commit is contained in:
parent
6778c3ec44
commit
297036e169
14 changed files with 0 additions and 696 deletions
|
|
@ -44,7 +44,6 @@ import (
|
|||
"k8s.io/ingress-nginx/internal/ingress/annotations/fastcgi"
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/globalratelimit"
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/http2pushpreload"
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/influxdb"
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/ipdenylist"
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/ipwhitelist"
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/loadbalancing"
|
||||
|
|
@ -115,7 +114,6 @@ type Ingress struct {
|
|||
XForwardedPrefix string
|
||||
SSLCipher sslcipher.Config
|
||||
Logs log.Config
|
||||
InfluxDB influxdb.Config
|
||||
ModSecurity modsecurity.Config
|
||||
Mirror mirror.Config
|
||||
StreamSnippet string
|
||||
|
|
@ -166,7 +164,6 @@ func NewAnnotationExtractor(cfg resolver.Resolver) Extractor {
|
|||
"XForwardedPrefix": xforwardedprefix.NewParser(cfg),
|
||||
"SSLCipher": sslcipher.NewParser(cfg),
|
||||
"Logs": log.NewParser(cfg),
|
||||
"InfluxDB": influxdb.NewParser(cfg),
|
||||
"BackendProtocol": backendprotocol.NewParser(cfg),
|
||||
"ModSecurity": modsecurity.NewParser(cfg),
|
||||
"Mirror": mirror.NewParser(cfg),
|
||||
|
|
|
|||
|
|
@ -1,101 +0,0 @@
|
|||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package influxdb
|
||||
|
||||
import (
|
||||
networking "k8s.io/api/networking/v1"
|
||||
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
|
||||
"k8s.io/ingress-nginx/internal/ingress/resolver"
|
||||
)
|
||||
|
||||
type influxdb struct {
|
||||
r resolver.Resolver
|
||||
}
|
||||
|
||||
// Config contains the IfluxDB configuration to be used in the Ingress
|
||||
type Config struct {
|
||||
InfluxDBEnabled bool `json:"influxDBEnabled"`
|
||||
InfluxDBMeasurement string `json:"influxDBMeasurement"`
|
||||
InfluxDBPort string `json:"influxDBPort"`
|
||||
InfluxDBHost string `json:"influxDBHost"`
|
||||
InfluxDBServerName string `json:"influxDBServerName"`
|
||||
}
|
||||
|
||||
// NewParser creates a new InfluxDB annotation parser
|
||||
func NewParser(r resolver.Resolver) parser.IngressAnnotation {
|
||||
return influxdb{r}
|
||||
}
|
||||
|
||||
// Parse parses the annotations to look for InfluxDB configurations
|
||||
func (c influxdb) Parse(ing *networking.Ingress) (interface{}, error) {
|
||||
var err error
|
||||
config := &Config{}
|
||||
|
||||
config.InfluxDBEnabled, err = parser.GetBoolAnnotation("enable-influxdb", ing)
|
||||
if err != nil {
|
||||
config.InfluxDBEnabled = false
|
||||
}
|
||||
|
||||
config.InfluxDBMeasurement, err = parser.GetStringAnnotation("influxdb-measurement", ing)
|
||||
if err != nil {
|
||||
config.InfluxDBMeasurement = "default"
|
||||
}
|
||||
|
||||
config.InfluxDBPort, err = parser.GetStringAnnotation("influxdb-port", ing)
|
||||
if err != nil {
|
||||
// This is not the default 8086 port but the port usually used to expose
|
||||
// influxdb in UDP, the module uses UDP to talk to influx via the line protocol.
|
||||
config.InfluxDBPort = "8089"
|
||||
}
|
||||
|
||||
config.InfluxDBHost, err = parser.GetStringAnnotation("influxdb-host", ing)
|
||||
if err != nil {
|
||||
config.InfluxDBHost = "127.0.0.1"
|
||||
}
|
||||
|
||||
config.InfluxDBServerName, err = parser.GetStringAnnotation("influxdb-server-name", ing)
|
||||
if err != nil {
|
||||
config.InfluxDBServerName = "nginx-ingress"
|
||||
}
|
||||
|
||||
return config, nil
|
||||
}
|
||||
|
||||
// Equal tests for equality between two Config types
|
||||
func (e1 *Config) Equal(e2 *Config) bool {
|
||||
if e1 == e2 {
|
||||
return true
|
||||
}
|
||||
if e1 == nil || e2 == nil {
|
||||
return false
|
||||
}
|
||||
if e1.InfluxDBEnabled != e2.InfluxDBEnabled {
|
||||
return false
|
||||
}
|
||||
if e1.InfluxDBPort != e2.InfluxDBPort {
|
||||
return false
|
||||
}
|
||||
if e1.InfluxDBHost != e2.InfluxDBHost {
|
||||
return false
|
||||
}
|
||||
if e1.InfluxDBServerName != e2.InfluxDBServerName {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
@ -1,138 +0,0 @@
|
|||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package influxdb
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
api "k8s.io/api/core/v1"
|
||||
networking "k8s.io/api/networking/v1"
|
||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
|
||||
"k8s.io/ingress-nginx/internal/ingress/resolver"
|
||||
)
|
||||
|
||||
func buildIngress() *networking.Ingress {
|
||||
defaultBackend := networking.IngressBackend{
|
||||
Service: &networking.IngressServiceBackend{
|
||||
Name: "default-backend",
|
||||
Port: networking.ServiceBackendPort{
|
||||
Number: 80,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return &networking.Ingress{
|
||||
ObjectMeta: meta_v1.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: networking.IngressSpec{
|
||||
DefaultBackend: &networking.IngressBackend{
|
||||
Service: &networking.IngressServiceBackend{
|
||||
Name: "default-backend",
|
||||
Port: networking.ServiceBackendPort{
|
||||
Number: 80,
|
||||
},
|
||||
},
|
||||
},
|
||||
Rules: []networking.IngressRule{
|
||||
{
|
||||
Host: "foo.bar.com",
|
||||
IngressRuleValue: networking.IngressRuleValue{
|
||||
HTTP: &networking.HTTPIngressRuleValue{
|
||||
Paths: []networking.HTTPIngressPath{
|
||||
{
|
||||
Path: "/foo",
|
||||
Backend: defaultBackend,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func TestIngressInvalidInfluxDB(t *testing.T) {
|
||||
ing := buildIngress()
|
||||
|
||||
influx, _ := NewParser(&resolver.Mock{}).Parse(ing)
|
||||
nginxInflux, ok := influx.(*Config)
|
||||
if !ok {
|
||||
t.Errorf("expected a Config type")
|
||||
}
|
||||
|
||||
if nginxInflux.InfluxDBEnabled == true {
|
||||
t.Errorf("expected influxdb enabled but returned %v", nginxInflux.InfluxDBEnabled)
|
||||
}
|
||||
|
||||
if nginxInflux.InfluxDBMeasurement != "default" {
|
||||
t.Errorf("expected measurement name not found. Found %v", nginxInflux.InfluxDBMeasurement)
|
||||
}
|
||||
|
||||
if nginxInflux.InfluxDBPort != "8089" {
|
||||
t.Errorf("expected port not found. Found %v", nginxInflux.InfluxDBPort)
|
||||
}
|
||||
|
||||
if nginxInflux.InfluxDBHost != "127.0.0.1" {
|
||||
t.Errorf("expected host not found. Found %v", nginxInflux.InfluxDBHost)
|
||||
}
|
||||
|
||||
if nginxInflux.InfluxDBServerName != "nginx-ingress" {
|
||||
t.Errorf("expected server name not found. Found %v", nginxInflux.InfluxDBServerName)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIngressInfluxDB(t *testing.T) {
|
||||
ing := buildIngress()
|
||||
|
||||
data := map[string]string{}
|
||||
data[parser.GetAnnotationWithPrefix("enable-influxdb")] = "true"
|
||||
data[parser.GetAnnotationWithPrefix("influxdb-measurement")] = "nginxmeasures"
|
||||
data[parser.GetAnnotationWithPrefix("influxdb-port")] = "9091"
|
||||
data[parser.GetAnnotationWithPrefix("influxdb-host")] = "10.99.0.13"
|
||||
data[parser.GetAnnotationWithPrefix("influxdb-server-name")] = "nginx-test-1"
|
||||
ing.SetAnnotations(data)
|
||||
|
||||
influx, _ := NewParser(&resolver.Mock{}).Parse(ing)
|
||||
nginxInflux, ok := influx.(*Config)
|
||||
if !ok {
|
||||
t.Errorf("expected a Config type")
|
||||
}
|
||||
|
||||
if !nginxInflux.InfluxDBEnabled {
|
||||
t.Errorf("expected influxdb enabled but returned %v", nginxInflux.InfluxDBEnabled)
|
||||
}
|
||||
|
||||
if nginxInflux.InfluxDBMeasurement != "nginxmeasures" {
|
||||
t.Errorf("expected measurement name not found. Found %v", nginxInflux.InfluxDBMeasurement)
|
||||
}
|
||||
|
||||
if nginxInflux.InfluxDBPort != "9091" {
|
||||
t.Errorf("expected port not found. Found %v", nginxInflux.InfluxDBPort)
|
||||
}
|
||||
|
||||
if nginxInflux.InfluxDBHost != "10.99.0.13" {
|
||||
t.Errorf("expected host not found. Found %v", nginxInflux.InfluxDBHost)
|
||||
}
|
||||
|
||||
if nginxInflux.InfluxDBServerName != "nginx-test-1" {
|
||||
t.Errorf("expected server name not found. Found %v", nginxInflux.InfluxDBServerName)
|
||||
}
|
||||
}
|
||||
|
|
@ -1460,7 +1460,6 @@ func locationApplyAnnotations(loc *ingress.Location, anns *annotations.Ingress)
|
|||
loc.UsePortInRedirects = anns.UsePortInRedirects
|
||||
loc.Connection = anns.Connection
|
||||
loc.Logs = anns.Logs
|
||||
loc.InfluxDB = anns.InfluxDB
|
||||
loc.DefaultBackend = anns.DefaultBackend
|
||||
loc.BackendProtocol = anns.BackendProtocol
|
||||
loc.FastCGI = anns.FastCGI
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ import (
|
|||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/influxdb"
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/ratelimit"
|
||||
"k8s.io/ingress-nginx/internal/ingress/controller/config"
|
||||
|
|
@ -267,7 +266,6 @@ var (
|
|||
"buildOpentracing": buildOpentracing,
|
||||
"buildOpentelemetry": buildOpentelemetry,
|
||||
"proxySetHeader": proxySetHeader,
|
||||
"buildInfluxDB": buildInfluxDB,
|
||||
"enforceRegexModifier": enforceRegexModifier,
|
||||
"buildCustomErrorDeps": buildCustomErrorDeps,
|
||||
"buildCustomErrorLocationsPerServer": buildCustomErrorLocationsPerServer,
|
||||
|
|
@ -281,7 +279,6 @@ var (
|
|||
"buildModSecurityForLocation": buildModSecurityForLocation,
|
||||
"buildMirrorLocations": buildMirrorLocations,
|
||||
"shouldLoadAuthDigestModule": shouldLoadAuthDigestModule,
|
||||
"shouldLoadInfluxDBModule": shouldLoadInfluxDBModule,
|
||||
"buildServerName": buildServerName,
|
||||
"buildCorsOriginRegex": buildCorsOriginRegex,
|
||||
}
|
||||
|
|
@ -1269,29 +1266,6 @@ func buildOpentelemetry(c interface{}, s interface{}) string {
|
|||
return buf.String()
|
||||
}
|
||||
|
||||
// buildInfluxDB produces the single line configuration
|
||||
// needed by the InfluxDB module to send request's metrics
|
||||
// for the current resource
|
||||
func buildInfluxDB(input interface{}) string {
|
||||
cfg, ok := input.(influxdb.Config)
|
||||
if !ok {
|
||||
klog.Errorf("expected an 'influxdb.Config' type but %T was returned", input)
|
||||
return ""
|
||||
}
|
||||
|
||||
if !cfg.InfluxDBEnabled {
|
||||
return ""
|
||||
}
|
||||
|
||||
return fmt.Sprintf(
|
||||
"influxdb server_name=%s host=%s port=%s measurement=%s enabled=true;",
|
||||
cfg.InfluxDBServerName,
|
||||
cfg.InfluxDBHost,
|
||||
cfg.InfluxDBPort,
|
||||
cfg.InfluxDBMeasurement,
|
||||
)
|
||||
}
|
||||
|
||||
func proxySetHeader(loc interface{}) string {
|
||||
location, ok := loc.(*ingress.Location)
|
||||
if !ok {
|
||||
|
|
@ -1797,25 +1771,6 @@ func shouldLoadAuthDigestModule(s interface{}) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// shouldLoadInfluxDBModule determines whether or not the ngx_http_auth_digest_module module needs to be loaded.
|
||||
func shouldLoadInfluxDBModule(s interface{}) bool {
|
||||
servers, ok := s.([]*ingress.Server)
|
||||
if !ok {
|
||||
klog.Errorf("expected an '[]*ingress.Server' type but %T was returned", s)
|
||||
return false
|
||||
}
|
||||
|
||||
for _, server := range servers {
|
||||
for _, location := range server.Locations {
|
||||
if location.InfluxDB.InfluxDBEnabled {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// buildServerName ensures wildcard hostnames are valid
|
||||
func buildServerName(hostname string) string {
|
||||
if !strings.HasPrefix(hostname, "*") {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ import (
|
|||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/authreq"
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/influxdb"
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/modsecurity"
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/opentelemetry"
|
||||
"k8s.io/ingress-nginx/internal/ingress/annotations/opentracing"
|
||||
|
|
@ -1640,30 +1639,6 @@ func TestProxySetHeader(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestBuildInfluxDB(t *testing.T) {
|
||||
invalidType := &ingress.Ingress{}
|
||||
expected := ""
|
||||
actual := buildInfluxDB(invalidType)
|
||||
|
||||
if expected != actual {
|
||||
t.Errorf("Expected '%v' but returned '%v'", expected, actual)
|
||||
}
|
||||
|
||||
cfg := influxdb.Config{
|
||||
InfluxDBEnabled: true,
|
||||
InfluxDBServerName: "ok.com",
|
||||
InfluxDBHost: "host.com",
|
||||
InfluxDBPort: "5252",
|
||||
InfluxDBMeasurement: "ok",
|
||||
}
|
||||
expected = "influxdb server_name=ok.com host=host.com port=5252 measurement=ok enabled=true;"
|
||||
actual = buildInfluxDB(cfg)
|
||||
|
||||
if expected != actual {
|
||||
t.Errorf("Expected '%v' but returned '%v'", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildOpenTracing(t *testing.T) {
|
||||
invalidType := &ingress.Ingress{}
|
||||
expected := ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue