Replace glog with klog
This commit is contained in:
parent
f4a4daed84
commit
2fa55eabf6
33 changed files with 353 additions and 327 deletions
|
@ -70,7 +70,8 @@ func TestFlagConflict(t *testing.T) {
|
||||||
defer func() { os.Args = oldArgs }()
|
defer func() { os.Args = oldArgs }()
|
||||||
os.Args = []string{"cmd", "--publish-service", "namespace/test", "--http-port", "0", "--https-port", "0", "--publish-status-address", "1.1.1.1"}
|
os.Args = []string{"cmd", "--publish-service", "namespace/test", "--http-port", "0", "--https-port", "0", "--publish-status-address", "1.1.1.1"}
|
||||||
|
|
||||||
_, _, err := parseFlags()
|
_, c, err := parseFlags()
|
||||||
|
t.Logf("%v", c)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("Expected an error parsing flags but none returned")
|
t.Fatalf("Expected an error parsing flags but none returned")
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,10 +21,10 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
|
|
||||||
apiv1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
|
"k8s.io/klog"
|
||||||
|
|
||||||
"k8s.io/ingress-nginx/internal/ingress/annotations/class"
|
"k8s.io/ingress-nginx/internal/ingress/annotations/class"
|
||||||
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
|
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
|
||||||
|
@ -168,7 +168,7 @@ Feature backed by OpenResty Lua libraries. Requires that OCSP stapling is not en
|
||||||
flag.CommandLine.Parse([]string{})
|
flag.CommandLine.Parse([]string{})
|
||||||
|
|
||||||
pflag.VisitAll(func(flag *pflag.Flag) {
|
pflag.VisitAll(func(flag *pflag.Flag) {
|
||||||
glog.V(2).Infof("FLAG: --%s=%q", flag.Name, flag.Value)
|
klog.V(2).Infof("FLAG: --%s=%q", flag.Name, flag.Value)
|
||||||
})
|
})
|
||||||
|
|
||||||
if *showVersion {
|
if *showVersion {
|
||||||
|
@ -176,10 +176,10 @@ Feature backed by OpenResty Lua libraries. Requires that OCSP stapling is not en
|
||||||
}
|
}
|
||||||
|
|
||||||
if *ingressClass != "" {
|
if *ingressClass != "" {
|
||||||
glog.Infof("Watching for Ingress class: %s", *ingressClass)
|
klog.Infof("Watching for Ingress class: %s", *ingressClass)
|
||||||
|
|
||||||
if *ingressClass != class.DefaultClass {
|
if *ingressClass != class.DefaultClass {
|
||||||
glog.Warningf("Only Ingresses with class %q will be processed by this Ingress controller", *ingressClass)
|
klog.Warningf("Only Ingresses with class %q will be processed by this Ingress controller", *ingressClass)
|
||||||
}
|
}
|
||||||
|
|
||||||
class.IngressClass = *ingressClass
|
class.IngressClass = *ingressClass
|
||||||
|
@ -209,7 +209,7 @@ Feature backed by OpenResty Lua libraries. Requires that OCSP stapling is not en
|
||||||
}
|
}
|
||||||
|
|
||||||
if !*enableSSLChainCompletion {
|
if !*enableSSLChainCompletion {
|
||||||
glog.Warningf("SSL certificate chain completion is disabled (--enable-ssl-chain-completion=false)")
|
klog.Warningf("SSL certificate chain completion is disabled (--enable-ssl-chain-completion=false)")
|
||||||
}
|
}
|
||||||
|
|
||||||
if *enableSSLChainCompletion && *dynamicCertificatesEnabled {
|
if *enableSSLChainCompletion && *dynamicCertificatesEnabled {
|
||||||
|
|
|
@ -28,7 +28,6 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
|
|
||||||
|
@ -38,6 +37,7 @@ import (
|
||||||
"k8s.io/apiserver/pkg/server/healthz"
|
"k8s.io/apiserver/pkg/server/healthz"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
|
"k8s.io/klog"
|
||||||
|
|
||||||
"k8s.io/ingress-nginx/internal/file"
|
"k8s.io/ingress-nginx/internal/file"
|
||||||
"k8s.io/ingress-nginx/internal/ingress/controller"
|
"k8s.io/ingress-nginx/internal/ingress/controller"
|
||||||
|
@ -59,6 +59,8 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
klog.InitFlags(nil)
|
||||||
|
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
|
||||||
fmt.Println(version.String())
|
fmt.Println(version.String())
|
||||||
|
@ -69,14 +71,14 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatal(err)
|
klog.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
nginxVersion()
|
nginxVersion()
|
||||||
|
|
||||||
fs, err := file.NewLocalFS()
|
fs, err := file.NewLocalFS()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatal(err)
|
klog.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
kubeClient, err := createApiserverClient(conf.APIServerHost, conf.KubeConfigFile)
|
kubeClient, err := createApiserverClient(conf.APIServerHost, conf.KubeConfigFile)
|
||||||
|
@ -87,24 +89,24 @@ func main() {
|
||||||
if len(conf.DefaultService) > 0 {
|
if len(conf.DefaultService) > 0 {
|
||||||
defSvcNs, defSvcName, err := k8s.ParseNameNS(conf.DefaultService)
|
defSvcNs, defSvcName, err := k8s.ParseNameNS(conf.DefaultService)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatal(err)
|
klog.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = kubeClient.CoreV1().Services(defSvcNs).Get(defSvcName, metav1.GetOptions{})
|
_, err = kubeClient.CoreV1().Services(defSvcNs).Get(defSvcName, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO (antoineco): compare with error types from k8s.io/apimachinery/pkg/api/errors
|
// TODO (antoineco): compare with error types from k8s.io/apimachinery/pkg/api/errors
|
||||||
if strings.Contains(err.Error(), "cannot get services in the namespace") {
|
if strings.Contains(err.Error(), "cannot get services in the namespace") {
|
||||||
glog.Fatal("✖ The cluster seems to be running with a restrictive Authorization mode and the Ingress controller does not have the required permissions to operate normally.")
|
klog.Fatal("✖ The cluster seems to be running with a restrictive Authorization mode and the Ingress controller does not have the required permissions to operate normally.")
|
||||||
}
|
}
|
||||||
glog.Fatalf("No service with name %v found: %v", conf.DefaultService, err)
|
klog.Fatalf("No service with name %v found: %v", conf.DefaultService, err)
|
||||||
}
|
}
|
||||||
glog.Infof("Validated %v as the default backend.", conf.DefaultService)
|
klog.Infof("Validated %v as the default backend.", conf.DefaultService)
|
||||||
}
|
}
|
||||||
|
|
||||||
if conf.Namespace != "" {
|
if conf.Namespace != "" {
|
||||||
_, err = kubeClient.CoreV1().Namespaces().Get(conf.Namespace, metav1.GetOptions{})
|
_, err = kubeClient.CoreV1().Namespaces().Get(conf.Namespace, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("No namespace with name %v found: %v", conf.Namespace, err)
|
klog.Fatalf("No namespace with name %v found: %v", conf.Namespace, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +114,7 @@ func main() {
|
||||||
defCert, defKey := ssl.GetFakeSSLCert()
|
defCert, defKey := ssl.GetFakeSSLCert()
|
||||||
c, err := ssl.AddOrUpdateCertAndKey(fakeCertificate, defCert, defKey, []byte{}, fs)
|
c, err := ssl.AddOrUpdateCertAndKey(fakeCertificate, defCert, defKey, []byte{}, fs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("Error generating self-signed certificate: %v", err)
|
klog.Fatalf("Error generating self-signed certificate: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.FakeCertificatePath = c.PemFileName
|
conf.FakeCertificatePath = c.PemFileName
|
||||||
|
@ -132,7 +134,7 @@ func main() {
|
||||||
if conf.EnableMetrics {
|
if conf.EnableMetrics {
|
||||||
mc, err = metric.NewCollector(conf.ListenPorts.Status, reg)
|
mc, err = metric.NewCollector(conf.ListenPorts.Status, reg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("Error creating prometheus collector: %v", err)
|
klog.Fatalf("Error creating prometheus collector: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mc.Start()
|
mc.Start()
|
||||||
|
@ -163,18 +165,18 @@ func handleSigterm(ngx *controller.NGINXController, exit exiter) {
|
||||||
signalChan := make(chan os.Signal, 1)
|
signalChan := make(chan os.Signal, 1)
|
||||||
signal.Notify(signalChan, syscall.SIGTERM)
|
signal.Notify(signalChan, syscall.SIGTERM)
|
||||||
<-signalChan
|
<-signalChan
|
||||||
glog.Info("Received SIGTERM, shutting down")
|
klog.Info("Received SIGTERM, shutting down")
|
||||||
|
|
||||||
exitCode := 0
|
exitCode := 0
|
||||||
if err := ngx.Stop(); err != nil {
|
if err := ngx.Stop(); err != nil {
|
||||||
glog.Infof("Error during shutdown: %v", err)
|
klog.Infof("Error during shutdown: %v", err)
|
||||||
exitCode = 1
|
exitCode = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.Info("Handled quit, awaiting Pod deletion")
|
klog.Info("Handled quit, awaiting Pod deletion")
|
||||||
time.Sleep(10 * time.Second)
|
time.Sleep(10 * time.Second)
|
||||||
|
|
||||||
glog.Infof("Exiting with %v", exitCode)
|
klog.Infof("Exiting with %v", exitCode)
|
||||||
exit(exitCode)
|
exit(exitCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +198,7 @@ func createApiserverClient(apiserverHost, kubeConfig string) (*kubernetes.Client
|
||||||
cfg.Burst = defaultBurst
|
cfg.Burst = defaultBurst
|
||||||
cfg.ContentType = "application/vnd.kubernetes.protobuf"
|
cfg.ContentType = "application/vnd.kubernetes.protobuf"
|
||||||
|
|
||||||
glog.Infof("Creating API client for %s", cfg.Host)
|
klog.Infof("Creating API client for %s", cfg.Host)
|
||||||
|
|
||||||
client, err := kubernetes.NewForConfig(cfg)
|
client, err := kubernetes.NewForConfig(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -216,7 +218,7 @@ func createApiserverClient(apiserverHost, kubeConfig string) (*kubernetes.Client
|
||||||
|
|
||||||
var lastErr error
|
var lastErr error
|
||||||
retries := 0
|
retries := 0
|
||||||
glog.V(2).Info("Trying to discover Kubernetes version")
|
klog.V(2).Info("Trying to discover Kubernetes version")
|
||||||
err = wait.ExponentialBackoff(defaultRetry, func() (bool, error) {
|
err = wait.ExponentialBackoff(defaultRetry, func() (bool, error) {
|
||||||
v, err = client.Discovery().ServerVersion()
|
v, err = client.Discovery().ServerVersion()
|
||||||
|
|
||||||
|
@ -225,7 +227,7 @@ func createApiserverClient(apiserverHost, kubeConfig string) (*kubernetes.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
lastErr = err
|
lastErr = err
|
||||||
glog.V(2).Infof("Unexpected error discovering Kubernetes version (attempt %v): %v", retries, err)
|
klog.V(2).Infof("Unexpected error discovering Kubernetes version (attempt %v): %v", retries, err)
|
||||||
retries++
|
retries++
|
||||||
return false, nil
|
return false, nil
|
||||||
})
|
})
|
||||||
|
@ -237,10 +239,10 @@ func createApiserverClient(apiserverHost, kubeConfig string) (*kubernetes.Client
|
||||||
|
|
||||||
// this should not happen, warn the user
|
// this should not happen, warn the user
|
||||||
if retries > 0 {
|
if retries > 0 {
|
||||||
glog.Warningf("Initial connection to the Kubernetes API server was retried %d times.", retries)
|
klog.Warningf("Initial connection to the Kubernetes API server was retried %d times.", retries)
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.Infof("Running in Kubernetes cluster version v%v.%v (%v) - git (%v) commit %v - platform %v",
|
klog.Infof("Running in Kubernetes cluster version v%v.%v (%v) - git (%v) commit %v - platform %v",
|
||||||
v.Major, v.Minor, v.GitVersion, v.GitTreeState, v.GitCommit, v.Platform)
|
v.Major, v.Minor, v.GitVersion, v.GitTreeState, v.GitCommit, v.Platform)
|
||||||
|
|
||||||
return client, nil
|
return client, nil
|
||||||
|
@ -248,7 +250,7 @@ func createApiserverClient(apiserverHost, kubeConfig string) (*kubernetes.Client
|
||||||
|
|
||||||
// Handler for fatal init errors. Prints a verbose error message and exits.
|
// Handler for fatal init errors. Prints a verbose error message and exits.
|
||||||
func handleFatalInitError(err error) {
|
func handleFatalInitError(err error) {
|
||||||
glog.Fatalf("Error while initiating a connection to the Kubernetes API server. "+
|
klog.Fatalf("Error while initiating a connection to the Kubernetes API server. "+
|
||||||
"This could mean the cluster is misconfigured (e.g. it has invalid API server certificates "+
|
"This could mean the cluster is misconfigured (e.g. it has invalid API server certificates "+
|
||||||
"or Service Accounts configuration). Reason: %s\n"+
|
"or Service Accounts configuration). Reason: %s\n"+
|
||||||
"Refer to the troubleshooting guide for more information: "+
|
"Refer to the troubleshooting guide for more information: "+
|
||||||
|
@ -266,7 +268,7 @@ func registerHandlers(mux *http.ServeMux) {
|
||||||
mux.HandleFunc("/stop", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/stop", func(w http.ResponseWriter, r *http.Request) {
|
||||||
err := syscall.Kill(syscall.Getpid(), syscall.SIGTERM)
|
err := syscall.Kill(syscall.Getpid(), syscall.SIGTERM)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Unexpected error: %v", err)
|
klog.Errorf("Unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -312,5 +314,5 @@ func startHTTPServer(port int, mux *http.ServeMux) {
|
||||||
WriteTimeout: 300 * time.Second,
|
WriteTimeout: 300 * time.Second,
|
||||||
IdleTimeout: 120 * time.Second,
|
IdleTimeout: 120 * time.Second,
|
||||||
}
|
}
|
||||||
glog.Fatal(server.ListenAndServe())
|
klog.Fatal(server.ListenAndServe())
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,17 +18,18 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"k8s.io/api/core/v1"
|
|
||||||
"k8s.io/client-go/kubernetes"
|
|
||||||
"k8s.io/client-go/kubernetes/fake"
|
|
||||||
"k8s.io/ingress-nginx/internal/file"
|
|
||||||
"k8s.io/ingress-nginx/internal/ingress/controller"
|
|
||||||
"os"
|
"os"
|
||||||
"syscall"
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/client-go/kubernetes"
|
||||||
|
"k8s.io/client-go/kubernetes/fake"
|
||||||
|
|
||||||
|
"k8s.io/ingress-nginx/internal/file"
|
||||||
|
"k8s.io/ingress-nginx/internal/ingress/controller"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCreateApiserverClient(t *testing.T) {
|
func TestCreateApiserverClient(t *testing.T) {
|
||||||
|
|
|
@ -20,13 +20,13 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
)
|
)
|
||||||
|
|
||||||
func nginxVersion() {
|
func nginxVersion() {
|
||||||
flag := "-v"
|
flag := "-v"
|
||||||
|
|
||||||
if glog.V(2) {
|
if klog.V(2) {
|
||||||
flag = "-V"
|
flag = "-V"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ package file
|
||||||
import (
|
import (
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ func SHA1(filename string) string {
|
||||||
hasher := sha1.New()
|
hasher := sha1.New()
|
||||||
s, err := ioutil.ReadFile(filename)
|
s, err := ioutil.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error reading file %v", err)
|
klog.Errorf("Error reading file %v", err)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,11 @@ limitations under the License.
|
||||||
package annotations
|
package annotations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/golang/glog"
|
|
||||||
"github.com/imdario/mergo"
|
"github.com/imdario/mergo"
|
||||||
"k8s.io/ingress-nginx/internal/ingress/annotations/canary"
|
"k8s.io/ingress-nginx/internal/ingress/annotations/canary"
|
||||||
"k8s.io/ingress-nginx/internal/ingress/annotations/modsecurity"
|
"k8s.io/ingress-nginx/internal/ingress/annotations/modsecurity"
|
||||||
"k8s.io/ingress-nginx/internal/ingress/annotations/sslcipher"
|
"k8s.io/ingress-nginx/internal/ingress/annotations/sslcipher"
|
||||||
|
"k8s.io/klog"
|
||||||
|
|
||||||
apiv1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
extensions "k8s.io/api/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
|
@ -156,7 +156,7 @@ func (e Extractor) Extract(ing *extensions.Ingress) *Ingress {
|
||||||
data := make(map[string]interface{})
|
data := make(map[string]interface{})
|
||||||
for name, annotationParser := range e.annotations {
|
for name, annotationParser := range e.annotations {
|
||||||
val, err := annotationParser.Parse(ing)
|
val, err := annotationParser.Parse(ing)
|
||||||
glog.V(5).Infof("annotation %v in Ingress %v/%v: %v", name, ing.GetNamespace(), ing.GetName(), val)
|
klog.V(5).Infof("annotation %v in Ingress %v/%v: %v", name, ing.GetNamespace(), ing.GetName(), val)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.IsMissingAnnotations(err) {
|
if errors.IsMissingAnnotations(err) {
|
||||||
continue
|
continue
|
||||||
|
@ -177,11 +177,11 @@ func (e Extractor) Extract(ing *extensions.Ingress) *Ingress {
|
||||||
_, alreadyDenied := data[DeniedKeyName]
|
_, alreadyDenied := data[DeniedKeyName]
|
||||||
if !alreadyDenied {
|
if !alreadyDenied {
|
||||||
data[DeniedKeyName] = err
|
data[DeniedKeyName] = err
|
||||||
glog.Errorf("error reading %v annotation in Ingress %v/%v: %v", name, ing.GetNamespace(), ing.GetName(), err)
|
klog.Errorf("error reading %v annotation in Ingress %v/%v: %v", name, ing.GetNamespace(), ing.GetName(), err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(5).Infof("error reading %v annotation in Ingress %v/%v: %v", name, ing.GetNamespace(), ing.GetName(), err)
|
klog.V(5).Infof("error reading %v annotation in Ingress %v/%v: %v", name, ing.GetNamespace(), ing.GetName(), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if val != nil {
|
if val != nil {
|
||||||
|
@ -191,7 +191,7 @@ func (e Extractor) Extract(ing *extensions.Ingress) *Ingress {
|
||||||
|
|
||||||
err := mergo.MapWithOverwrite(pia, data)
|
err := mergo.MapWithOverwrite(pia, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("unexpected error merging extracted annotations: %v", err)
|
klog.Errorf("unexpected error merging extracted annotations: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return pia
|
return pia
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
|
|
||||||
extensions "k8s.io/api/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
|
|
||||||
|
@ -146,12 +146,12 @@ func (a authReq) Parse(ing *extensions.Ingress) (interface{}, error) {
|
||||||
// Optional Parameters
|
// Optional Parameters
|
||||||
signIn, err := parser.GetStringAnnotation("auth-signin", ing)
|
signIn, err := parser.GetStringAnnotation("auth-signin", ing)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warning("auth-signin annotation is undefined and will not be set")
|
klog.Warning("auth-signin annotation is undefined and will not be set")
|
||||||
}
|
}
|
||||||
|
|
||||||
authSnippet, err := parser.GetStringAnnotation("auth-snippet", ing)
|
authSnippet, err := parser.GetStringAnnotation("auth-snippet", ing)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warning("auth-snippet annotation is undefined and will not be set")
|
klog.Warning("auth-snippet annotation is undefined and will not be set")
|
||||||
}
|
}
|
||||||
|
|
||||||
responseHeaders := []string{}
|
responseHeaders := []string{}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
extensions "k8s.io/api/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
|
|
||||||
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
|
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
|
||||||
|
@ -57,7 +57,7 @@ func (a backendProtocol) Parse(ing *extensions.Ingress) (interface{}, error) {
|
||||||
|
|
||||||
proto = strings.TrimSpace(strings.ToUpper(proto))
|
proto = strings.TrimSpace(strings.ToUpper(proto))
|
||||||
if !validProtocols.MatchString(proto) {
|
if !validProtocols.MatchString(proto) {
|
||||||
glog.Warningf("Protocol %v is not a valid value for the backend-protocol annotation. Using HTTP as protocol", proto)
|
klog.Warningf("Protocol %v is not a valid value for the backend-protocol annotation. Using HTTP as protocol", proto)
|
||||||
return HTTP, nil
|
return HTTP, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||||
package class
|
package class
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
extensions "k8s.io/api/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ var (
|
||||||
func IsValid(ing *extensions.Ingress) bool {
|
func IsValid(ing *extensions.Ingress) bool {
|
||||||
ingress, ok := ing.GetAnnotations()[IngressKey]
|
ingress, ok := ing.GetAnnotations()[IngressKey]
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.V(3).Infof("annotation %v is not present in ingress %v/%v", IngressKey, ing.Namespace, ing.Name)
|
klog.V(3).Infof("annotation %v is not present in ingress %v/%v", IngressKey, ing.Namespace, ing.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// we have 2 valid combinations
|
// we have 2 valid combinations
|
||||||
|
|
|
@ -19,7 +19,7 @@ package sessionaffinity
|
||||||
import (
|
import (
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
|
|
||||||
extensions "k8s.io/api/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ func (a affinity) Parse(ing *extensions.Ingress) (interface{}, error) {
|
||||||
case "cookie":
|
case "cookie":
|
||||||
cookie = a.cookieAffinityParse(ing)
|
cookie = a.cookieAffinityParse(ing)
|
||||||
default:
|
default:
|
||||||
glog.V(3).Infof("No default affinity was found for Ingress %v", ing.Name)
|
klog.V(3).Infof("No default affinity was found for Ingress %v", ing.Name)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ func (n *NGINXController) Check(_ *http.Request) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check the nginx master process is running
|
// check the nginx master process is running
|
||||||
fs, err := proc.NewFS("/proc")
|
fs, err := proc.NewFS("/proc", false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "unexpected error reading /proc directory")
|
return errors.Wrap(err, "unexpected error reading /proc directory")
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
|
|
||||||
apiv1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
|
|
||||||
|
@ -675,7 +675,7 @@ func NewDefault() Configuration {
|
||||||
NoAuthLocations: "/.well-known/acme-challenge",
|
NoAuthLocations: "/.well-known/acme-challenge",
|
||||||
}
|
}
|
||||||
|
|
||||||
if glog.V(5) {
|
if klog.V(5) {
|
||||||
cfg.ErrorLogLevel = "debug"
|
cfg.ErrorLogLevel = "debug"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
"github.com/mitchellh/hashstructure"
|
"github.com/mitchellh/hashstructure"
|
||||||
|
|
||||||
apiv1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
|
@ -143,7 +143,7 @@ func (n *NGINXController) syncIngress(interface{}) error {
|
||||||
|
|
||||||
for _, loc := range server.Locations {
|
for _, loc := range server.Locations {
|
||||||
if loc.Path != rootLocation {
|
if loc.Path != rootLocation {
|
||||||
glog.Warningf("Ignoring SSL Passthrough for location %q in server %q", loc.Path, server.Hostname)
|
klog.Warningf("Ignoring SSL Passthrough for location %q in server %q", loc.Path, server.Hostname)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
passUpstreams = append(passUpstreams, &ingress.SSLPassthroughBackend{
|
passUpstreams = append(passUpstreams, &ingress.SSLPassthroughBackend{
|
||||||
|
@ -166,12 +166,12 @@ func (n *NGINXController) syncIngress(interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if n.runningConfig.Equal(pcfg) {
|
if n.runningConfig.Equal(pcfg) {
|
||||||
glog.V(3).Infof("No configuration change detected, skipping backend reload.")
|
klog.V(3).Infof("No configuration change detected, skipping backend reload.")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if !n.IsDynamicConfigurationEnough(pcfg) {
|
if !n.IsDynamicConfigurationEnough(pcfg) {
|
||||||
glog.Infof("Configuration changes detected, backend reload required.")
|
klog.Infof("Configuration changes detected, backend reload required.")
|
||||||
|
|
||||||
hash, _ := hashstructure.Hash(pcfg, &hashstructure.HashOptions{
|
hash, _ := hashstructure.Hash(pcfg, &hashstructure.HashOptions{
|
||||||
TagName: "json",
|
TagName: "json",
|
||||||
|
@ -183,13 +183,13 @@ func (n *NGINXController) syncIngress(interface{}) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
n.metricCollector.IncReloadErrorCount()
|
n.metricCollector.IncReloadErrorCount()
|
||||||
n.metricCollector.ConfigSuccess(hash, false)
|
n.metricCollector.ConfigSuccess(hash, false)
|
||||||
glog.Errorf("Unexpected failure reloading the backend:\n%v", err)
|
klog.Errorf("Unexpected failure reloading the backend:\n%v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
n.metricCollector.SetHosts(hosts)
|
n.metricCollector.SetHosts(hosts)
|
||||||
|
|
||||||
glog.Infof("Backend successfully reloaded.")
|
klog.Infof("Backend successfully reloaded.")
|
||||||
n.metricCollector.ConfigSuccess(hash, true)
|
n.metricCollector.ConfigSuccess(hash, true)
|
||||||
n.metricCollector.IncReloadCount()
|
n.metricCollector.IncReloadCount()
|
||||||
n.metricCollector.SetSSLExpireTime(servers)
|
n.metricCollector.SetSSLExpireTime(servers)
|
||||||
|
@ -201,7 +201,7 @@ func (n *NGINXController) syncIngress(interface{}) error {
|
||||||
// start listening on the configured port (default 18080)
|
// start listening on the configured port (default 18080)
|
||||||
// For large configurations it might take a while so we loop
|
// For large configurations it might take a while so we loop
|
||||||
// and back off
|
// and back off
|
||||||
glog.Info("Initial sync, sleeping for 1 second.")
|
klog.Info("Initial sync, sleeping for 1 second.")
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,15 +215,15 @@ func (n *NGINXController) syncIngress(interface{}) error {
|
||||||
err := wait.ExponentialBackoff(retry, func() (bool, error) {
|
err := wait.ExponentialBackoff(retry, func() (bool, error) {
|
||||||
err := configureDynamically(pcfg, n.cfg.ListenPorts.Status, n.cfg.DynamicCertificatesEnabled)
|
err := configureDynamically(pcfg, n.cfg.ListenPorts.Status, n.cfg.DynamicCertificatesEnabled)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
glog.V(2).Infof("Dynamic reconfiguration succeeded.")
|
klog.V(2).Infof("Dynamic reconfiguration succeeded.")
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.Warningf("Dynamic reconfiguration failed: %v", err)
|
klog.Warningf("Dynamic reconfiguration failed: %v", err)
|
||||||
return false, err
|
return false, err
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Unexpected failure reconfiguring NGINX:\n%v", err)
|
klog.Errorf("Unexpected failure reconfiguring NGINX:\n%v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,15 +240,15 @@ func (n *NGINXController) getStreamServices(configmapName string, proto apiv1.Pr
|
||||||
if configmapName == "" {
|
if configmapName == "" {
|
||||||
return []ingress.L4Service{}
|
return []ingress.L4Service{}
|
||||||
}
|
}
|
||||||
glog.V(3).Infof("Obtaining information about %v stream services from ConfigMap %q", proto, configmapName)
|
klog.V(3).Infof("Obtaining information about %v stream services from ConfigMap %q", proto, configmapName)
|
||||||
_, _, err := k8s.ParseNameNS(configmapName)
|
_, _, err := k8s.ParseNameNS(configmapName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error parsing ConfigMap reference %q: %v", configmapName, err)
|
klog.Errorf("Error parsing ConfigMap reference %q: %v", configmapName, err)
|
||||||
return []ingress.L4Service{}
|
return []ingress.L4Service{}
|
||||||
}
|
}
|
||||||
configmap, err := n.store.GetConfigMap(configmapName)
|
configmap, err := n.store.GetConfigMap(configmapName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error getting ConfigMap %q: %v", configmapName, err)
|
klog.Errorf("Error getting ConfigMap %q: %v", configmapName, err)
|
||||||
return []ingress.L4Service{}
|
return []ingress.L4Service{}
|
||||||
}
|
}
|
||||||
var svcs []ingress.L4Service
|
var svcs []ingress.L4Service
|
||||||
|
@ -266,16 +266,16 @@ func (n *NGINXController) getStreamServices(configmapName string, proto apiv1.Pr
|
||||||
for port, svcRef := range configmap.Data {
|
for port, svcRef := range configmap.Data {
|
||||||
externalPort, err := strconv.Atoi(port)
|
externalPort, err := strconv.Atoi(port)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("%q is not a valid %v port number", port, proto)
|
klog.Warningf("%q is not a valid %v port number", port, proto)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if reserverdPorts.Has(externalPort) {
|
if reserverdPorts.Has(externalPort) {
|
||||||
glog.Warningf("Port %d cannot be used for %v stream services. It is reserved for the Ingress controller.", externalPort, proto)
|
klog.Warningf("Port %d cannot be used for %v stream services. It is reserved for the Ingress controller.", externalPort, proto)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
nsSvcPort := strings.Split(svcRef, ":")
|
nsSvcPort := strings.Split(svcRef, ":")
|
||||||
if len(nsSvcPort) < 2 {
|
if len(nsSvcPort) < 2 {
|
||||||
glog.Warningf("Invalid Service reference %q for %v port %d", svcRef, proto, externalPort)
|
klog.Warningf("Invalid Service reference %q for %v port %d", svcRef, proto, externalPort)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
nsName := nsSvcPort[0]
|
nsName := nsSvcPort[0]
|
||||||
|
@ -293,19 +293,19 @@ func (n *NGINXController) getStreamServices(configmapName string, proto apiv1.Pr
|
||||||
}
|
}
|
||||||
svcNs, svcName, err := k8s.ParseNameNS(nsName)
|
svcNs, svcName, err := k8s.ParseNameNS(nsName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("%v", err)
|
klog.Warningf("%v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
svc, err := n.store.GetService(nsName)
|
svc, err := n.store.GetService(nsName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Error getting Service %q: %v", nsName, err)
|
klog.Warningf("Error getting Service %q: %v", nsName, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
var endps []ingress.Endpoint
|
var endps []ingress.Endpoint
|
||||||
targetPort, err := strconv.Atoi(svcPort)
|
targetPort, err := strconv.Atoi(svcPort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// not a port number, fall back to using port name
|
// not a port number, fall back to using port name
|
||||||
glog.V(3).Infof("Searching Endpoints with %v port name %q for Service %q", proto, svcPort, nsName)
|
klog.V(3).Infof("Searching Endpoints with %v port name %q for Service %q", proto, svcPort, nsName)
|
||||||
for _, sp := range svc.Spec.Ports {
|
for _, sp := range svc.Spec.Ports {
|
||||||
if sp.Name == svcPort {
|
if sp.Name == svcPort {
|
||||||
if sp.Protocol == proto {
|
if sp.Protocol == proto {
|
||||||
|
@ -315,7 +315,7 @@ func (n *NGINXController) getStreamServices(configmapName string, proto apiv1.Pr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
glog.V(3).Infof("Searching Endpoints with %v port number %d for Service %q", proto, targetPort, nsName)
|
klog.V(3).Infof("Searching Endpoints with %v port number %d for Service %q", proto, targetPort, nsName)
|
||||||
for _, sp := range svc.Spec.Ports {
|
for _, sp := range svc.Spec.Ports {
|
||||||
if sp.Port == int32(targetPort) {
|
if sp.Port == int32(targetPort) {
|
||||||
if sp.Protocol == proto {
|
if sp.Protocol == proto {
|
||||||
|
@ -328,7 +328,7 @@ func (n *NGINXController) getStreamServices(configmapName string, proto apiv1.Pr
|
||||||
// stream services cannot contain empty upstreams and there is
|
// stream services cannot contain empty upstreams and there is
|
||||||
// no default backend equivalent
|
// no default backend equivalent
|
||||||
if len(endps) == 0 {
|
if len(endps) == 0 {
|
||||||
glog.Warningf("Service %q does not have any active Endpoint for %v port %v", nsName, proto, svcPort)
|
klog.Warningf("Service %q does not have any active Endpoint for %v port %v", nsName, proto, svcPort)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
svcs = append(svcs, ingress.L4Service{
|
svcs = append(svcs, ingress.L4Service{
|
||||||
|
@ -365,14 +365,14 @@ func (n *NGINXController) getDefaultUpstream() *ingress.Backend {
|
||||||
|
|
||||||
svc, err := n.store.GetService(svcKey)
|
svc, err := n.store.GetService(svcKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Error getting default backend %q: %v", svcKey, err)
|
klog.Warningf("Error getting default backend %q: %v", svcKey, err)
|
||||||
upstream.Endpoints = append(upstream.Endpoints, n.DefaultEndpoint())
|
upstream.Endpoints = append(upstream.Endpoints, n.DefaultEndpoint())
|
||||||
return upstream
|
return upstream
|
||||||
}
|
}
|
||||||
|
|
||||||
endps := getEndpoints(svc, &svc.Spec.Ports[0], apiv1.ProtocolTCP, n.store.GetServiceEndpoints)
|
endps := getEndpoints(svc, &svc.Spec.Ports[0], apiv1.ProtocolTCP, n.store.GetServiceEndpoints)
|
||||||
if len(endps) == 0 {
|
if len(endps) == 0 {
|
||||||
glog.Warningf("Service %q does not have any active Endpoint", svcKey)
|
klog.Warningf("Service %q does not have any active Endpoint", svcKey)
|
||||||
endps = []ingress.Endpoint{n.DefaultEndpoint()}
|
endps = []ingress.Endpoint{n.DefaultEndpoint()}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,7 +406,7 @@ func (n *NGINXController) getBackendServers(ingresses []*ingress.Ingress) ([]*in
|
||||||
|
|
||||||
if rule.HTTP == nil &&
|
if rule.HTTP == nil &&
|
||||||
host != defServerName {
|
host != defServerName {
|
||||||
glog.V(3).Infof("Ingress %q does not contain any HTTP rule, using default backend", ingKey)
|
klog.V(3).Infof("Ingress %q does not contain any HTTP rule, using default backend", ingKey)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,16 +417,16 @@ func (n *NGINXController) getBackendServers(ingresses []*ingress.Ingress) ([]*in
|
||||||
if server.CertificateAuth.CAFileName == "" {
|
if server.CertificateAuth.CAFileName == "" {
|
||||||
server.CertificateAuth = anns.CertificateAuth
|
server.CertificateAuth = anns.CertificateAuth
|
||||||
if server.CertificateAuth.Secret != "" && server.CertificateAuth.CAFileName == "" {
|
if server.CertificateAuth.Secret != "" && server.CertificateAuth.CAFileName == "" {
|
||||||
glog.V(3).Infof("Secret %q has no 'ca.crt' key, mutual authentication disabled for Ingress %q",
|
klog.V(3).Infof("Secret %q has no 'ca.crt' key, mutual authentication disabled for Ingress %q",
|
||||||
server.CertificateAuth.Secret, ingKey)
|
server.CertificateAuth.Secret, ingKey)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
glog.V(3).Infof("Server %q is already configured for mutual authentication (Ingress %q)",
|
klog.V(3).Infof("Server %q is already configured for mutual authentication (Ingress %q)",
|
||||||
server.Hostname, ingKey)
|
server.Hostname, ingKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
if rule.HTTP == nil {
|
if rule.HTTP == nil {
|
||||||
glog.V(3).Infof("Ingress %q does not contain any HTTP rule, using default backend", ingKey)
|
klog.V(3).Infof("Ingress %q does not contain any HTTP rule, using default backend", ingKey)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,12 +451,12 @@ func (n *NGINXController) getBackendServers(ingresses []*ingress.Ingress) ([]*in
|
||||||
addLoc = false
|
addLoc = false
|
||||||
|
|
||||||
if !loc.IsDefBackend {
|
if !loc.IsDefBackend {
|
||||||
glog.V(3).Infof("Location %q already configured for server %q with upstream %q (Ingress %q)",
|
klog.V(3).Infof("Location %q already configured for server %q with upstream %q (Ingress %q)",
|
||||||
loc.Path, server.Hostname, loc.Backend, ingKey)
|
loc.Path, server.Hostname, loc.Backend, ingKey)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(3).Infof("Replacing location %q for server %q with upstream %q to use upstream %q (Ingress %q)",
|
klog.V(3).Infof("Replacing location %q for server %q with upstream %q to use upstream %q (Ingress %q)",
|
||||||
loc.Path, server.Hostname, loc.Backend, ups.Name, ingKey)
|
loc.Path, server.Hostname, loc.Backend, ups.Name, ingKey)
|
||||||
|
|
||||||
loc.Backend = ups.Name
|
loc.Backend = ups.Name
|
||||||
|
@ -496,7 +496,7 @@ func (n *NGINXController) getBackendServers(ingresses []*ingress.Ingress) ([]*in
|
||||||
|
|
||||||
// new location
|
// new location
|
||||||
if addLoc {
|
if addLoc {
|
||||||
glog.V(3).Infof("Adding location %q for server %q with upstream %q (Ingress %q)",
|
klog.V(3).Infof("Adding location %q for server %q with upstream %q (Ingress %q)",
|
||||||
nginxPath, server.Hostname, ups.Name, ingKey)
|
nginxPath, server.Hostname, ups.Name, ingKey)
|
||||||
|
|
||||||
loc := &ingress.Location{
|
loc := &ingress.Location{
|
||||||
|
@ -543,7 +543,7 @@ func (n *NGINXController) getBackendServers(ingresses []*ingress.Ingress) ([]*in
|
||||||
if anns.SessionAffinity.Type == "cookie" {
|
if anns.SessionAffinity.Type == "cookie" {
|
||||||
cookiePath := anns.SessionAffinity.Cookie.Path
|
cookiePath := anns.SessionAffinity.Cookie.Path
|
||||||
if anns.Rewrite.UseRegex && cookiePath == "" {
|
if anns.Rewrite.UseRegex && cookiePath == "" {
|
||||||
glog.Warningf("session-cookie-path should be set when use-regex is true")
|
klog.Warningf("session-cookie-path should be set when use-regex is true")
|
||||||
}
|
}
|
||||||
|
|
||||||
ups.SessionAffinity.CookieSessionAffinity.Name = anns.SessionAffinity.Cookie.Name
|
ups.SessionAffinity.CookieSessionAffinity.Name = anns.SessionAffinity.Cookie.Name
|
||||||
|
@ -562,7 +562,7 @@ func (n *NGINXController) getBackendServers(ingresses []*ingress.Ingress) ([]*in
|
||||||
}
|
}
|
||||||
|
|
||||||
if anns.Canary.Enabled {
|
if anns.Canary.Enabled {
|
||||||
glog.Infof("Canary ingress %v detected. Finding eligible backends to merge into.", ing.Name)
|
klog.Infof("Canary ingress %v detected. Finding eligible backends to merge into.", ing.Name)
|
||||||
mergeAlternativeBackends(ing, upstreams, servers)
|
mergeAlternativeBackends(ing, upstreams, servers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -577,13 +577,13 @@ func (n *NGINXController) getBackendServers(ingresses []*ingress.Ingress) ([]*in
|
||||||
for _, location := range server.Locations {
|
for _, location := range server.Locations {
|
||||||
if upstream.Name == location.Backend {
|
if upstream.Name == location.Backend {
|
||||||
if len(upstream.Endpoints) == 0 {
|
if len(upstream.Endpoints) == 0 {
|
||||||
glog.V(3).Infof("Upstream %q has no active Endpoint", upstream.Name)
|
klog.V(3).Infof("Upstream %q has no active Endpoint", upstream.Name)
|
||||||
// check if the location contains endpoints and a custom default backend
|
// check if the location contains endpoints and a custom default backend
|
||||||
if location.DefaultBackend != nil {
|
if location.DefaultBackend != nil {
|
||||||
sp := location.DefaultBackend.Spec.Ports[0]
|
sp := location.DefaultBackend.Spec.Ports[0]
|
||||||
endps := getEndpoints(location.DefaultBackend, &sp, apiv1.ProtocolTCP, n.store.GetServiceEndpoints)
|
endps := getEndpoints(location.DefaultBackend, &sp, apiv1.ProtocolTCP, n.store.GetServiceEndpoints)
|
||||||
if len(endps) > 0 {
|
if len(endps) > 0 {
|
||||||
glog.V(3).Infof("Using custom default backend for location %q in server %q (Service \"%v/%v\")",
|
klog.V(3).Infof("Using custom default backend for location %q in server %q (Service \"%v/%v\")",
|
||||||
location.Path, server.Hostname, location.DefaultBackend.Namespace, location.DefaultBackend.Name)
|
location.Path, server.Hostname, location.DefaultBackend.Namespace, location.DefaultBackend.Name)
|
||||||
|
|
||||||
nb := upstream.DeepCopy()
|
nb := upstream.DeepCopy()
|
||||||
|
@ -599,7 +599,7 @@ func (n *NGINXController) getBackendServers(ingresses []*ingress.Ingress) ([]*in
|
||||||
if server.SSLPassthrough {
|
if server.SSLPassthrough {
|
||||||
if location.Path == rootLocation {
|
if location.Path == rootLocation {
|
||||||
if location.Backend == defUpstreamName {
|
if location.Backend == defUpstreamName {
|
||||||
glog.Warningf("Server %q has no default backend, ignoring SSL Passthrough.", server.Hostname)
|
klog.Warningf("Server %q has no default backend, ignoring SSL Passthrough.", server.Hostname)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
isHTTPSfrom = append(isHTTPSfrom, server)
|
isHTTPSfrom = append(isHTTPSfrom, server)
|
||||||
|
@ -650,7 +650,7 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B
|
||||||
if ing.Spec.Backend != nil {
|
if ing.Spec.Backend != nil {
|
||||||
defBackend = upstreamName(ing.Namespace, ing.Spec.Backend.ServiceName, ing.Spec.Backend.ServicePort)
|
defBackend = upstreamName(ing.Namespace, ing.Spec.Backend.ServiceName, ing.Spec.Backend.ServicePort)
|
||||||
|
|
||||||
glog.V(3).Infof("Creating upstream %q", defBackend)
|
klog.V(3).Infof("Creating upstream %q", defBackend)
|
||||||
upstreams[defBackend] = newUpstream(defBackend)
|
upstreams[defBackend] = newUpstream(defBackend)
|
||||||
if upstreams[defBackend].SecureCACert.Secret == "" {
|
if upstreams[defBackend].SecureCACert.Secret == "" {
|
||||||
upstreams[defBackend].SecureCACert = anns.SecureUpstream.CACert
|
upstreams[defBackend].SecureCACert = anns.SecureUpstream.CACert
|
||||||
|
@ -668,7 +668,7 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B
|
||||||
if anns.ServiceUpstream {
|
if anns.ServiceUpstream {
|
||||||
endpoint, err := n.getServiceClusterEndpoint(svcKey, ing.Spec.Backend)
|
endpoint, err := n.getServiceClusterEndpoint(svcKey, ing.Spec.Backend)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Failed to determine a suitable ClusterIP Endpoint for Service %q: %v", svcKey, err)
|
klog.Errorf("Failed to determine a suitable ClusterIP Endpoint for Service %q: %v", svcKey, err)
|
||||||
} else {
|
} else {
|
||||||
upstreams[defBackend].Endpoints = []ingress.Endpoint{endpoint}
|
upstreams[defBackend].Endpoints = []ingress.Endpoint{endpoint}
|
||||||
}
|
}
|
||||||
|
@ -688,13 +688,13 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B
|
||||||
endps, err := n.serviceEndpoints(svcKey, ing.Spec.Backend.ServicePort.String())
|
endps, err := n.serviceEndpoints(svcKey, ing.Spec.Backend.ServicePort.String())
|
||||||
upstreams[defBackend].Endpoints = append(upstreams[defBackend].Endpoints, endps...)
|
upstreams[defBackend].Endpoints = append(upstreams[defBackend].Endpoints, endps...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Error creating upstream %q: %v", defBackend, err)
|
klog.Warningf("Error creating upstream %q: %v", defBackend, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s, err := n.store.GetService(svcKey)
|
s, err := n.store.GetService(svcKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Error obtaining Service %q: %v", svcKey, err)
|
klog.Warningf("Error obtaining Service %q: %v", svcKey, err)
|
||||||
}
|
}
|
||||||
upstreams[defBackend].Service = s
|
upstreams[defBackend].Service = s
|
||||||
}
|
}
|
||||||
|
@ -711,7 +711,7 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(3).Infof("Creating upstream %q", name)
|
klog.V(3).Infof("Creating upstream %q", name)
|
||||||
upstreams[name] = newUpstream(name)
|
upstreams[name] = newUpstream(name)
|
||||||
upstreams[name].Port = path.Backend.ServicePort
|
upstreams[name].Port = path.Backend.ServicePort
|
||||||
|
|
||||||
|
@ -733,7 +733,7 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B
|
||||||
if anns.ServiceUpstream {
|
if anns.ServiceUpstream {
|
||||||
endpoint, err := n.getServiceClusterEndpoint(svcKey, &path.Backend)
|
endpoint, err := n.getServiceClusterEndpoint(svcKey, &path.Backend)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Failed to determine a suitable ClusterIP Endpoint for Service %q: %v", svcKey, err)
|
klog.Errorf("Failed to determine a suitable ClusterIP Endpoint for Service %q: %v", svcKey, err)
|
||||||
} else {
|
} else {
|
||||||
upstreams[name].Endpoints = []ingress.Endpoint{endpoint}
|
upstreams[name].Endpoints = []ingress.Endpoint{endpoint}
|
||||||
}
|
}
|
||||||
|
@ -752,7 +752,7 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B
|
||||||
if len(upstreams[name].Endpoints) == 0 {
|
if len(upstreams[name].Endpoints) == 0 {
|
||||||
endp, err := n.serviceEndpoints(svcKey, path.Backend.ServicePort.String())
|
endp, err := n.serviceEndpoints(svcKey, path.Backend.ServicePort.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Error obtaining Endpoints for Service %q: %v", svcKey, err)
|
klog.Warningf("Error obtaining Endpoints for Service %q: %v", svcKey, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
upstreams[name].Endpoints = endp
|
upstreams[name].Endpoints = endp
|
||||||
|
@ -760,7 +760,7 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B
|
||||||
|
|
||||||
s, err := n.store.GetService(svcKey)
|
s, err := n.store.GetService(svcKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Error obtaining Service %q: %v", svcKey, err)
|
klog.Warningf("Error obtaining Service %q: %v", svcKey, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -816,7 +816,7 @@ func (n *NGINXController) serviceEndpoints(svcKey, backendPort string) ([]ingres
|
||||||
return upstreams, err
|
return upstreams, err
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(3).Infof("Obtaining ports information for Service %q", svcKey)
|
klog.V(3).Infof("Obtaining ports information for Service %q", svcKey)
|
||||||
for _, servicePort := range svc.Spec.Ports {
|
for _, servicePort := range svc.Spec.Ports {
|
||||||
// targetPort could be a string, use either the port name or number (int)
|
// targetPort could be a string, use either the port name or number (int)
|
||||||
if strconv.Itoa(int(servicePort.Port)) == backendPort ||
|
if strconv.Itoa(int(servicePort.Port)) == backendPort ||
|
||||||
|
@ -825,7 +825,7 @@ func (n *NGINXController) serviceEndpoints(svcKey, backendPort string) ([]ingres
|
||||||
|
|
||||||
endps := getEndpoints(svc, &servicePort, apiv1.ProtocolTCP, n.store.GetServiceEndpoints)
|
endps := getEndpoints(svc, &servicePort, apiv1.ProtocolTCP, n.store.GetServiceEndpoints)
|
||||||
if len(endps) == 0 {
|
if len(endps) == 0 {
|
||||||
glog.Warningf("Service %q does not have any active Endpoint.", svcKey)
|
klog.Warningf("Service %q does not have any active Endpoint.", svcKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
if n.cfg.SortBackends {
|
if n.cfg.SortBackends {
|
||||||
|
@ -848,7 +848,7 @@ func (n *NGINXController) serviceEndpoints(svcKey, backendPort string) ([]ingres
|
||||||
if len(svc.Spec.Ports) == 0 && svc.Spec.Type == apiv1.ServiceTypeExternalName {
|
if len(svc.Spec.Ports) == 0 && svc.Spec.Type == apiv1.ServiceTypeExternalName {
|
||||||
externalPort, err := strconv.Atoi(backendPort)
|
externalPort, err := strconv.Atoi(backendPort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Only numeric ports are allowed in ExternalName Services: %q is not a valid port number.", backendPort)
|
klog.Warningf("Only numeric ports are allowed in ExternalName Services: %q is not a valid port number.", backendPort)
|
||||||
return upstreams, nil
|
return upstreams, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -859,7 +859,7 @@ func (n *NGINXController) serviceEndpoints(svcKey, backendPort string) ([]ingres
|
||||||
}
|
}
|
||||||
endps := getEndpoints(svc, &servicePort, apiv1.ProtocolTCP, n.store.GetServiceEndpoints)
|
endps := getEndpoints(svc, &servicePort, apiv1.ProtocolTCP, n.store.GetServiceEndpoints)
|
||||||
if len(endps) == 0 {
|
if len(endps) == 0 {
|
||||||
glog.Warningf("Service %q does not have any active Endpoint.", svcKey)
|
klog.Warningf("Service %q does not have any active Endpoint.", svcKey)
|
||||||
return upstreams, nil
|
return upstreams, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -950,7 +950,7 @@ func (n *NGINXController) createServers(data []*ingress.Ingress,
|
||||||
// special "catch all" case, Ingress with a backend but no rule
|
// special "catch all" case, Ingress with a backend but no rule
|
||||||
defLoc := servers[defServerName].Locations[0]
|
defLoc := servers[defServerName].Locations[0]
|
||||||
if defLoc.IsDefBackend && len(ing.Spec.Rules) == 0 {
|
if defLoc.IsDefBackend && len(ing.Spec.Rules) == 0 {
|
||||||
glog.Infof("Ingress %q defines a backend but no rule. Using it to configure the catch-all server %q",
|
klog.Infof("Ingress %q defines a backend but no rule. Using it to configure the catch-all server %q",
|
||||||
ingKey, defServerName)
|
ingKey, defServerName)
|
||||||
|
|
||||||
defLoc.IsDefBackend = false
|
defLoc.IsDefBackend = false
|
||||||
|
@ -978,7 +978,7 @@ func (n *NGINXController) createServers(data []*ingress.Ingress,
|
||||||
defLoc.BackendProtocol = anns.BackendProtocol
|
defLoc.BackendProtocol = anns.BackendProtocol
|
||||||
defLoc.ModSecurity = anns.ModSecurity
|
defLoc.ModSecurity = anns.ModSecurity
|
||||||
} else {
|
} else {
|
||||||
glog.V(3).Infof("Ingress %q defines both a backend and rules. Using its backend as default upstream for all its rules.",
|
klog.V(3).Infof("Ingress %q defines both a backend and rules. Using its backend as default upstream for all its rules.",
|
||||||
ingKey)
|
ingKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1029,7 +1029,7 @@ func (n *NGINXController) createServers(data []*ingress.Ingress,
|
||||||
aliases["Alias"] = host
|
aliases["Alias"] = host
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
glog.Warningf("Aliases already configured for server %q, skipping (Ingress %q)",
|
klog.Warningf("Aliases already configured for server %q, skipping (Ingress %q)",
|
||||||
host, ingKey)
|
host, ingKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1038,7 +1038,7 @@ func (n *NGINXController) createServers(data []*ingress.Ingress,
|
||||||
if servers[host].ServerSnippet == "" {
|
if servers[host].ServerSnippet == "" {
|
||||||
servers[host].ServerSnippet = anns.ServerSnippet
|
servers[host].ServerSnippet = anns.ServerSnippet
|
||||||
} else {
|
} else {
|
||||||
glog.Warningf("Server snippet already configured for server %q, skipping (Ingress %q)",
|
klog.Warningf("Server snippet already configured for server %q, skipping (Ingress %q)",
|
||||||
host, ingKey)
|
host, ingKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1054,14 +1054,14 @@ func (n *NGINXController) createServers(data []*ingress.Ingress,
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(ing.Spec.TLS) == 0 {
|
if len(ing.Spec.TLS) == 0 {
|
||||||
glog.V(3).Infof("Ingress %q does not contains a TLS section.", ingKey)
|
klog.V(3).Infof("Ingress %q does not contains a TLS section.", ingKey)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
tlsSecretName := extractTLSSecretName(host, ing, n.store.GetLocalSSLCert)
|
tlsSecretName := extractTLSSecretName(host, ing, n.store.GetLocalSSLCert)
|
||||||
|
|
||||||
if tlsSecretName == "" {
|
if tlsSecretName == "" {
|
||||||
glog.V(3).Infof("Host %q is listed in the TLS section but secretName is empty. Using default certificate.", host)
|
klog.V(3).Infof("Host %q is listed in the TLS section but secretName is empty. Using default certificate.", host)
|
||||||
servers[host].SSLCert.PemFileName = defaultPemFileName
|
servers[host].SSLCert.PemFileName = defaultPemFileName
|
||||||
servers[host].SSLCert.PemSHA = defaultPemSHA
|
servers[host].SSLCert.PemSHA = defaultPemSHA
|
||||||
continue
|
continue
|
||||||
|
@ -1070,7 +1070,7 @@ func (n *NGINXController) createServers(data []*ingress.Ingress,
|
||||||
secrKey := fmt.Sprintf("%v/%v", ing.Namespace, tlsSecretName)
|
secrKey := fmt.Sprintf("%v/%v", ing.Namespace, tlsSecretName)
|
||||||
cert, err := n.store.GetLocalSSLCert(secrKey)
|
cert, err := n.store.GetLocalSSLCert(secrKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Error getting SSL certificate %q: %v. Using default certificate", secrKey, err)
|
klog.Warningf("Error getting SSL certificate %q: %v. Using default certificate", secrKey, err)
|
||||||
servers[host].SSLCert.PemFileName = defaultPemFileName
|
servers[host].SSLCert.PemFileName = defaultPemFileName
|
||||||
servers[host].SSLCert.PemSHA = defaultPemSHA
|
servers[host].SSLCert.PemSHA = defaultPemSHA
|
||||||
continue
|
continue
|
||||||
|
@ -1078,15 +1078,15 @@ func (n *NGINXController) createServers(data []*ingress.Ingress,
|
||||||
|
|
||||||
err = cert.Certificate.VerifyHostname(host)
|
err = cert.Certificate.VerifyHostname(host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Unexpected error validating SSL certificate %q for server %q: %v", secrKey, host, err)
|
klog.Warningf("Unexpected error validating SSL certificate %q for server %q: %v", secrKey, host, err)
|
||||||
glog.Warning("Validating certificate against DNS names. This will be deprecated in a future version.")
|
klog.Warning("Validating certificate against DNS names. This will be deprecated in a future version.")
|
||||||
// check the Common Name field
|
// check the Common Name field
|
||||||
// https://github.com/golang/go/issues/22922
|
// https://github.com/golang/go/issues/22922
|
||||||
err := verifyHostname(host, cert.Certificate)
|
err := verifyHostname(host, cert.Certificate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("SSL certificate %q does not contain a Common Name or Subject Alternative Name for server %q: %v",
|
klog.Warningf("SSL certificate %q does not contain a Common Name or Subject Alternative Name for server %q: %v",
|
||||||
secrKey, host, err)
|
secrKey, host, err)
|
||||||
glog.Warningf("Using default certificate")
|
klog.Warningf("Using default certificate")
|
||||||
servers[host].SSLCert.PemFileName = defaultPemFileName
|
servers[host].SSLCert.PemFileName = defaultPemFileName
|
||||||
servers[host].SSLCert.PemSHA = defaultPemSHA
|
servers[host].SSLCert.PemSHA = defaultPemSHA
|
||||||
continue
|
continue
|
||||||
|
@ -1102,14 +1102,14 @@ func (n *NGINXController) createServers(data []*ingress.Ingress,
|
||||||
servers[host].SSLCert = *cert
|
servers[host].SSLCert = *cert
|
||||||
|
|
||||||
if cert.ExpireTime.Before(time.Now().Add(240 * time.Hour)) {
|
if cert.ExpireTime.Before(time.Now().Add(240 * time.Hour)) {
|
||||||
glog.Warningf("SSL certificate for server %q is about to expire (%v)", host, cert.ExpireTime)
|
klog.Warningf("SSL certificate for server %q is about to expire (%v)", host, cert.ExpireTime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for alias, host := range aliases {
|
for alias, host := range aliases {
|
||||||
if _, ok := servers[alias]; ok {
|
if _, ok := servers[alias]; ok {
|
||||||
glog.Warningf("Conflicting hostname (%v) and alias (%v). Removing alias to avoid conflicts.", host, alias)
|
klog.Warningf("Conflicting hostname (%v) and alias (%v). Removing alias to avoid conflicts.", host, alias)
|
||||||
servers[host].Alias = ""
|
servers[host].Alias = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1124,7 +1124,7 @@ func canMergeBackend(primary *ingress.Backend, alternative *ingress.Backend) boo
|
||||||
// Performs the merge action and checks to ensure that one two alternative backends do not merge into each other
|
// Performs the merge action and checks to ensure that one two alternative backends do not merge into each other
|
||||||
func mergeAlternativeBackend(priUps *ingress.Backend, altUps *ingress.Backend) bool {
|
func mergeAlternativeBackend(priUps *ingress.Backend, altUps *ingress.Backend) bool {
|
||||||
if priUps.NoServer {
|
if priUps.NoServer {
|
||||||
glog.Warningf("unable to merge alternative backend %v into primary backend %v because %v is a primary backend",
|
klog.Warningf("unable to merge alternative backend %v into primary backend %v because %v is a primary backend",
|
||||||
altUps.Name, priUps.Name, priUps.Name)
|
altUps.Name, priUps.Name, priUps.Name)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -1154,7 +1154,7 @@ func mergeAlternativeBackends(ing *ingress.Ingress, upstreams map[string]*ingres
|
||||||
priUps := upstreams[loc.Backend]
|
priUps := upstreams[loc.Backend]
|
||||||
|
|
||||||
if canMergeBackend(priUps, altUps) {
|
if canMergeBackend(priUps, altUps) {
|
||||||
glog.Infof("matching backend %v found for alternative backend %v",
|
klog.Infof("matching backend %v found for alternative backend %v",
|
||||||
priUps.Name, altUps.Name)
|
priUps.Name, altUps.Name)
|
||||||
|
|
||||||
merged = mergeAlternativeBackend(priUps, altUps)
|
merged = mergeAlternativeBackend(priUps, altUps)
|
||||||
|
@ -1162,7 +1162,7 @@ func mergeAlternativeBackends(ing *ingress.Ingress, upstreams map[string]*ingres
|
||||||
}
|
}
|
||||||
|
|
||||||
if !merged {
|
if !merged {
|
||||||
glog.Warningf("unable to find real backend for alternative backend %v. Deleting.", altUps.Name)
|
klog.Warningf("unable to find real backend for alternative backend %v. Deleting.", altUps.Name)
|
||||||
delete(upstreams, altUps.Name)
|
delete(upstreams, altUps.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1177,7 +1177,7 @@ func mergeAlternativeBackends(ing *ingress.Ingress, upstreams map[string]*ingres
|
||||||
|
|
||||||
server, ok := servers[rule.Host]
|
server, ok := servers[rule.Host]
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("cannot merge alternative backend %s into hostname %s that does not exist",
|
klog.Errorf("cannot merge alternative backend %s into hostname %s that does not exist",
|
||||||
altUps.Name,
|
altUps.Name,
|
||||||
rule.Host)
|
rule.Host)
|
||||||
|
|
||||||
|
@ -1189,7 +1189,7 @@ func mergeAlternativeBackends(ing *ingress.Ingress, upstreams map[string]*ingres
|
||||||
priUps := upstreams[loc.Backend]
|
priUps := upstreams[loc.Backend]
|
||||||
|
|
||||||
if canMergeBackend(priUps, altUps) && loc.Path == path.Path {
|
if canMergeBackend(priUps, altUps) && loc.Path == path.Path {
|
||||||
glog.Infof("matching backend %v found for alternative backend %v",
|
klog.Infof("matching backend %v found for alternative backend %v",
|
||||||
priUps.Name, altUps.Name)
|
priUps.Name, altUps.Name)
|
||||||
|
|
||||||
merged = mergeAlternativeBackend(priUps, altUps)
|
merged = mergeAlternativeBackend(priUps, altUps)
|
||||||
|
@ -1197,7 +1197,7 @@ func mergeAlternativeBackends(ing *ingress.Ingress, upstreams map[string]*ingres
|
||||||
}
|
}
|
||||||
|
|
||||||
if !merged {
|
if !merged {
|
||||||
glog.Warningf("unable to find real backend for alternative backend %v. Deleting.", altUps.Name)
|
klog.Warningf("unable to find real backend for alternative backend %v. Deleting.", altUps.Name)
|
||||||
delete(upstreams, altUps.Name)
|
delete(upstreams, altUps.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1232,7 +1232,7 @@ func extractTLSSecretName(host string, ing *ingress.Ingress,
|
||||||
|
|
||||||
cert, err := getLocalSSLCert(secrKey)
|
cert, err := getLocalSSLCert(secrKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Error getting SSL certificate %q: %v", secrKey, err)
|
klog.Warningf("Error getting SSL certificate %q: %v", secrKey, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1244,7 +1244,7 @@ func extractTLSSecretName(host string, ing *ingress.Ingress,
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
glog.V(3).Infof("Found SSL certificate matching host %q: %q", host, secrKey)
|
klog.V(3).Infof("Found SSL certificate matching host %q: %q", host, secrKey)
|
||||||
return tls.SecretName
|
return tls.SecretName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
|
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
|
||||||
|
@ -48,18 +48,18 @@ func getEndpoints(s *corev1.Service, port *corev1.ServicePort, proto corev1.Prot
|
||||||
|
|
||||||
// ExternalName services
|
// ExternalName services
|
||||||
if s.Spec.Type == corev1.ServiceTypeExternalName {
|
if s.Spec.Type == corev1.ServiceTypeExternalName {
|
||||||
glog.V(3).Infof("Ingress using Service %q of type ExternalName.", svcKey)
|
klog.V(3).Infof("Ingress using Service %q of type ExternalName.", svcKey)
|
||||||
|
|
||||||
targetPort := port.TargetPort.IntValue()
|
targetPort := port.TargetPort.IntValue()
|
||||||
if targetPort <= 0 {
|
if targetPort <= 0 {
|
||||||
glog.Errorf("ExternalName Service %q has an invalid port (%v)", svcKey, targetPort)
|
klog.Errorf("ExternalName Service %q has an invalid port (%v)", svcKey, targetPort)
|
||||||
return upsServers
|
return upsServers
|
||||||
}
|
}
|
||||||
|
|
||||||
if net.ParseIP(s.Spec.ExternalName) == nil {
|
if net.ParseIP(s.Spec.ExternalName) == nil {
|
||||||
_, err := net.LookupHost(s.Spec.ExternalName)
|
_, err := net.LookupHost(s.Spec.ExternalName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error resolving host %q: %v", s.Spec.ExternalName, err)
|
klog.Errorf("Error resolving host %q: %v", s.Spec.ExternalName, err)
|
||||||
return upsServers
|
return upsServers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,10 +70,10 @@ func getEndpoints(s *corev1.Service, port *corev1.ServicePort, proto corev1.Prot
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(3).Infof("Getting Endpoints for Service %q and port %v", svcKey, port.String())
|
klog.V(3).Infof("Getting Endpoints for Service %q and port %v", svcKey, port.String())
|
||||||
ep, err := getServiceEndpoints(svcKey)
|
ep, err := getServiceEndpoints(svcKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Error obtaining Endpoints for Service %q: %v", svcKey, err)
|
klog.Warningf("Error obtaining Endpoints for Service %q: %v", svcKey, err)
|
||||||
return upsServers
|
return upsServers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,6 +113,6 @@ func getEndpoints(s *corev1.Service, port *corev1.ServicePort, proto corev1.Prot
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(3).Infof("Endpoints found for Service %q: %v", svcKey, upsServers)
|
klog.V(3).Infof("Endpoints found for Service %q: %v", svcKey, upsServers)
|
||||||
return upsServers
|
return upsServers
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,6 @@ import (
|
||||||
"text/template"
|
"text/template"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
|
||||||
|
|
||||||
proxyproto "github.com/armon/go-proxyproto"
|
proxyproto "github.com/armon/go-proxyproto"
|
||||||
"github.com/eapache/channels"
|
"github.com/eapache/channels"
|
||||||
apiv1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
|
@ -44,6 +42,7 @@ import (
|
||||||
v1core "k8s.io/client-go/kubernetes/typed/core/v1"
|
v1core "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||||
"k8s.io/client-go/tools/record"
|
"k8s.io/client-go/tools/record"
|
||||||
"k8s.io/client-go/util/flowcontrol"
|
"k8s.io/client-go/util/flowcontrol"
|
||||||
|
"k8s.io/klog"
|
||||||
"k8s.io/kubernetes/pkg/util/filesystem"
|
"k8s.io/kubernetes/pkg/util/filesystem"
|
||||||
|
|
||||||
"k8s.io/ingress-nginx/internal/file"
|
"k8s.io/ingress-nginx/internal/file"
|
||||||
|
@ -76,14 +75,14 @@ var (
|
||||||
// NewNGINXController creates a new NGINX Ingress controller.
|
// NewNGINXController creates a new NGINX Ingress controller.
|
||||||
func NewNGINXController(config *Configuration, mc metric.Collector, fs file.Filesystem) *NGINXController {
|
func NewNGINXController(config *Configuration, mc metric.Collector, fs file.Filesystem) *NGINXController {
|
||||||
eventBroadcaster := record.NewBroadcaster()
|
eventBroadcaster := record.NewBroadcaster()
|
||||||
eventBroadcaster.StartLogging(glog.Infof)
|
eventBroadcaster.StartLogging(klog.Infof)
|
||||||
eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{
|
eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{
|
||||||
Interface: config.Client.CoreV1().Events(config.Namespace),
|
Interface: config.Client.CoreV1().Events(config.Namespace),
|
||||||
})
|
})
|
||||||
|
|
||||||
h, err := dns.GetSystemNameServers()
|
h, err := dns.GetSystemNameServers()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Error reading system nameservers: %v", err)
|
klog.Warningf("Error reading system nameservers: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
n := &NGINXController{
|
n := &NGINXController{
|
||||||
|
@ -113,7 +112,7 @@ func NewNGINXController(config *Configuration, mc metric.Collector, fs file.File
|
||||||
|
|
||||||
pod, err := k8s.GetPodDetails(config.Client)
|
pod, err := k8s.GetPodDetails(config.Client)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("unexpected error obtaining pod information: %v", err)
|
klog.Fatalf("unexpected error obtaining pod information: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
n.store = store.New(
|
n.store = store.New(
|
||||||
|
@ -147,14 +146,14 @@ func NewNGINXController(config *Configuration, mc metric.Collector, fs file.File
|
||||||
UseNodeInternalIP: config.UseNodeInternalIP,
|
UseNodeInternalIP: config.UseNodeInternalIP,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
glog.Warning("Update of Ingress status is disabled (flag --update-status)")
|
klog.Warning("Update of Ingress status is disabled (flag --update-status)")
|
||||||
}
|
}
|
||||||
|
|
||||||
onTemplateChange := func() {
|
onTemplateChange := func() {
|
||||||
template, err := ngx_template.NewTemplate(tmplPath, fs)
|
template, err := ngx_template.NewTemplate(tmplPath, fs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// this error is different from the rest because it must be clear why nginx is not working
|
// this error is different from the rest because it must be clear why nginx is not working
|
||||||
glog.Errorf(`
|
klog.Errorf(`
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Error loading new template: %v
|
Error loading new template: %v
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
@ -163,13 +162,13 @@ Error loading new template: %v
|
||||||
}
|
}
|
||||||
|
|
||||||
n.t = template
|
n.t = template
|
||||||
glog.Info("New NGINX configuration template loaded.")
|
klog.Info("New NGINX configuration template loaded.")
|
||||||
n.syncQueue.EnqueueTask(task.GetDummyObject("template-change"))
|
n.syncQueue.EnqueueTask(task.GetDummyObject("template-change"))
|
||||||
}
|
}
|
||||||
|
|
||||||
ngxTpl, err := ngx_template.NewTemplate(tmplPath, fs)
|
ngxTpl, err := ngx_template.NewTemplate(tmplPath, fs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("Invalid NGINX configuration template: %v", err)
|
klog.Fatalf("Invalid NGINX configuration template: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
n.t = ngxTpl
|
n.t = ngxTpl
|
||||||
|
@ -181,7 +180,7 @@ Error loading new template: %v
|
||||||
|
|
||||||
_, err = watch.NewFileWatcher(tmplPath, onTemplateChange)
|
_, err = watch.NewFileWatcher(tmplPath, onTemplateChange)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("Error creating file watcher for %v: %v", tmplPath, err)
|
klog.Fatalf("Error creating file watcher for %v: %v", tmplPath, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
filesToWatch := []string{}
|
filesToWatch := []string{}
|
||||||
|
@ -199,16 +198,16 @@ Error loading new template: %v
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("Error creating file watchers: %v", err)
|
klog.Fatalf("Error creating file watchers: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, f := range filesToWatch {
|
for _, f := range filesToWatch {
|
||||||
_, err = watch.NewFileWatcher(f, func() {
|
_, err = watch.NewFileWatcher(f, func() {
|
||||||
glog.Infof("File %v changed. Reloading NGINX", f)
|
klog.Infof("File %v changed. Reloading NGINX", f)
|
||||||
n.syncQueue.EnqueueTask(task.GetDummyObject("file-change"))
|
n.syncQueue.EnqueueTask(task.GetDummyObject("file-change"))
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("Error creating file watcher for %v: %v", f, err)
|
klog.Fatalf("Error creating file watcher for %v: %v", f, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,7 +261,7 @@ type NGINXController struct {
|
||||||
|
|
||||||
// Start starts a new NGINX master process running in the foreground.
|
// Start starts a new NGINX master process running in the foreground.
|
||||||
func (n *NGINXController) Start() {
|
func (n *NGINXController) Start() {
|
||||||
glog.Info("Starting NGINX Ingress controller")
|
klog.Info("Starting NGINX Ingress controller")
|
||||||
|
|
||||||
n.store.Run(n.stopCh)
|
n.store.Run(n.stopCh)
|
||||||
|
|
||||||
|
@ -283,7 +282,7 @@ func (n *NGINXController) Start() {
|
||||||
n.setupSSLProxy()
|
n.setupSSLProxy()
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.Info("Starting NGINX process")
|
klog.Info("Starting NGINX process")
|
||||||
n.start(cmd)
|
n.start(cmd)
|
||||||
|
|
||||||
go n.syncQueue.Run(time.Second, n.stopCh)
|
go n.syncQueue.Run(time.Second, n.stopCh)
|
||||||
|
@ -319,7 +318,7 @@ func (n *NGINXController) Start() {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if evt, ok := event.(store.Event); ok {
|
if evt, ok := event.(store.Event); ok {
|
||||||
glog.V(3).Infof("Event %v received - object %v", evt.Type, evt.Obj)
|
klog.V(3).Infof("Event %v received - object %v", evt.Type, evt.Obj)
|
||||||
if evt.Type == store.ConfigurationEvent {
|
if evt.Type == store.ConfigurationEvent {
|
||||||
// TODO: is this necessary? Consider removing this special case
|
// TODO: is this necessary? Consider removing this special case
|
||||||
n.syncQueue.EnqueueTask(task.GetDummyObject("configmap-change"))
|
n.syncQueue.EnqueueTask(task.GetDummyObject("configmap-change"))
|
||||||
|
@ -328,7 +327,7 @@ func (n *NGINXController) Start() {
|
||||||
|
|
||||||
n.syncQueue.EnqueueSkippableTask(evt.Obj)
|
n.syncQueue.EnqueueSkippableTask(evt.Obj)
|
||||||
} else {
|
} else {
|
||||||
glog.Warningf("Unexpected event type received %T", event)
|
klog.Warningf("Unexpected event type received %T", event)
|
||||||
}
|
}
|
||||||
case <-n.stopCh:
|
case <-n.stopCh:
|
||||||
break
|
break
|
||||||
|
@ -347,7 +346,7 @@ func (n *NGINXController) Stop() error {
|
||||||
return fmt.Errorf("shutdown already in progress")
|
return fmt.Errorf("shutdown already in progress")
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.Info("Shutting down controller queues")
|
klog.Info("Shutting down controller queues")
|
||||||
close(n.stopCh)
|
close(n.stopCh)
|
||||||
go n.syncQueue.Shutdown()
|
go n.syncQueue.Shutdown()
|
||||||
if n.syncStatus != nil {
|
if n.syncStatus != nil {
|
||||||
|
@ -355,7 +354,7 @@ func (n *NGINXController) Stop() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// send stop signal to NGINX
|
// send stop signal to NGINX
|
||||||
glog.Info("Stopping NGINX process")
|
klog.Info("Stopping NGINX process")
|
||||||
cmd := nginxExecCommand("-s", "quit")
|
cmd := nginxExecCommand("-s", "quit")
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
|
@ -368,7 +367,7 @@ func (n *NGINXController) Stop() error {
|
||||||
timer := time.NewTicker(time.Second * 1)
|
timer := time.NewTicker(time.Second * 1)
|
||||||
for range timer.C {
|
for range timer.C {
|
||||||
if !process.IsNginxRunning() {
|
if !process.IsNginxRunning() {
|
||||||
glog.Info("NGINX process has stopped")
|
klog.Info("NGINX process has stopped")
|
||||||
timer.Stop()
|
timer.Stop()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -381,7 +380,7 @@ func (n *NGINXController) start(cmd *exec.Cmd) {
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
if err := cmd.Start(); err != nil {
|
if err := cmd.Start(); err != nil {
|
||||||
glog.Fatalf("NGINX error: %v", err)
|
klog.Fatalf("NGINX error: %v", err)
|
||||||
n.ngxErrCh <- err
|
n.ngxErrCh <- err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -444,7 +443,7 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
|
||||||
for _, pb := range ingressCfg.PassthroughBackends {
|
for _, pb := range ingressCfg.PassthroughBackends {
|
||||||
svc := pb.Service
|
svc := pb.Service
|
||||||
if svc == nil {
|
if svc == nil {
|
||||||
glog.Warningf("Missing Service for SSL Passthrough backend %q", pb.Backend)
|
klog.Warningf("Missing Service for SSL Passthrough backend %q", pb.Backend)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
port, err := strconv.Atoi(pb.Port.String())
|
port, err := strconv.Atoi(pb.Port.String())
|
||||||
|
@ -497,7 +496,7 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
|
||||||
} else {
|
} else {
|
||||||
n = fmt.Sprintf("www.%v", srv.Hostname)
|
n = fmt.Sprintf("www.%v", srv.Hostname)
|
||||||
}
|
}
|
||||||
glog.V(3).Infof("Creating redirect from %q to %q", srv.Hostname, n)
|
klog.V(3).Infof("Creating redirect from %q to %q", srv.Hostname, n)
|
||||||
if _, ok := redirectServers[n]; !ok {
|
if _, ok := redirectServers[n]; !ok {
|
||||||
found := false
|
found := false
|
||||||
for _, esrv := range ingressCfg.Servers {
|
for _, esrv := range ingressCfg.Servers {
|
||||||
|
@ -514,24 +513,24 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
|
||||||
}
|
}
|
||||||
if cfg.ServerNameHashBucketSize == 0 {
|
if cfg.ServerNameHashBucketSize == 0 {
|
||||||
nameHashBucketSize := nginxHashBucketSize(longestName)
|
nameHashBucketSize := nginxHashBucketSize(longestName)
|
||||||
glog.V(3).Infof("Adjusting ServerNameHashBucketSize variable to %d", nameHashBucketSize)
|
klog.V(3).Infof("Adjusting ServerNameHashBucketSize variable to %d", nameHashBucketSize)
|
||||||
cfg.ServerNameHashBucketSize = nameHashBucketSize
|
cfg.ServerNameHashBucketSize = nameHashBucketSize
|
||||||
}
|
}
|
||||||
serverNameHashMaxSize := nextPowerOf2(serverNameBytes)
|
serverNameHashMaxSize := nextPowerOf2(serverNameBytes)
|
||||||
if cfg.ServerNameHashMaxSize < serverNameHashMaxSize {
|
if cfg.ServerNameHashMaxSize < serverNameHashMaxSize {
|
||||||
glog.V(3).Infof("Adjusting ServerNameHashMaxSize variable to %d", serverNameHashMaxSize)
|
klog.V(3).Infof("Adjusting ServerNameHashMaxSize variable to %d", serverNameHashMaxSize)
|
||||||
cfg.ServerNameHashMaxSize = serverNameHashMaxSize
|
cfg.ServerNameHashMaxSize = serverNameHashMaxSize
|
||||||
}
|
}
|
||||||
|
|
||||||
// the limit of open files is per worker process
|
// the limit of open files is per worker process
|
||||||
// and we leave some room to avoid consuming all the FDs available
|
// and we leave some room to avoid consuming all the FDs available
|
||||||
wp, err := strconv.Atoi(cfg.WorkerProcesses)
|
wp, err := strconv.Atoi(cfg.WorkerProcesses)
|
||||||
glog.V(3).Infof("Number of worker processes: %d", wp)
|
klog.V(3).Infof("Number of worker processes: %d", wp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wp = 1
|
wp = 1
|
||||||
}
|
}
|
||||||
maxOpenFiles := (sysctlFSFileMax() / wp) - 1024
|
maxOpenFiles := (sysctlFSFileMax() / wp) - 1024
|
||||||
glog.V(2).Infof("Maximum number of open file descriptors: %d", maxOpenFiles)
|
klog.V(2).Infof("Maximum number of open file descriptors: %d", maxOpenFiles)
|
||||||
if maxOpenFiles < 1024 {
|
if maxOpenFiles < 1024 {
|
||||||
// this means the value of RLIMIT_NOFILE is too low.
|
// this means the value of RLIMIT_NOFILE is too low.
|
||||||
maxOpenFiles = 1024
|
maxOpenFiles = 1024
|
||||||
|
@ -541,7 +540,7 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
|
||||||
if cfg.ProxySetHeaders != "" {
|
if cfg.ProxySetHeaders != "" {
|
||||||
cmap, err := n.store.GetConfigMap(cfg.ProxySetHeaders)
|
cmap, err := n.store.GetConfigMap(cfg.ProxySetHeaders)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Error reading ConfigMap %q from local store: %v", cfg.ProxySetHeaders, err)
|
klog.Warningf("Error reading ConfigMap %q from local store: %v", cfg.ProxySetHeaders, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
setHeaders = cmap.Data
|
setHeaders = cmap.Data
|
||||||
|
@ -551,7 +550,7 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
|
||||||
if cfg.AddHeaders != "" {
|
if cfg.AddHeaders != "" {
|
||||||
cmap, err := n.store.GetConfigMap(cfg.AddHeaders)
|
cmap, err := n.store.GetConfigMap(cfg.AddHeaders)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Error reading ConfigMap %q from local store: %v", cfg.AddHeaders, err)
|
klog.Warningf("Error reading ConfigMap %q from local store: %v", cfg.AddHeaders, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
addHeaders = cmap.Data
|
addHeaders = cmap.Data
|
||||||
|
@ -563,7 +562,7 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
|
||||||
|
|
||||||
secret, err := n.store.GetSecret(secretName)
|
secret, err := n.store.GetSecret(secretName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Error reading Secret %q from local store: %v", secretName, err)
|
klog.Warningf("Error reading Secret %q from local store: %v", secretName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
nsSecName := strings.Replace(secretName, "/", "-", -1)
|
nsSecName := strings.Replace(secretName, "/", "-", -1)
|
||||||
|
@ -572,7 +571,7 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
|
||||||
if ok {
|
if ok {
|
||||||
pemFileName, err := ssl.AddOrUpdateDHParam(nsSecName, dh, n.fileSystem)
|
pemFileName, err := ssl.AddOrUpdateDHParam(nsSecName, dh, n.fileSystem)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Error adding or updating dhparam file %v: %v", nsSecName, err)
|
klog.Warningf("Error adding or updating dhparam file %v: %v", nsSecName, err)
|
||||||
} else {
|
} else {
|
||||||
sslDHParam = pemFileName
|
sslDHParam = pemFileName
|
||||||
}
|
}
|
||||||
|
@ -624,7 +623,7 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if glog.V(2) {
|
if klog.V(2) {
|
||||||
src, _ := ioutil.ReadFile(cfgPath)
|
src, _ := ioutil.ReadFile(cfgPath)
|
||||||
if !bytes.Equal(src, content) {
|
if !bytes.Equal(src, content) {
|
||||||
tmpfile, err := ioutil.TempFile("", "new-nginx-cfg")
|
tmpfile, err := ioutil.TempFile("", "new-nginx-cfg")
|
||||||
|
@ -640,7 +639,7 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
|
||||||
// TODO: executing diff can return exit code != 0
|
// TODO: executing diff can return exit code != 0
|
||||||
diffOutput, _ := exec.Command("diff", "-u", cfgPath, tmpfile.Name()).CombinedOutput()
|
diffOutput, _ := exec.Command("diff", "-u", cfgPath, tmpfile.Name()).CombinedOutput()
|
||||||
|
|
||||||
glog.Infof("NGINX configuration diff:\n%v", string(diffOutput))
|
klog.Infof("NGINX configuration diff:\n%v", string(diffOutput))
|
||||||
|
|
||||||
// we do not defer the deletion of temp files in order
|
// we do not defer the deletion of temp files in order
|
||||||
// to keep them around for inspection in case of error
|
// to keep them around for inspection in case of error
|
||||||
|
@ -691,7 +690,7 @@ func (n *NGINXController) setupSSLProxy() {
|
||||||
sslPort := n.cfg.ListenPorts.HTTPS
|
sslPort := n.cfg.ListenPorts.HTTPS
|
||||||
proxyPort := n.cfg.ListenPorts.SSLProxy
|
proxyPort := n.cfg.ListenPorts.SSLProxy
|
||||||
|
|
||||||
glog.Info("Starting TLS proxy for SSL Passthrough")
|
klog.Info("Starting TLS proxy for SSL Passthrough")
|
||||||
n.Proxy = &TCPProxy{
|
n.Proxy = &TCPProxy{
|
||||||
Default: &TCPServer{
|
Default: &TCPServer{
|
||||||
Hostname: "localhost",
|
Hostname: "localhost",
|
||||||
|
@ -703,7 +702,7 @@ func (n *NGINXController) setupSSLProxy() {
|
||||||
|
|
||||||
listener, err := net.Listen("tcp", fmt.Sprintf(":%v", sslPort))
|
listener, err := net.Listen("tcp", fmt.Sprintf(":%v", sslPort))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("%v", err)
|
klog.Fatalf("%v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyList := &proxyproto.Listener{Listener: listener, ProxyHeaderTimeout: cfg.ProxyProtocolHeaderTimeout}
|
proxyList := &proxyproto.Listener{Listener: listener, ProxyHeaderTimeout: cfg.ProxyProtocolHeaderTimeout}
|
||||||
|
@ -723,11 +722,11 @@ func (n *NGINXController) setupSSLProxy() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Error accepting TCP connection: %v", err)
|
klog.Warningf("Error accepting TCP connection: %v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(3).Infof("Handling connection from remote address %s to local %s", conn.RemoteAddr(), conn.LocalAddr())
|
klog.V(3).Infof("Handling connection from remote address %s to local %s", conn.RemoteAddr(), conn.LocalAddr())
|
||||||
go n.Proxy.Handle(conn)
|
go n.Proxy.Handle(conn)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -884,7 +883,7 @@ func post(url string, data interface{}) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(2).Infof("Posting to %s", url)
|
klog.V(2).Infof("Posting to %s", url)
|
||||||
resp, err := http.Post(url, "application/json", bytes.NewReader(buf))
|
resp, err := http.Post(url, "application/json", bytes.NewReader(buf))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -892,7 +891,7 @@ func post(url string, data interface{}) error {
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := resp.Body.Close(); err != nil {
|
if err := resp.Body.Close(); err != nil {
|
||||||
glog.Warningf("Error while closing response body:\n%v", err)
|
klog.Warningf("Error while closing response body:\n%v", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
"github.com/imdario/mergo"
|
"github.com/imdario/mergo"
|
||||||
|
|
||||||
apiv1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
|
@ -39,13 +39,13 @@ func (s k8sStore) syncSecret(key string) {
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
defer s.mu.Unlock()
|
defer s.mu.Unlock()
|
||||||
|
|
||||||
glog.V(3).Infof("Syncing Secret %q", key)
|
klog.V(3).Infof("Syncing Secret %q", key)
|
||||||
|
|
||||||
// TODO: getPemCertificate should not write to disk to avoid unnecessary overhead
|
// TODO: getPemCertificate should not write to disk to avoid unnecessary overhead
|
||||||
cert, err := s.getPemCertificate(key)
|
cert, err := s.getPemCertificate(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !isErrSecretForAuth(err) {
|
if !isErrSecretForAuth(err) {
|
||||||
glog.Warningf("Error obtaining X.509 certificate: %v", err)
|
klog.Warningf("Error obtaining X.509 certificate: %v", err)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ func (s k8sStore) syncSecret(key string) {
|
||||||
// no need to update
|
// no need to update
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
glog.Infof("Updating Secret %q in the local store", key)
|
klog.Infof("Updating Secret %q in the local store", key)
|
||||||
s.sslStore.Update(key, cert)
|
s.sslStore.Update(key, cert)
|
||||||
// this update must trigger an update
|
// this update must trigger an update
|
||||||
// (like an update event from a change in Ingress)
|
// (like an update event from a change in Ingress)
|
||||||
|
@ -65,7 +65,7 @@ func (s k8sStore) syncSecret(key string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.Infof("Adding Secret %q to the local store", key)
|
klog.Infof("Adding Secret %q to the local store", key)
|
||||||
s.sslStore.Add(key, cert)
|
s.sslStore.Add(key, cert)
|
||||||
// this update must trigger an update
|
// this update must trigger an update
|
||||||
// (like an update event from a change in Ingress)
|
// (like an update event from a change in Ingress)
|
||||||
|
@ -116,7 +116,7 @@ func (s k8sStore) getPemCertificate(secretName string) (*ingress.SSLCert, error)
|
||||||
if ca != nil {
|
if ca != nil {
|
||||||
msg += " and authentication"
|
msg += " and authentication"
|
||||||
}
|
}
|
||||||
glog.V(3).Info(msg)
|
klog.V(3).Info(msg)
|
||||||
|
|
||||||
} else if ca != nil {
|
} else if ca != nil {
|
||||||
sslCert, err = ssl.AddCertAuth(nsSecName, ca, s.filesystem)
|
sslCert, err = ssl.AddCertAuth(nsSecName, ca, s.filesystem)
|
||||||
|
@ -127,7 +127,7 @@ func (s k8sStore) getPemCertificate(secretName string) (*ingress.SSLCert, error)
|
||||||
|
|
||||||
// makes this secret in 'syncSecret' to be used for Certificate Authentication
|
// makes this secret in 'syncSecret' to be used for Certificate Authentication
|
||||||
// this does not enable Certificate Authentication
|
// this does not enable Certificate Authentication
|
||||||
glog.V(3).Infof("Configuring Secret %q for TLS authentication", secretName)
|
klog.V(3).Infof("Configuring Secret %q for TLS authentication", secretName)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if auth != nil {
|
if auth != nil {
|
||||||
|
@ -158,7 +158,7 @@ func (s k8sStore) checkSSLChainIssues() {
|
||||||
|
|
||||||
data, err := ssl.FullChainCert(secret.PemFileName, s.filesystem)
|
data, err := ssl.FullChainCert(secret.PemFileName, s.filesystem)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error generating CA certificate chain for Secret %q: %v", secrKey, err)
|
klog.Errorf("Error generating CA certificate chain for Secret %q: %v", secrKey, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,13 +166,13 @@ func (s k8sStore) checkSSLChainIssues() {
|
||||||
|
|
||||||
file, err := s.filesystem.Create(fullChainPemFileName)
|
file, err := s.filesystem.Create(fullChainPemFileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error creating SSL certificate file for Secret %q: %v", secrKey, err)
|
klog.Errorf("Error creating SSL certificate file for Secret %q: %v", secrKey, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = file.Write(data)
|
_, err = file.Write(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error creating SSL certificate for Secret %q: %v", secrKey, err)
|
klog.Errorf("Error creating SSL certificate for Secret %q: %v", secrKey, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,13 +180,13 @@ func (s k8sStore) checkSSLChainIssues() {
|
||||||
|
|
||||||
err = mergo.MergeWithOverwrite(dst, secret)
|
err = mergo.MergeWithOverwrite(dst, secret)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error creating SSL certificate for Secret %q: %v", secrKey, err)
|
klog.Errorf("Error creating SSL certificate for Secret %q: %v", secrKey, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
dst.FullChainPemFileName = fullChainPemFileName
|
dst.FullChainPemFileName = fullChainPemFileName
|
||||||
|
|
||||||
glog.Infof("Updating local copy of SSL certificate %q with missing intermediate CA certs", secrKey)
|
klog.Infof("Updating local copy of SSL certificate %q with missing intermediate CA certs", secrKey)
|
||||||
s.sslStore.Update(secrKey, dst)
|
s.sslStore.Update(secrKey, dst)
|
||||||
// this update must trigger an update
|
// this update must trigger an update
|
||||||
// (like an update event from a change in Ingress)
|
// (like an update event from a change in Ingress)
|
||||||
|
|
|
@ -25,7 +25,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/eapache/channels"
|
"github.com/eapache/channels"
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
|
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
extensions "k8s.io/api/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
|
@ -247,7 +247,7 @@ func New(checkOCSP bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
eventBroadcaster := record.NewBroadcaster()
|
eventBroadcaster := record.NewBroadcaster()
|
||||||
eventBroadcaster.StartLogging(glog.Infof)
|
eventBroadcaster.StartLogging(klog.Infof)
|
||||||
eventBroadcaster.StartRecordingToSink(&clientcorev1.EventSinkImpl{
|
eventBroadcaster.StartRecordingToSink(&clientcorev1.EventSinkImpl{
|
||||||
Interface: client.CoreV1().Events(namespace),
|
Interface: client.CoreV1().Events(namespace),
|
||||||
})
|
})
|
||||||
|
@ -305,7 +305,7 @@ func New(checkOCSP bool,
|
||||||
ing := obj.(*extensions.Ingress)
|
ing := obj.(*extensions.Ingress)
|
||||||
if !class.IsValid(ing) {
|
if !class.IsValid(ing) {
|
||||||
a, _ := parser.GetStringAnnotation(class.IngressKey, ing)
|
a, _ := parser.GetStringAnnotation(class.IngressKey, ing)
|
||||||
glog.Infof("ignoring add for ingress %v based on annotation %v with value %v", ing.Name, class.IngressKey, a)
|
klog.Infof("ignoring add for ingress %v based on annotation %v with value %v", ing.Name, class.IngressKey, a)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
recorder.Eventf(ing, corev1.EventTypeNormal, "CREATE", fmt.Sprintf("Ingress %s/%s", ing.Namespace, ing.Name))
|
recorder.Eventf(ing, corev1.EventTypeNormal, "CREATE", fmt.Sprintf("Ingress %s/%s", ing.Namespace, ing.Name))
|
||||||
|
@ -325,17 +325,17 @@ func New(checkOCSP bool,
|
||||||
// If we reached here it means the ingress was deleted but its final state is unrecorded.
|
// If we reached here it means the ingress was deleted but its final state is unrecorded.
|
||||||
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
|
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("couldn't get object from tombstone %#v", obj)
|
klog.Errorf("couldn't get object from tombstone %#v", obj)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ing, ok = tombstone.Obj.(*extensions.Ingress)
|
ing, ok = tombstone.Obj.(*extensions.Ingress)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("Tombstone contained object that is not an Ingress: %#v", obj)
|
klog.Errorf("Tombstone contained object that is not an Ingress: %#v", obj)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !class.IsValid(ing) {
|
if !class.IsValid(ing) {
|
||||||
glog.Infof("ignoring delete for ingress %v based on annotation %v", ing.Name, class.IngressKey)
|
klog.Infof("ignoring delete for ingress %v based on annotation %v", ing.Name, class.IngressKey)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
recorder.Eventf(ing, corev1.EventTypeNormal, "DELETE", fmt.Sprintf("Ingress %s/%s", ing.Namespace, ing.Name))
|
recorder.Eventf(ing, corev1.EventTypeNormal, "DELETE", fmt.Sprintf("Ingress %s/%s", ing.Namespace, ing.Name))
|
||||||
|
@ -356,10 +356,10 @@ func New(checkOCSP bool,
|
||||||
validOld := class.IsValid(oldIng)
|
validOld := class.IsValid(oldIng)
|
||||||
validCur := class.IsValid(curIng)
|
validCur := class.IsValid(curIng)
|
||||||
if !validOld && validCur {
|
if !validOld && validCur {
|
||||||
glog.Infof("creating ingress %v based on annotation %v", curIng.Name, class.IngressKey)
|
klog.Infof("creating ingress %v based on annotation %v", curIng.Name, class.IngressKey)
|
||||||
recorder.Eventf(curIng, corev1.EventTypeNormal, "CREATE", fmt.Sprintf("Ingress %s/%s", curIng.Namespace, curIng.Name))
|
recorder.Eventf(curIng, corev1.EventTypeNormal, "CREATE", fmt.Sprintf("Ingress %s/%s", curIng.Namespace, curIng.Name))
|
||||||
} else if validOld && !validCur {
|
} else if validOld && !validCur {
|
||||||
glog.Infof("removing ingress %v based on annotation %v", curIng.Name, class.IngressKey)
|
klog.Infof("removing ingress %v based on annotation %v", curIng.Name, class.IngressKey)
|
||||||
recorder.Eventf(curIng, corev1.EventTypeNormal, "DELETE", fmt.Sprintf("Ingress %s/%s", curIng.Namespace, curIng.Name))
|
recorder.Eventf(curIng, corev1.EventTypeNormal, "DELETE", fmt.Sprintf("Ingress %s/%s", curIng.Namespace, curIng.Name))
|
||||||
} else if validCur && !reflect.DeepEqual(old, cur) {
|
} else if validCur && !reflect.DeepEqual(old, cur) {
|
||||||
recorder.Eventf(curIng, corev1.EventTypeNormal, "UPDATE", fmt.Sprintf("Ingress %s/%s", curIng.Namespace, curIng.Name))
|
recorder.Eventf(curIng, corev1.EventTypeNormal, "UPDATE", fmt.Sprintf("Ingress %s/%s", curIng.Namespace, curIng.Name))
|
||||||
|
@ -437,12 +437,12 @@ func New(checkOCSP bool,
|
||||||
// If we reached here it means the secret was deleted but its final state is unrecorded.
|
// If we reached here it means the secret was deleted but its final state is unrecorded.
|
||||||
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
|
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("couldn't get object from tombstone %#v", obj)
|
klog.Errorf("couldn't get object from tombstone %#v", obj)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sec, ok = tombstone.Obj.(*corev1.Secret)
|
sec, ok = tombstone.Obj.(*corev1.Secret)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("Tombstone contained object that is not a Secret: %#v", obj)
|
klog.Errorf("Tombstone contained object that is not a Secret: %#v", obj)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -527,7 +527,7 @@ func New(checkOCSP bool,
|
||||||
key := k8s.MetaNamespaceKey(ingKey)
|
key := k8s.MetaNamespaceKey(ingKey)
|
||||||
ing, err := store.getIngress(key)
|
ing, err := store.getIngress(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("could not find Ingress %v in local store: %v", key, err)
|
klog.Errorf("could not find Ingress %v in local store: %v", key, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
store.syncIngress(ing)
|
store.syncIngress(ing)
|
||||||
|
@ -581,7 +581,7 @@ func New(checkOCSP bool,
|
||||||
ns, name, _ := k8s.ParseNameNS(configmap)
|
ns, name, _ := k8s.ParseNameNS(configmap)
|
||||||
cm, err := client.CoreV1().ConfigMaps(ns).Get(name, metav1.GetOptions{})
|
cm, err := client.CoreV1().ConfigMaps(ns).Get(name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Unexpected error reading configuration configmap: %v", err)
|
klog.Warningf("Unexpected error reading configuration configmap: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
store.setConfig(cm)
|
store.setConfig(cm)
|
||||||
|
@ -623,7 +623,7 @@ func (s *k8sStore) syncIngress(ing *extensions.Ingress) {
|
||||||
// references in secretIngressMap.
|
// references in secretIngressMap.
|
||||||
func (s *k8sStore) updateSecretIngressMap(ing *extensions.Ingress) {
|
func (s *k8sStore) updateSecretIngressMap(ing *extensions.Ingress) {
|
||||||
key := k8s.MetaNamespaceKey(ing)
|
key := k8s.MetaNamespaceKey(ing)
|
||||||
glog.V(3).Infof("updating references to secrets for ingress %v", key)
|
klog.V(3).Infof("updating references to secrets for ingress %v", key)
|
||||||
|
|
||||||
// delete all existing references first
|
// delete all existing references first
|
||||||
s.secretIngressMap.Delete(key)
|
s.secretIngressMap.Delete(key)
|
||||||
|
@ -649,7 +649,7 @@ func (s *k8sStore) updateSecretIngressMap(ing *extensions.Ingress) {
|
||||||
for _, ann := range secretAnnotations {
|
for _, ann := range secretAnnotations {
|
||||||
secrKey, err := objectRefAnnotationNsKey(ann, ing)
|
secrKey, err := objectRefAnnotationNsKey(ann, ing)
|
||||||
if err != nil && !errors.IsMissingAnnotations(err) {
|
if err != nil && !errors.IsMissingAnnotations(err) {
|
||||||
glog.Errorf("error reading secret reference in annotation %q: %s", ann, err)
|
klog.Errorf("error reading secret reference in annotation %q: %s", ann, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if secrKey != "" {
|
if secrKey != "" {
|
||||||
|
@ -775,18 +775,18 @@ func (s k8sStore) writeSSLSessionTicketKey(cmap *corev1.ConfigMap, fileName stri
|
||||||
|
|
||||||
// 81 used instead of 80 because of padding
|
// 81 used instead of 80 because of padding
|
||||||
if !(ticketBytes == 48 || ticketBytes == 81) {
|
if !(ticketBytes == 48 || ticketBytes == 81) {
|
||||||
glog.Warningf("ssl-session-ticket-key must contain either 48 or 80 bytes")
|
klog.Warningf("ssl-session-ticket-key must contain either 48 or 80 bytes")
|
||||||
}
|
}
|
||||||
|
|
||||||
decodedTicket, err := base64.StdEncoding.DecodeString(ticketString)
|
decodedTicket, err := base64.StdEncoding.DecodeString(ticketString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("unexpected error decoding ssl-session-ticket-key: %v", err)
|
klog.Errorf("unexpected error decoding ssl-session-ticket-key: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ioutil.WriteFile(fileName, decodedTicket, file.ReadWriteByUser)
|
err = ioutil.WriteFile(fileName, decodedTicket, file.ReadWriteByUser)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("unexpected error writing ssl-session-ticket-key to %s: %v", fileName, err)
|
klog.Errorf("unexpected error writing ssl-session-ticket-key to %s: %v", fileName, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
|
|
||||||
"github.com/paultag/sniff/parser"
|
"github.com/paultag/sniff/parser"
|
||||||
)
|
)
|
||||||
|
@ -63,19 +63,19 @@ func (p *TCPProxy) Handle(conn net.Conn) {
|
||||||
|
|
||||||
length, err := conn.Read(data)
|
length, err := conn.Read(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.V(4).Infof("Error reading the first 4k of the connection: %s", err)
|
klog.V(4).Infof("Error reading the first 4k of the connection: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
proxy := p.Default
|
proxy := p.Default
|
||||||
hostname, err := parser.GetHostname(data[:])
|
hostname, err := parser.GetHostname(data[:])
|
||||||
if err == nil {
|
if err == nil {
|
||||||
glog.V(4).Infof("Parsed hostname from TLS Client Hello: %s", hostname)
|
klog.V(4).Infof("Parsed hostname from TLS Client Hello: %s", hostname)
|
||||||
proxy = p.Get(hostname)
|
proxy = p.Get(hostname)
|
||||||
}
|
}
|
||||||
|
|
||||||
if proxy == nil {
|
if proxy == nil {
|
||||||
glog.V(4).Infof("There is no configured proxy for SSL connections.")
|
klog.V(4).Infof("There is no configured proxy for SSL connections.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,16 +96,16 @@ func (p *TCPProxy) Handle(conn net.Conn) {
|
||||||
protocol = "TCP6"
|
protocol = "TCP6"
|
||||||
}
|
}
|
||||||
proxyProtocolHeader := fmt.Sprintf("PROXY %s %s %s %d %d\r\n", protocol, remoteAddr.IP.String(), localAddr.IP.String(), remoteAddr.Port, localAddr.Port)
|
proxyProtocolHeader := fmt.Sprintf("PROXY %s %s %s %d %d\r\n", protocol, remoteAddr.IP.String(), localAddr.IP.String(), remoteAddr.Port, localAddr.Port)
|
||||||
glog.V(4).Infof("Writing Proxy Protocol header: %s", proxyProtocolHeader)
|
klog.V(4).Infof("Writing Proxy Protocol header: %s", proxyProtocolHeader)
|
||||||
_, err = fmt.Fprintf(clientConn, proxyProtocolHeader)
|
_, err = fmt.Fprintf(clientConn, proxyProtocolHeader)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error writing Proxy Protocol header: %s", err)
|
klog.Errorf("Error writing Proxy Protocol header: %s", err)
|
||||||
clientConn.Close()
|
clientConn.Close()
|
||||||
} else {
|
} else {
|
||||||
_, err = clientConn.Write(data[:length])
|
_, err = clientConn.Write(data[:length])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error writing the first 4k of proxy data: %s", err)
|
klog.Errorf("Error writing the first 4k of proxy data: %s", err)
|
||||||
clientConn.Close()
|
clientConn.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
|
|
||||||
"github.com/mitchellh/hashstructure"
|
"github.com/mitchellh/hashstructure"
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
|
@ -83,7 +83,7 @@ func ReadConfig(src map[string]string) config.Configuration {
|
||||||
for _, i := range strings.Split(val, ",") {
|
for _, i := range strings.Split(val, ",") {
|
||||||
j, err := strconv.Atoi(i)
|
j, err := strconv.Atoi(i)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("%v is not a valid http code: %v", i, err)
|
klog.Warningf("%v is not a valid http code: %v", i, err)
|
||||||
} else {
|
} else {
|
||||||
errors = append(errors, j)
|
errors = append(errors, j)
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ func ReadConfig(src map[string]string) config.Configuration {
|
||||||
bindAddressIpv4List = append(bindAddressIpv4List, fmt.Sprintf("%v", ns))
|
bindAddressIpv4List = append(bindAddressIpv4List, fmt.Sprintf("%v", ns))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
glog.Warningf("%v is not a valid textual representation of an IP address", i)
|
klog.Warningf("%v is not a valid textual representation of an IP address", i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,12 +140,12 @@ func ReadConfig(src map[string]string) config.Configuration {
|
||||||
delete(conf, httpRedirectCode)
|
delete(conf, httpRedirectCode)
|
||||||
j, err := strconv.Atoi(val)
|
j, err := strconv.Atoi(val)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("%v is not a valid HTTP code: %v", val, err)
|
klog.Warningf("%v is not a valid HTTP code: %v", val, err)
|
||||||
} else {
|
} else {
|
||||||
if validRedirectCodes.Has(j) {
|
if validRedirectCodes.Has(j) {
|
||||||
to.HTTPRedirectCode = j
|
to.HTTPRedirectCode = j
|
||||||
} else {
|
} else {
|
||||||
glog.Warningf("The code %v is not a valid as HTTP redirect code. Using the default.", val)
|
klog.Warningf("The code %v is not a valid as HTTP redirect code. Using the default.", val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ func ReadConfig(src map[string]string) config.Configuration {
|
||||||
delete(conf, proxyHeaderTimeout)
|
delete(conf, proxyHeaderTimeout)
|
||||||
duration, err := time.ParseDuration(val)
|
duration, err := time.ParseDuration(val)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("proxy-protocol-header-timeout of %v encountered an error while being parsed %v. Switching to use default value instead.", val, err)
|
klog.Warningf("proxy-protocol-header-timeout of %v encountered an error while being parsed %v. Switching to use default value instead.", val, err)
|
||||||
} else {
|
} else {
|
||||||
to.ProxyProtocolHeaderTimeout = duration
|
to.ProxyProtocolHeaderTimeout = duration
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ func ReadConfig(src map[string]string) config.Configuration {
|
||||||
delete(conf, proxyStreamResponses)
|
delete(conf, proxyStreamResponses)
|
||||||
j, err := strconv.Atoi(val)
|
j, err := strconv.Atoi(val)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("%v is not a valid number: %v", val, err)
|
klog.Warningf("%v is not a valid number: %v", val, err)
|
||||||
} else {
|
} else {
|
||||||
streamResponses = j
|
streamResponses = j
|
||||||
}
|
}
|
||||||
|
@ -220,18 +220,18 @@ func ReadConfig(src map[string]string) config.Configuration {
|
||||||
|
|
||||||
decoder, err := mapstructure.NewDecoder(config)
|
decoder, err := mapstructure.NewDecoder(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("unexpected error merging defaults: %v", err)
|
klog.Warningf("unexpected error merging defaults: %v", err)
|
||||||
}
|
}
|
||||||
err = decoder.Decode(conf)
|
err = decoder.Decode(conf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("unexpected error merging defaults: %v", err)
|
klog.Warningf("unexpected error merging defaults: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
hash, err := hashstructure.Hash(to, &hashstructure.HashOptions{
|
hash, err := hashstructure.Hash(to, &hashstructure.HashOptions{
|
||||||
TagName: "json",
|
TagName: "json",
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("unexpected error obtaining hash: %v", err)
|
klog.Warningf("unexpected error obtaining hash: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
to.Checksum = fmt.Sprintf("%v", hash)
|
to.Checksum = fmt.Sprintf("%v", hash)
|
||||||
|
@ -245,7 +245,7 @@ func filterErrors(codes []int) []int {
|
||||||
if code > 299 && code < 600 {
|
if code > 299 && code < 600 {
|
||||||
fa = append(fa, code)
|
fa = append(fa, code)
|
||||||
} else {
|
} else {
|
||||||
glog.Warningf("error code %v is not valid for custom error pages", code)
|
klog.Warningf("error code %v is not valid for custom error pages", code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ import (
|
||||||
text_template "text/template"
|
text_template "text/template"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
|
@ -84,12 +84,12 @@ func (t *Template) Write(conf config.TemplateConfig) ([]byte, error) {
|
||||||
outCmdBuf := t.bp.Get()
|
outCmdBuf := t.bp.Get()
|
||||||
defer t.bp.Put(outCmdBuf)
|
defer t.bp.Put(outCmdBuf)
|
||||||
|
|
||||||
if glog.V(3) {
|
if klog.V(3) {
|
||||||
b, err := json.Marshal(conf)
|
b, err := json.Marshal(conf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("unexpected error: %v", err)
|
klog.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
glog.Infof("NGINX configuration: %v", string(b))
|
klog.Infof("NGINX configuration: %v", string(b))
|
||||||
}
|
}
|
||||||
|
|
||||||
err := t.tmpl.Execute(tmplBuf, conf)
|
err := t.tmpl.Execute(tmplBuf, conf)
|
||||||
|
@ -103,7 +103,7 @@ func (t *Template) Write(conf config.TemplateConfig) ([]byte, error) {
|
||||||
cmd.Stdin = tmplBuf
|
cmd.Stdin = tmplBuf
|
||||||
cmd.Stdout = outCmdBuf
|
cmd.Stdout = outCmdBuf
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
glog.Warningf("unexpected error cleaning template: %v", err)
|
klog.Warningf("unexpected error cleaning template: %v", err)
|
||||||
return tmplBuf.Bytes(), nil
|
return tmplBuf.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ func shouldConfigureLuaRestyWAF(disableLuaRestyWAF bool, mode string) bool {
|
||||||
func buildLuaSharedDictionaries(s interface{}, disableLuaRestyWAF bool) string {
|
func buildLuaSharedDictionaries(s interface{}, disableLuaRestyWAF bool) string {
|
||||||
servers, ok := s.([]*ingress.Server)
|
servers, ok := s.([]*ingress.Server)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected an '[]*ingress.Server' type but %T was returned", s)
|
klog.Errorf("expected an '[]*ingress.Server' type but %T was returned", s)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,12 +238,12 @@ func buildLuaSharedDictionaries(s interface{}, disableLuaRestyWAF bool) string {
|
||||||
func buildResolversForLua(res interface{}, disableIpv6 interface{}) string {
|
func buildResolversForLua(res interface{}, disableIpv6 interface{}) string {
|
||||||
nss, ok := res.([]net.IP)
|
nss, ok := res.([]net.IP)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected a '[]net.IP' type but %T was returned", res)
|
klog.Errorf("expected a '[]net.IP' type but %T was returned", res)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
no6, ok := disableIpv6.(bool)
|
no6, ok := disableIpv6.(bool)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected a 'bool' type but %T was returned", disableIpv6)
|
klog.Errorf("expected a 'bool' type but %T was returned", disableIpv6)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,12 +267,12 @@ func buildResolvers(res interface{}, disableIpv6 interface{}) string {
|
||||||
// NGINX need IPV6 addresses to be surrounded by brackets
|
// NGINX need IPV6 addresses to be surrounded by brackets
|
||||||
nss, ok := res.([]net.IP)
|
nss, ok := res.([]net.IP)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected a '[]net.IP' type but %T was returned", res)
|
klog.Errorf("expected a '[]net.IP' type but %T was returned", res)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
no6, ok := disableIpv6.(bool)
|
no6, ok := disableIpv6.(bool)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected a 'bool' type but %T was returned", disableIpv6)
|
klog.Errorf("expected a 'bool' type but %T was returned", disableIpv6)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ func stripLocationModifer(path string) string {
|
||||||
func enforceRegexModifier(input interface{}) bool {
|
func enforceRegexModifier(input interface{}) bool {
|
||||||
locations, ok := input.([]*ingress.Location)
|
locations, ok := input.([]*ingress.Location)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected an '[]*ingress.Location' type but %T was returned", input)
|
klog.Errorf("expected an '[]*ingress.Location' type but %T was returned", input)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +333,7 @@ func enforceRegexModifier(input interface{}) bool {
|
||||||
func buildLocation(input interface{}, enforceRegex bool) string {
|
func buildLocation(input interface{}, enforceRegex bool) string {
|
||||||
location, ok := input.(*ingress.Location)
|
location, ok := input.(*ingress.Location)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected an '*ingress.Location' type but %T was returned", input)
|
klog.Errorf("expected an '*ingress.Location' type but %T was returned", input)
|
||||||
return slash
|
return slash
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,7 +360,7 @@ func buildLocation(input interface{}, enforceRegex bool) string {
|
||||||
func buildAuthLocation(input interface{}) string {
|
func buildAuthLocation(input interface{}) string {
|
||||||
location, ok := input.(*ingress.Location)
|
location, ok := input.(*ingress.Location)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected an '*ingress.Location' type but %T was returned", input)
|
klog.Errorf("expected an '*ingress.Location' type but %T was returned", input)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,7 +378,7 @@ func buildAuthResponseHeaders(input interface{}) []string {
|
||||||
location, ok := input.(*ingress.Location)
|
location, ok := input.(*ingress.Location)
|
||||||
res := []string{}
|
res := []string{}
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected an '*ingress.Location' type but %T was returned", input)
|
klog.Errorf("expected an '*ingress.Location' type but %T was returned", input)
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,7 +398,7 @@ func buildAuthResponseHeaders(input interface{}) []string {
|
||||||
func buildLogFormatUpstream(input interface{}) string {
|
func buildLogFormatUpstream(input interface{}) string {
|
||||||
cfg, ok := input.(config.Configuration)
|
cfg, ok := input.(config.Configuration)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected a 'config.Configuration' type but %T was returned", input)
|
klog.Errorf("expected a 'config.Configuration' type but %T was returned", input)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,13 +412,13 @@ func buildLogFormatUpstream(input interface{}) string {
|
||||||
func buildProxyPass(host string, b interface{}, loc interface{}) string {
|
func buildProxyPass(host string, b interface{}, loc interface{}) string {
|
||||||
backends, ok := b.([]*ingress.Backend)
|
backends, ok := b.([]*ingress.Backend)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected an '[]*ingress.Backend' type but %T was returned", b)
|
klog.Errorf("expected an '[]*ingress.Backend' type but %T was returned", b)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
location, ok := loc.(*ingress.Location)
|
location, ok := loc.(*ingress.Location)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected a '*ingress.Location' type but %T was returned", loc)
|
klog.Errorf("expected a '*ingress.Location' type but %T was returned", loc)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,7 +520,7 @@ func filterRateLimits(input interface{}) []ratelimit.Config {
|
||||||
|
|
||||||
servers, ok := input.([]*ingress.Server)
|
servers, ok := input.([]*ingress.Server)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected a '[]ratelimit.RateLimit' type but %T was returned", input)
|
klog.Errorf("expected a '[]ratelimit.RateLimit' type but %T was returned", input)
|
||||||
return ratelimits
|
return ratelimits
|
||||||
}
|
}
|
||||||
for _, server := range servers {
|
for _, server := range servers {
|
||||||
|
@ -544,7 +544,7 @@ func buildRateLimitZones(input interface{}) []string {
|
||||||
|
|
||||||
servers, ok := input.([]*ingress.Server)
|
servers, ok := input.([]*ingress.Server)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected a '[]*ingress.Server' type but %T was returned", input)
|
klog.Errorf("expected a '[]*ingress.Server' type but %T was returned", input)
|
||||||
return zones.List()
|
return zones.List()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -594,7 +594,7 @@ func buildRateLimit(input interface{}) []string {
|
||||||
|
|
||||||
loc, ok := input.(*ingress.Location)
|
loc, ok := input.(*ingress.Location)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected an '*ingress.Location' type but %T was returned", input)
|
klog.Errorf("expected an '*ingress.Location' type but %T was returned", input)
|
||||||
return limits
|
return limits
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -634,7 +634,7 @@ func buildRateLimit(input interface{}) []string {
|
||||||
func isLocationInLocationList(location interface{}, rawLocationList string) bool {
|
func isLocationInLocationList(location interface{}, rawLocationList string) bool {
|
||||||
loc, ok := location.(*ingress.Location)
|
loc, ok := location.(*ingress.Location)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected an '*ingress.Location' type but %T was returned", location)
|
klog.Errorf("expected an '*ingress.Location' type but %T was returned", location)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -656,7 +656,7 @@ func isLocationInLocationList(location interface{}, rawLocationList string) bool
|
||||||
func isLocationAllowed(input interface{}) bool {
|
func isLocationAllowed(input interface{}) bool {
|
||||||
loc, ok := input.(*ingress.Location)
|
loc, ok := input.(*ingress.Location)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected an '*ingress.Location' type but %T was returned", input)
|
klog.Errorf("expected an '*ingress.Location' type but %T was returned", input)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -675,7 +675,7 @@ var (
|
||||||
func buildDenyVariable(a interface{}) string {
|
func buildDenyVariable(a interface{}) string {
|
||||||
l, ok := a.(string)
|
l, ok := a.(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected a 'string' type but %T was returned", a)
|
klog.Errorf("expected a 'string' type but %T was returned", a)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -689,7 +689,7 @@ func buildDenyVariable(a interface{}) string {
|
||||||
func buildUpstreamName(loc interface{}) string {
|
func buildUpstreamName(loc interface{}) string {
|
||||||
location, ok := loc.(*ingress.Location)
|
location, ok := loc.(*ingress.Location)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected a '*ingress.Location' type but %T was returned", loc)
|
klog.Errorf("expected a '*ingress.Location' type but %T was returned", loc)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -701,7 +701,7 @@ func buildUpstreamName(loc interface{}) string {
|
||||||
func buildNextUpstream(i, r interface{}) string {
|
func buildNextUpstream(i, r interface{}) string {
|
||||||
nextUpstream, ok := i.(string)
|
nextUpstream, ok := i.(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected a 'string' type but %T was returned", i)
|
klog.Errorf("expected a 'string' type but %T was returned", i)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -765,13 +765,13 @@ type ingressInformation struct {
|
||||||
func getIngressInformation(i, p interface{}) *ingressInformation {
|
func getIngressInformation(i, p interface{}) *ingressInformation {
|
||||||
ing, ok := i.(*ingress.Ingress)
|
ing, ok := i.(*ingress.Ingress)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected an '*ingress.Ingress' type but %T was returned", i)
|
klog.Errorf("expected an '*ingress.Ingress' type but %T was returned", i)
|
||||||
return &ingressInformation{}
|
return &ingressInformation{}
|
||||||
}
|
}
|
||||||
|
|
||||||
path, ok := p.(string)
|
path, ok := p.(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected a 'string' type but %T was returned", p)
|
klog.Errorf("expected a 'string' type but %T was returned", p)
|
||||||
return &ingressInformation{}
|
return &ingressInformation{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -808,7 +808,7 @@ func getIngressInformation(i, p interface{}) *ingressInformation {
|
||||||
func buildForwardedFor(input interface{}) string {
|
func buildForwardedFor(input interface{}) string {
|
||||||
s, ok := input.(string)
|
s, ok := input.(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected a 'string' type but %T was returned", input)
|
klog.Errorf("expected a 'string' type but %T was returned", input)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -820,7 +820,7 @@ func buildForwardedFor(input interface{}) string {
|
||||||
func buildAuthSignURL(input interface{}) string {
|
func buildAuthSignURL(input interface{}) string {
|
||||||
s, ok := input.(string)
|
s, ok := input.(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected an 'string' type but %T was returned", input)
|
klog.Errorf("expected an 'string' type but %T was returned", input)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -855,7 +855,7 @@ func randomString() string {
|
||||||
func buildOpentracing(input interface{}) string {
|
func buildOpentracing(input interface{}) string {
|
||||||
cfg, ok := input.(config.Configuration)
|
cfg, ok := input.(config.Configuration)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected a 'config.Configuration' type but %T was returned", input)
|
klog.Errorf("expected a 'config.Configuration' type but %T was returned", input)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -881,7 +881,7 @@ func buildOpentracing(input interface{}) string {
|
||||||
func buildInfluxDB(input interface{}) string {
|
func buildInfluxDB(input interface{}) string {
|
||||||
cfg, ok := input.(influxdb.Config)
|
cfg, ok := input.(influxdb.Config)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected an 'influxdb.Config' type but %T was returned", input)
|
klog.Errorf("expected an 'influxdb.Config' type but %T was returned", input)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -901,7 +901,7 @@ func buildInfluxDB(input interface{}) string {
|
||||||
func proxySetHeader(loc interface{}) string {
|
func proxySetHeader(loc interface{}) string {
|
||||||
location, ok := loc.(*ingress.Location)
|
location, ok := loc.(*ingress.Location)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected a '*ingress.Location' type but %T was returned", loc)
|
klog.Errorf("expected a '*ingress.Location' type but %T was returned", loc)
|
||||||
return "proxy_set_header"
|
return "proxy_set_header"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -932,7 +932,7 @@ func buildCustomErrorDeps(proxySetHeaders map[string]string, errorCodes []int, e
|
||||||
func collectCustomErrorsPerServer(input interface{}) []int {
|
func collectCustomErrorsPerServer(input interface{}) []int {
|
||||||
server, ok := input.(*ingress.Server)
|
server, ok := input.(*ingress.Server)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected a '*ingress.Server' type but %T was returned", input)
|
klog.Errorf("expected a '*ingress.Server' type but %T was returned", input)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -954,7 +954,7 @@ func collectCustomErrorsPerServer(input interface{}) []int {
|
||||||
func opentracingPropagateContext(loc interface{}) string {
|
func opentracingPropagateContext(loc interface{}) string {
|
||||||
location, ok := loc.(*ingress.Location)
|
location, ok := loc.(*ingress.Location)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("expected a '*ingress.Location' type but %T was returned", loc)
|
klog.Errorf("expected a '*ingress.Location' type but %T was returned", loc)
|
||||||
return "opentracing_propagate_context"
|
return "opentracing_propagate_context"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ import (
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
|
|
||||||
api "k8s.io/api/core/v1"
|
api "k8s.io/api/core/v1"
|
||||||
"k8s.io/kubernetes/pkg/util/sysctl"
|
"k8s.io/kubernetes/pkg/util/sysctl"
|
||||||
|
@ -57,7 +57,7 @@ func upstreamName(namespace string, service string, port intstr.IntOrString) str
|
||||||
func sysctlSomaxconn() int {
|
func sysctlSomaxconn() int {
|
||||||
maxConns, err := sysctl.New().GetSysctl("net/core/somaxconn")
|
maxConns, err := sysctl.New().GetSysctl("net/core/somaxconn")
|
||||||
if err != nil || maxConns < 512 {
|
if err != nil || maxConns < 512 {
|
||||||
glog.V(3).Infof("net.core.somaxconn=%v (using system default)", maxConns)
|
klog.V(3).Infof("net.core.somaxconn=%v (using system default)", maxConns)
|
||||||
return 511
|
return 511
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,10 +70,10 @@ func sysctlFSFileMax() int {
|
||||||
var rLimit syscall.Rlimit
|
var rLimit syscall.Rlimit
|
||||||
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
|
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error reading system maximum number of open file descriptors (RLIMIT_NOFILE): %v", err)
|
klog.Errorf("Error reading system maximum number of open file descriptors (RLIMIT_NOFILE): %v", err)
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
glog.V(2).Infof("rlimit.max=%v", rLimit.Max)
|
klog.V(2).Infof("rlimit.max=%v", rLimit.Max)
|
||||||
return int(rLimit.Max)
|
return int(rLimit.Max)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
|
@ -181,11 +181,11 @@ func (cm *Controller) SetSSLExpireTime(servers []*ingress.Server) {
|
||||||
func (cm *Controller) RemoveMetrics(hosts []string, registry prometheus.Gatherer) {
|
func (cm *Controller) RemoveMetrics(hosts []string, registry prometheus.Gatherer) {
|
||||||
mfs, err := registry.Gather()
|
mfs, err := registry.Gather()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error gathering metrics: %v", err)
|
klog.Errorf("Error gathering metrics: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(2).Infof("removing SSL certificate metrics for %v hosts", hosts)
|
klog.V(2).Infof("removing SSL certificate metrics for %v hosts", hosts)
|
||||||
toRemove := sets.NewString(hosts...)
|
toRemove := sets.NewString(hosts...)
|
||||||
|
|
||||||
for _, mf := range mfs {
|
for _, mf := range mfs {
|
||||||
|
@ -212,10 +212,10 @@ func (cm *Controller) RemoveMetrics(hosts []string, registry prometheus.Gatherer
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(2).Infof("Removing prometheus metric from gauge %v for host %v", metricName, host)
|
klog.V(2).Infof("Removing prometheus metric from gauge %v for host %v", metricName, host)
|
||||||
removed := cm.sslExpireTime.Delete(labels)
|
removed := cm.sslExpireTime.Delete(labels)
|
||||||
if !removed {
|
if !removed {
|
||||||
glog.V(2).Infof("metric %v for host %v with labels not removed: %v", metricName, host, labels)
|
klog.V(2).Infof("metric %v for host %v with labels not removed: %v", metricName, host, labels)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ func parse(data string) *basicStatus {
|
||||||
|
|
||||||
func getNginxStatus(port int, path string) (*basicStatus, error) {
|
func getNginxStatus(port int, path string) (*basicStatus, error) {
|
||||||
url := fmt.Sprintf("http://0.0.0.0:%v%v", port, path)
|
url := fmt.Sprintf("http://0.0.0.0:%v%v", port, path)
|
||||||
glog.V(3).Infof("start scraping url: %v", url)
|
klog.V(3).Infof("start scraping url: %v", url)
|
||||||
|
|
||||||
data, err := httpBody(url)
|
data, err := httpBody(url)
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ func getNginxStatus(port int, path string) (*basicStatus, error) {
|
||||||
func (p nginxStatusCollector) scrape(ch chan<- prometheus.Metric) {
|
func (p nginxStatusCollector) scrape(ch chan<- prometheus.Metric) {
|
||||||
s, err := getNginxStatus(p.ngxHealthPort, p.ngxStatusPath)
|
s, err := getNginxStatus(p.ngxHealthPort, p.ngxStatusPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("unexpected error obtaining nginx status info: %v", err)
|
klog.Warningf("unexpected error obtaining nginx status info: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
|
@ -203,19 +203,19 @@ func NewSocketCollector(pod, namespace, class string) (*SocketCollector, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sc *SocketCollector) handleMessage(msg []byte) {
|
func (sc *SocketCollector) handleMessage(msg []byte) {
|
||||||
glog.V(5).Infof("msg: %v", string(msg))
|
klog.V(5).Infof("msg: %v", string(msg))
|
||||||
|
|
||||||
// Unmarshal bytes
|
// Unmarshal bytes
|
||||||
var statsBatch []socketData
|
var statsBatch []socketData
|
||||||
err := jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(msg, &statsBatch)
|
err := jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(msg, &statsBatch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Unexpected error deserializing JSON payload: %v. Payload:\n%v", err, string(msg))
|
klog.Errorf("Unexpected error deserializing JSON payload: %v. Payload:\n%v", err, string(msg))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, stats := range statsBatch {
|
for _, stats := range statsBatch {
|
||||||
if !sc.hosts.Has(stats.Host) {
|
if !sc.hosts.Has(stats.Host) {
|
||||||
glog.V(3).Infof("skiping metric for host %v that is not being served", stats.Host)
|
klog.V(3).Infof("skiping metric for host %v that is not being served", stats.Host)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ func (sc *SocketCollector) handleMessage(msg []byte) {
|
||||||
|
|
||||||
requestsMetric, err := sc.requests.GetMetricWith(collectorLabels)
|
requestsMetric, err := sc.requests.GetMetricWith(collectorLabels)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error fetching requests metric: %v", err)
|
klog.Errorf("Error fetching requests metric: %v", err)
|
||||||
} else {
|
} else {
|
||||||
requestsMetric.Inc()
|
requestsMetric.Inc()
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ func (sc *SocketCollector) handleMessage(msg []byte) {
|
||||||
if stats.Latency != -1 {
|
if stats.Latency != -1 {
|
||||||
latencyMetric, err := sc.upstreamLatency.GetMetricWith(latencyLabels)
|
latencyMetric, err := sc.upstreamLatency.GetMetricWith(latencyLabels)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error fetching latency metric: %v", err)
|
klog.Errorf("Error fetching latency metric: %v", err)
|
||||||
} else {
|
} else {
|
||||||
latencyMetric.Observe(stats.Latency)
|
latencyMetric.Observe(stats.Latency)
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ func (sc *SocketCollector) handleMessage(msg []byte) {
|
||||||
if stats.RequestTime != -1 {
|
if stats.RequestTime != -1 {
|
||||||
requestTimeMetric, err := sc.requestTime.GetMetricWith(requestLabels)
|
requestTimeMetric, err := sc.requestTime.GetMetricWith(requestLabels)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error fetching request duration metric: %v", err)
|
klog.Errorf("Error fetching request duration metric: %v", err)
|
||||||
} else {
|
} else {
|
||||||
requestTimeMetric.Observe(stats.RequestTime)
|
requestTimeMetric.Observe(stats.RequestTime)
|
||||||
}
|
}
|
||||||
|
@ -269,7 +269,7 @@ func (sc *SocketCollector) handleMessage(msg []byte) {
|
||||||
if stats.RequestLength != -1 {
|
if stats.RequestLength != -1 {
|
||||||
requestLengthMetric, err := sc.requestLength.GetMetricWith(requestLabels)
|
requestLengthMetric, err := sc.requestLength.GetMetricWith(requestLabels)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error fetching request length metric: %v", err)
|
klog.Errorf("Error fetching request length metric: %v", err)
|
||||||
} else {
|
} else {
|
||||||
requestLengthMetric.Observe(stats.RequestLength)
|
requestLengthMetric.Observe(stats.RequestLength)
|
||||||
}
|
}
|
||||||
|
@ -278,7 +278,7 @@ func (sc *SocketCollector) handleMessage(msg []byte) {
|
||||||
if stats.ResponseTime != -1 {
|
if stats.ResponseTime != -1 {
|
||||||
responseTimeMetric, err := sc.responseTime.GetMetricWith(requestLabels)
|
responseTimeMetric, err := sc.responseTime.GetMetricWith(requestLabels)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error fetching upstream response time metric: %v", err)
|
klog.Errorf("Error fetching upstream response time metric: %v", err)
|
||||||
} else {
|
} else {
|
||||||
responseTimeMetric.Observe(stats.ResponseTime)
|
responseTimeMetric.Observe(stats.ResponseTime)
|
||||||
}
|
}
|
||||||
|
@ -287,14 +287,14 @@ func (sc *SocketCollector) handleMessage(msg []byte) {
|
||||||
if stats.ResponseLength != -1 {
|
if stats.ResponseLength != -1 {
|
||||||
bytesSentMetric, err := sc.bytesSent.GetMetricWith(requestLabels)
|
bytesSentMetric, err := sc.bytesSent.GetMetricWith(requestLabels)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error fetching bytes sent metric: %v", err)
|
klog.Errorf("Error fetching bytes sent metric: %v", err)
|
||||||
} else {
|
} else {
|
||||||
bytesSentMetric.Observe(stats.ResponseLength)
|
bytesSentMetric.Observe(stats.ResponseLength)
|
||||||
}
|
}
|
||||||
|
|
||||||
responseSizeMetric, err := sc.responseLength.GetMetricWith(requestLabels)
|
responseSizeMetric, err := sc.responseLength.GetMetricWith(requestLabels)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error fetching bytes sent metric: %v", err)
|
klog.Errorf("Error fetching bytes sent metric: %v", err)
|
||||||
} else {
|
} else {
|
||||||
responseSizeMetric.Observe(stats.ResponseLength)
|
responseSizeMetric.Observe(stats.ResponseLength)
|
||||||
}
|
}
|
||||||
|
@ -325,12 +325,12 @@ func (sc *SocketCollector) Stop() {
|
||||||
func (sc *SocketCollector) RemoveMetrics(ingresses []string, registry prometheus.Gatherer) {
|
func (sc *SocketCollector) RemoveMetrics(ingresses []string, registry prometheus.Gatherer) {
|
||||||
mfs, err := registry.Gather()
|
mfs, err := registry.Gather()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error gathering metrics: %v", err)
|
klog.Errorf("Error gathering metrics: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. remove metrics of removed ingresses
|
// 1. remove metrics of removed ingresses
|
||||||
glog.V(2).Infof("removing ingresses %v from metrics", ingresses)
|
klog.V(2).Infof("removing ingresses %v from metrics", ingresses)
|
||||||
for _, mf := range mfs {
|
for _, mf := range mfs {
|
||||||
metricName := mf.GetName()
|
metricName := mf.GetName()
|
||||||
metric, ok := sc.metricMapping[metricName]
|
metric, ok := sc.metricMapping[metricName]
|
||||||
|
@ -362,13 +362,13 @@ func (sc *SocketCollector) RemoveMetrics(ingresses []string, registry prometheus
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(2).Infof("Removing prometheus metric from histogram %v for ingress %v", metricName, ingKey)
|
klog.V(2).Infof("Removing prometheus metric from histogram %v for ingress %v", metricName, ingKey)
|
||||||
|
|
||||||
h, ok := metric.(*prometheus.HistogramVec)
|
h, ok := metric.(*prometheus.HistogramVec)
|
||||||
if ok {
|
if ok {
|
||||||
removed := h.Delete(labels)
|
removed := h.Delete(labels)
|
||||||
if !removed {
|
if !removed {
|
||||||
glog.V(2).Infof("metric %v for ingress %v with labels not removed: %v", metricName, ingKey, labels)
|
klog.V(2).Infof("metric %v for ingress %v with labels not removed: %v", metricName, ingKey, labels)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,7 +376,7 @@ func (sc *SocketCollector) RemoveMetrics(ingresses []string, registry prometheus
|
||||||
if ok {
|
if ok {
|
||||||
removed := s.Delete(labels)
|
removed := s.Delete(labels)
|
||||||
if !removed {
|
if !removed {
|
||||||
glog.V(2).Infof("metric %v for ingress %v with labels not removed: %v", metricName, ingKey, labels)
|
klog.V(2).Infof("metric %v for ingress %v with labels not removed: %v", metricName, ingKey, labels)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
pool "gopkg.in/go-playground/pool.v3"
|
pool "gopkg.in/go-playground/pool.v3"
|
||||||
|
@ -123,7 +123,7 @@ func (s statusSync) Run() {
|
||||||
var stopCh chan struct{}
|
var stopCh chan struct{}
|
||||||
callbacks := leaderelection.LeaderCallbacks{
|
callbacks := leaderelection.LeaderCallbacks{
|
||||||
OnStartedLeading: func(ctx context.Context) {
|
OnStartedLeading: func(ctx context.Context) {
|
||||||
glog.V(2).Infof("I am the new status update leader")
|
klog.V(2).Infof("I am the new status update leader")
|
||||||
stopCh = make(chan struct{})
|
stopCh = make(chan struct{})
|
||||||
go s.syncQueue.Run(time.Second, stopCh)
|
go s.syncQueue.Run(time.Second, stopCh)
|
||||||
// trigger initial sync
|
// trigger initial sync
|
||||||
|
@ -136,7 +136,7 @@ func (s statusSync) Run() {
|
||||||
}, stopCh)
|
}, stopCh)
|
||||||
},
|
},
|
||||||
OnStoppedLeading: func() {
|
OnStoppedLeading: func() {
|
||||||
glog.V(2).Info("I am not status update leader anymore")
|
klog.V(2).Info("I am not status update leader anymore")
|
||||||
close(stopCh)
|
close(stopCh)
|
||||||
|
|
||||||
// cancel the context
|
// cancel the context
|
||||||
|
@ -145,7 +145,7 @@ func (s statusSync) Run() {
|
||||||
cancelContext = newLeaderCtx(ctx)
|
cancelContext = newLeaderCtx(ctx)
|
||||||
},
|
},
|
||||||
OnNewLeader: func(identity string) {
|
OnNewLeader: func(identity string) {
|
||||||
glog.Infof("new leader elected: %v", identity)
|
klog.Infof("new leader elected: %v", identity)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ func (s statusSync) Run() {
|
||||||
Callbacks: callbacks,
|
Callbacks: callbacks,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("unexpected error starting leader election: %v", err)
|
klog.Fatalf("unexpected error starting leader election: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelContext = newLeaderCtx(ctx)
|
cancelContext = newLeaderCtx(ctx)
|
||||||
|
@ -193,36 +193,36 @@ func (s statusSync) Shutdown() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !s.UpdateStatusOnShutdown {
|
if !s.UpdateStatusOnShutdown {
|
||||||
glog.Warningf("skipping update of status of Ingress rules")
|
klog.Warningf("skipping update of status of Ingress rules")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.Info("updating status of Ingress rules (remove)")
|
klog.Info("updating status of Ingress rules (remove)")
|
||||||
|
|
||||||
addrs, err := s.runningAddresses()
|
addrs, err := s.runningAddresses()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("error obtaining running IPs: %v", addrs)
|
klog.Errorf("error obtaining running IPs: %v", addrs)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(addrs) > 1 {
|
if len(addrs) > 1 {
|
||||||
// leave the job to the next leader
|
// leave the job to the next leader
|
||||||
glog.Infof("leaving status update for next leader (%v)", len(addrs))
|
klog.Infof("leaving status update for next leader (%v)", len(addrs))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.isRunningMultiplePods() {
|
if s.isRunningMultiplePods() {
|
||||||
glog.V(2).Infof("skipping Ingress status update (multiple pods running - another one will be elected as master)")
|
klog.V(2).Infof("skipping Ingress status update (multiple pods running - another one will be elected as master)")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.Infof("removing address from ingress status (%v)", addrs)
|
klog.Infof("removing address from ingress status (%v)", addrs)
|
||||||
s.updateStatus([]apiv1.LoadBalancerIngress{})
|
s.updateStatus([]apiv1.LoadBalancerIngress{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *statusSync) sync(key interface{}) error {
|
func (s *statusSync) sync(key interface{}) error {
|
||||||
if s.syncQueue.IsShuttingDown() {
|
if s.syncQueue.IsShuttingDown() {
|
||||||
glog.V(2).Infof("skipping Ingress status update (shutting down in progress)")
|
klog.V(2).Infof("skipping Ingress status update (shutting down in progress)")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +247,7 @@ func (s statusSync) keyfunc(input interface{}) (interface{}, error) {
|
||||||
func NewStatusSyncer(config Config) Sync {
|
func NewStatusSyncer(config Config) Sync {
|
||||||
pod, err := k8s.GetPodDetails(config.Client)
|
pod, err := k8s.GetPodDetails(config.Client)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("unexpected error obtaining pod information: %v", err)
|
klog.Fatalf("unexpected error obtaining pod information: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
st := statusSync{
|
st := statusSync{
|
||||||
|
@ -360,7 +360,7 @@ func (s *statusSync) updateStatus(newIngressPoint []apiv1.LoadBalancerIngress) {
|
||||||
curIPs := ing.Status.LoadBalancer.Ingress
|
curIPs := ing.Status.LoadBalancer.Ingress
|
||||||
sort.SliceStable(curIPs, lessLoadBalancerIngress(curIPs))
|
sort.SliceStable(curIPs, lessLoadBalancerIngress(curIPs))
|
||||||
if ingressSliceEqual(curIPs, newIngressPoint) {
|
if ingressSliceEqual(curIPs, newIngressPoint) {
|
||||||
glog.V(3).Infof("skipping update of Ingress %v/%v (no change)", ing.Namespace, ing.Name)
|
klog.V(3).Infof("skipping update of Ingress %v/%v (no change)", ing.Namespace, ing.Name)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,11 +385,11 @@ func runUpdate(ing *ingress.Ingress, status []apiv1.LoadBalancerIngress,
|
||||||
return nil, errors.Wrap(err, fmt.Sprintf("unexpected error searching Ingress %v/%v", ing.Namespace, ing.Name))
|
return nil, errors.Wrap(err, fmt.Sprintf("unexpected error searching Ingress %v/%v", ing.Namespace, ing.Name))
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.Infof("updating Ingress %v/%v status to %v", currIng.Namespace, currIng.Name, status)
|
klog.Infof("updating Ingress %v/%v status to %v", currIng.Namespace, currIng.Name, status)
|
||||||
currIng.Status.LoadBalancer.Ingress = status
|
currIng.Status.LoadBalancer.Ingress = status
|
||||||
_, err = ingClient.UpdateStatus(currIng)
|
_, err = ingClient.UpdateStatus(currIng)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("error updating ingress rule: %v", err)
|
klog.Warningf("error updating ingress rule: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
apiv1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
|
@ -42,7 +42,7 @@ func ParseNameNS(input string) (string, string, error) {
|
||||||
func GetNodeIPOrName(kubeClient clientset.Interface, name string, useInternalIP bool) string {
|
func GetNodeIPOrName(kubeClient clientset.Interface, name string, useInternalIP bool) string {
|
||||||
node, err := kubeClient.CoreV1().Nodes().Get(name, metav1.GetOptions{})
|
node, err := kubeClient.CoreV1().Nodes().Get(name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Error getting node %v: %v", name, err)
|
klog.Errorf("Error getting node %v: %v", name, err)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ func GetPodDetails(kubeClient clientset.Interface) (*PodInfo, error) {
|
||||||
func MetaNamespaceKey(obj interface{}) string {
|
func MetaNamespaceKey(obj interface{}) string {
|
||||||
key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj)
|
key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warning(err)
|
klog.Warning(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return key
|
return key
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
)
|
)
|
||||||
|
|
||||||
var defResolvConf = "/etc/resolv.conf"
|
var defResolvConf = "/etc/resolv.conf"
|
||||||
|
@ -53,6 +53,6 @@ func GetSystemNameServers() ([]net.IP, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(3).Infof("nameservers IP address/es to use: %v", nameservers)
|
klog.V(3).Infof("nameservers IP address/es to use: %v", nameservers)
|
||||||
return nameservers, nil
|
return nameservers, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
"github.com/zakjan/cert-chain-resolver/certUtil"
|
"github.com/zakjan/cert-chain-resolver/certUtil"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
|
@ -56,7 +56,7 @@ func AddOrUpdateCertAndKey(name string, cert, key, ca []byte,
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not create temp pem file %v: %v", pemFileName, err)
|
return nil, fmt.Errorf("could not create temp pem file %v: %v", pemFileName, err)
|
||||||
}
|
}
|
||||||
glog.V(3).Infof("Creating temp file %v for Keypair: %v", tempPemFile.Name(), pemName)
|
klog.V(3).Infof("Creating temp file %v for Keypair: %v", tempPemFile.Name(), pemName)
|
||||||
|
|
||||||
_, err = tempPemFile.Write(cert)
|
_, err = tempPemFile.Write(cert)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -110,11 +110,11 @@ func AddOrUpdateCertAndKey(name string, cert, key, ca []byte,
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(pemCert.Extensions) > 0 {
|
if len(pemCert.Extensions) > 0 {
|
||||||
glog.V(3).Info("parsing ssl certificate extensions")
|
klog.V(3).Info("parsing ssl certificate extensions")
|
||||||
for _, ext := range getExtension(pemCert, oidExtensionSubjectAltName) {
|
for _, ext := range getExtension(pemCert, oidExtensionSubjectAltName) {
|
||||||
dns, _, _, err := parseSANExtension(ext.Value)
|
dns, _, _, err := parseSANExtension(ext.Value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("unexpected error parsing certificate extensions: %v", err)
|
klog.Warningf("unexpected error parsing certificate extensions: %v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,11 +224,11 @@ func CreateSSLCert(name string, cert, key, ca []byte) (*ingress.SSLCert, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(pemCert.Extensions) > 0 {
|
if len(pemCert.Extensions) > 0 {
|
||||||
glog.V(3).Info("parsing ssl certificate extensions")
|
klog.V(3).Info("parsing ssl certificate extensions")
|
||||||
for _, ext := range getExtension(pemCert, oidExtensionSubjectAltName) {
|
for _, ext := range getExtension(pemCert, oidExtensionSubjectAltName) {
|
||||||
dns, _, _, err := parseSANExtension(ext.Value)
|
dns, _, _, err := parseSANExtension(ext.Value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("unexpected error parsing certificate extensions: %v", err)
|
klog.Warningf("unexpected error parsing certificate extensions: %v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,7 +366,7 @@ func AddCertAuth(name string, ca []byte, fs file.Filesystem) (*ingress.SSLCert,
|
||||||
return nil, fmt.Errorf("could not write CA file %v: %v", caFileName, err)
|
return nil, fmt.Errorf("could not write CA file %v: %v", caFileName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(3).Infof("Created CA Certificate for Authentication: %v", caFileName)
|
klog.V(3).Infof("Created CA Certificate for Authentication: %v", caFileName)
|
||||||
return &ingress.SSLCert{
|
return &ingress.SSLCert{
|
||||||
Certificate: pemCert,
|
Certificate: pemCert,
|
||||||
CAFileName: caFileName,
|
CAFileName: caFileName,
|
||||||
|
@ -382,7 +382,7 @@ func AddOrUpdateDHParam(name string, dh []byte, fs file.Filesystem) (string, err
|
||||||
|
|
||||||
tempPemFile, err := fs.TempFile(file.DefaultSSLDirectory, pemName)
|
tempPemFile, err := fs.TempFile(file.DefaultSSLDirectory, pemName)
|
||||||
|
|
||||||
glog.V(3).Infof("Creating temp file %v for DH param: %v", tempPemFile.Name(), pemName)
|
klog.V(3).Infof("Creating temp file %v for DH param: %v", tempPemFile.Name(), pemName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("could not create temp pem file %v: %v", pemFileName, err)
|
return "", fmt.Errorf("could not create temp pem file %v: %v", pemFileName, err)
|
||||||
}
|
}
|
||||||
|
@ -432,7 +432,7 @@ func GetFakeSSLCert() ([]byte, []byte) {
|
||||||
priv, err = rsa.GenerateKey(rand.Reader, 2048)
|
priv, err = rsa.GenerateKey(rand.Reader, 2048)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("failed to generate fake private key: %s", err)
|
klog.Fatalf("failed to generate fake private key: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
notBefore := time.Now()
|
notBefore := time.Now()
|
||||||
|
@ -443,7 +443,7 @@ func GetFakeSSLCert() ([]byte, []byte) {
|
||||||
serialNumber, err := rand.Int(rand.Reader, serialNumberLimit)
|
serialNumber, err := rand.Int(rand.Reader, serialNumberLimit)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("failed to generate fake serial number: %s", err)
|
klog.Fatalf("failed to generate fake serial number: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
template := x509.Certificate{
|
template := x509.Certificate{
|
||||||
|
@ -462,7 +462,7 @@ func GetFakeSSLCert() ([]byte, []byte) {
|
||||||
}
|
}
|
||||||
derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.(*rsa.PrivateKey).PublicKey, priv)
|
derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.(*rsa.PrivateKey).PublicKey, priv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("Failed to create fake certificate: %s", err)
|
klog.Fatalf("Failed to create fake certificate: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cert := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: derBytes})
|
cert := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: derBytes})
|
||||||
|
|
|
@ -18,20 +18,20 @@ package ssl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/rsa"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
certutil "k8s.io/client-go/util/cert"
|
certutil "k8s.io/client-go/util/cert"
|
||||||
"k8s.io/client-go/util/cert/triple"
|
|
||||||
|
|
||||||
"k8s.io/ingress-nginx/internal/file"
|
"k8s.io/ingress-nginx/internal/file"
|
||||||
)
|
)
|
||||||
|
|
||||||
// generateRSACerts generates a self signed certificate using a self generated ca
|
// generateRSACerts generates a self signed certificate using a self generated ca
|
||||||
func generateRSACerts(host string) (*triple.KeyPair, *triple.KeyPair, error) {
|
func generateRSACerts(host string) (*keyPair, *keyPair, error) {
|
||||||
ca, err := triple.NewCA("self-sign-ca")
|
ca, err := newCA("self-sign-ca")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ func generateRSACerts(host string) (*triple.KeyPair, *triple.KeyPair, error) {
|
||||||
return nil, nil, fmt.Errorf("unable to sign the server certificate: %v", err)
|
return nil, nil, fmt.Errorf("unable to sign the server certificate: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &triple.KeyPair{
|
return &keyPair{
|
||||||
Key: key,
|
Key: key,
|
||||||
Cert: cert,
|
Cert: cert,
|
||||||
}, ca, nil
|
}, ca, nil
|
||||||
|
@ -182,3 +182,26 @@ func TestCreateSSLCert(t *testing.T) {
|
||||||
t.Fatalf("expected cname echoheaders but %v returned", ngxCert.CN[0])
|
t.Fatalf("expected cname echoheaders but %v returned", ngxCert.CN[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type keyPair struct {
|
||||||
|
Key *rsa.PrivateKey
|
||||||
|
Cert *x509.Certificate
|
||||||
|
}
|
||||||
|
|
||||||
|
func newCA(name string) (*keyPair, error) {
|
||||||
|
key, err := certutil.NewPrivateKey()
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("unable to create a private key for a new CA: %v", err)
|
||||||
|
}
|
||||||
|
config := certutil.Config{
|
||||||
|
CommonName: name,
|
||||||
|
}
|
||||||
|
cert, err := certutil.NewSelfSignedCACert(config, key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("unable to create a self-signed certificate for a new CA: %v", err)
|
||||||
|
}
|
||||||
|
return &keyPair{
|
||||||
|
Key: key,
|
||||||
|
Cert: cert,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
|
@ -75,7 +75,7 @@ func (t *Queue) EnqueueSkippableTask(obj interface{}) {
|
||||||
// enqueue enqueues ns/name of the given api object in the task queue.
|
// enqueue enqueues ns/name of the given api object in the task queue.
|
||||||
func (t *Queue) enqueue(obj interface{}, skippable bool) {
|
func (t *Queue) enqueue(obj interface{}, skippable bool) {
|
||||||
if t.IsShuttingDown() {
|
if t.IsShuttingDown() {
|
||||||
glog.Errorf("queue has been shutdown, failed to enqueue: %v", obj)
|
klog.Errorf("queue has been shutdown, failed to enqueue: %v", obj)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,10 +84,10 @@ func (t *Queue) enqueue(obj interface{}, skippable bool) {
|
||||||
// make sure the timestamp is bigger than lastSync
|
// make sure the timestamp is bigger than lastSync
|
||||||
ts = time.Now().Add(24 * time.Hour).UnixNano()
|
ts = time.Now().Add(24 * time.Hour).UnixNano()
|
||||||
}
|
}
|
||||||
glog.V(3).Infof("queuing item %v", obj)
|
klog.V(3).Infof("queuing item %v", obj)
|
||||||
key, err := t.fn(obj)
|
key, err := t.fn(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("%v", err)
|
klog.Errorf("%v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
t.queue.Add(Element{
|
t.queue.Add(Element{
|
||||||
|
@ -119,15 +119,15 @@ func (t *Queue) worker() {
|
||||||
|
|
||||||
item := key.(Element)
|
item := key.(Element)
|
||||||
if t.lastSync > item.Timestamp {
|
if t.lastSync > item.Timestamp {
|
||||||
glog.V(3).Infof("skipping %v sync (%v > %v)", item.Key, t.lastSync, item.Timestamp)
|
klog.V(3).Infof("skipping %v sync (%v > %v)", item.Key, t.lastSync, item.Timestamp)
|
||||||
t.queue.Forget(key)
|
t.queue.Forget(key)
|
||||||
t.queue.Done(key)
|
t.queue.Done(key)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(3).Infof("syncing %v", item.Key)
|
klog.V(3).Infof("syncing %v", item.Key)
|
||||||
if err := t.sync(key); err != nil {
|
if err := t.sync(key); err != nil {
|
||||||
glog.Warningf("requeuing %v, err %v", item.Key, err)
|
klog.Warningf("requeuing %v, err %v", item.Key, err)
|
||||||
t.queue.AddRateLimited(Element{
|
t.queue.AddRateLimited(Element{
|
||||||
Key: item.Key,
|
Key: item.Key,
|
||||||
Timestamp: time.Now().UnixNano(),
|
Timestamp: time.Now().UnixNano(),
|
||||||
|
|
|
@ -19,7 +19,7 @@ package e2e
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
|
|
||||||
"k8s.io/ingress-nginx/test/e2e/framework"
|
"k8s.io/ingress-nginx/test/e2e/framework"
|
||||||
|
@ -29,7 +29,7 @@ func init() {
|
||||||
framework.RegisterParseFlags()
|
framework.RegisterParseFlags()
|
||||||
|
|
||||||
if "" == framework.TestContext.KubeConfig {
|
if "" == framework.TestContext.KubeConfig {
|
||||||
glog.Fatalf("environment variable %v must be set", clientcmd.RecommendedConfigPathEnvVar)
|
klog.Fatalf("environment variable %v must be set", clientcmd.RecommendedConfigPathEnvVar)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func TestE2E(t *testing.T) {
|
func TestE2E(t *testing.T) {
|
||||||
|
|
|
@ -30,7 +30,7 @@ import (
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
restclient "k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"k8s.io/klog"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
|
@ -235,8 +235,8 @@ func (f *Framework) matchNginxConditions(name string, matcher func(cfg string) b
|
||||||
|
|
||||||
var match bool
|
var match bool
|
||||||
errs := InterceptGomegaFailures(func() {
|
errs := InterceptGomegaFailures(func() {
|
||||||
if glog.V(10) && len(o) > 0 {
|
if klog.V(10) && len(o) > 0 {
|
||||||
glog.Infof("nginx.conf:\n%v", o)
|
klog.Infof("nginx.conf:\n%v", o)
|
||||||
}
|
}
|
||||||
|
|
||||||
// passes the nginx config to the passed function
|
// passes the nginx config to the passed function
|
||||||
|
@ -250,7 +250,7 @@ func (f *Framework) matchNginxConditions(name string, matcher func(cfg string) b
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
glog.V(2).Infof("Errors waiting for conditions: %v", errs)
|
klog.V(2).Infof("Errors waiting for conditions: %v", errs)
|
||||||
}
|
}
|
||||||
|
|
||||||
return false, nil
|
return false, nil
|
||||||
|
@ -329,7 +329,7 @@ func UpdateDeployment(kubeClientSet kubernetes.Interface, namespace string, name
|
||||||
}
|
}
|
||||||
|
|
||||||
if *deployment.Spec.Replicas != int32(replicas) {
|
if *deployment.Spec.Replicas != int32(replicas) {
|
||||||
glog.Infof("updating replica count from %v to %v...", *deployment.Spec.Replicas, replicas)
|
klog.Infof("updating replica count from %v to %v...", *deployment.Spec.Replicas, replicas)
|
||||||
deployment, err := kubeClientSet.AppsV1beta1().Deployments(namespace).Get(name, metav1.GetOptions{})
|
deployment, err := kubeClientSet.AppsV1beta1().Deployments(namespace).Get(name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue