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)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue