mirror of
https://github.com/eliasstepanik/caddy-ingess.git
synced 2026-01-10 20:18:28 +00:00
remove klog and update tls app config
This commit is contained in:
parent
f0c4f064c3
commit
9a07d46e31
@ -4,7 +4,7 @@ import (
|
||||
"flag"
|
||||
|
||||
"github.com/caddyserver/ingress/internal/caddy"
|
||||
"k8s.io/klog"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func parseFlags() caddy.ControllerConfig {
|
||||
@ -23,7 +23,7 @@ func parseFlags() caddy.ControllerConfig {
|
||||
flag.Parse()
|
||||
|
||||
if email == "" && enableAutomaticTLS {
|
||||
klog.Info("An email must be defined for automatic tls features, set flag `email` with the email address you would like to use for certificate registration.")
|
||||
logrus.Info("An email must be defined for automatic tls features, set flag `email` with the email address you would like to use for certificate registration.")
|
||||
enableAutomaticTLS = false
|
||||
}
|
||||
|
||||
|
||||
@ -6,12 +6,12 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/caddyserver/ingress/internal/controller"
|
||||
"github.com/sirupsen/logrus"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/apimachinery/pkg/version"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -23,14 +23,12 @@ const (
|
||||
)
|
||||
|
||||
func main() {
|
||||
klog.InitFlags(nil)
|
||||
|
||||
// parse any flags required to configure the caddy ingress controller
|
||||
cfg := parseFlags()
|
||||
|
||||
if cfg.WatchNamespace == "" {
|
||||
cfg.WatchNamespace = v1.NamespaceAll
|
||||
klog.Warning("-namespace flag is unset, caddy ingress controller will monitor ingress resources in all namespaces.")
|
||||
logrus.Warning("-namespace flag is unset, caddy ingress controller will monitor ingress resources in all namespaces.")
|
||||
}
|
||||
|
||||
// get client to access the kubernetes service api
|
||||
@ -42,7 +40,7 @@ func main() {
|
||||
API server certificates or Service Accounts configuration)
|
||||
`
|
||||
|
||||
klog.Fatalf(msg, err)
|
||||
logrus.Fatalf(msg, err)
|
||||
}
|
||||
|
||||
restClient := kubeClient.ExtensionsV1beta1().RESTClient()
|
||||
@ -54,7 +52,7 @@ func main() {
|
||||
healthPort := 9090
|
||||
go startMetricsServer(healthPort)
|
||||
|
||||
klog.Info("Starting the caddy ingress controller")
|
||||
logrus.Info("Starting the caddy ingress controller")
|
||||
|
||||
// start the ingress controller
|
||||
stopCh := make(chan struct{}, 1)
|
||||
@ -100,7 +98,7 @@ func startMetricsServer(port int) {
|
||||
IdleTimeout: 120 * time.Second,
|
||||
}
|
||||
|
||||
klog.Fatal(server.ListenAndServe())
|
||||
logrus.Fatal(server.ListenAndServe())
|
||||
}
|
||||
|
||||
// createApiserverClient creates a new Kubernetes REST client. We assume the
|
||||
@ -115,7 +113,7 @@ func createApiserverClient() (*kubernetes.Clientset, error) {
|
||||
cfg.Burst = defaultBurst
|
||||
cfg.ContentType = "application/vnd.kubernetes.protobuf"
|
||||
|
||||
klog.Infof("Creating API client for %s", cfg.Host)
|
||||
logrus.Infof("Creating API client for %s", cfg.Host)
|
||||
|
||||
client, err := kubernetes.NewForConfig(cfg)
|
||||
if err != nil {
|
||||
@ -130,8 +128,6 @@ func createApiserverClient() (*kubernetes.Clientset, error) {
|
||||
Jitter: 0.1,
|
||||
}
|
||||
|
||||
klog.V(2).Info("Attempting to discover Kubernetes version")
|
||||
|
||||
var v *version.Info
|
||||
var retries int
|
||||
var lastErr error
|
||||
@ -143,7 +139,7 @@ func createApiserverClient() (*kubernetes.Clientset, error) {
|
||||
}
|
||||
|
||||
lastErr = err
|
||||
klog.V(2).Infof("Unexpected error discovering Kubernetes version (attempt %v): %v", retries, err)
|
||||
logrus.Infof("Unexpected error discovering Kubernetes version (attempt %v): %v", retries, err)
|
||||
retries++
|
||||
return false, nil
|
||||
})
|
||||
@ -155,11 +151,11 @@ func createApiserverClient() (*kubernetes.Clientset, error) {
|
||||
|
||||
// this should not happen, warn the user
|
||||
if retries > 0 {
|
||||
klog.Warningf("Initial connection to the Kubernetes API server was retried %d times.", retries)
|
||||
logrus.Warningf("Initial connection to the Kubernetes API server was retried %d times.", retries)
|
||||
}
|
||||
|
||||
msg := "Running in Kubernetes cluster version v%v.%v (%v) - git (%v) commit %v - platform %v"
|
||||
klog.Infof(msg, v.Major, v.Minor, v.GitVersion, v.GitTreeState, v.GitCommit, v.Platform)
|
||||
logrus.Infof(msg, v.Major, v.Minor, v.GitVersion, v.GitTreeState, v.GitCommit, v.Platform)
|
||||
|
||||
return client, nil
|
||||
}
|
||||
|
||||
2
go.mod
2
go.mod
@ -9,6 +9,7 @@ require (
|
||||
github.com/mholt/certmagic v0.5.1
|
||||
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
|
||||
github.com/pkg/errors v0.8.1
|
||||
github.com/sirupsen/logrus v1.2.0
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
|
||||
google.golang.org/grpc v1.20.1 // indirect
|
||||
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
|
||||
@ -18,7 +19,6 @@ require (
|
||||
k8s.io/apimachinery v0.0.0-20190602125621-c0632ccbde11
|
||||
k8s.io/client-go v0.0.0-20190602130007-e65ca70987a6
|
||||
k8s.io/cloud-provider v0.0.0-20190503112208-4f570a5e5694 // indirect
|
||||
k8s.io/klog v0.3.2
|
||||
k8s.io/kubernetes v1.14.1
|
||||
k8s.io/utils v0.0.0-20190506122338-8fab8cb257d5 // indirect
|
||||
)
|
||||
|
||||
6
go.sum
6
go.sum
@ -109,8 +109,6 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv
|
||||
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/mholt/certmagic v0.5.1 h1:8Pf6Hwwlh5sbT3nwn3ovXyXWxHCEM54wvfLzTrQ+UiM=
|
||||
github.com/mholt/certmagic v0.5.1/go.mod h1:g4cOPxcjV0oFq3qwpjSA30LReKD8AoIfwAY9VvG35NY=
|
||||
github.com/miekg/dns v1.1.3 h1:1g0r1IvskvgL8rR+AcHzUA+oFmGcQlaIm4IqakufeMM=
|
||||
github.com/miekg/dns v1.1.3/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
@ -142,8 +140,10 @@ github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7q
|
||||
github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a h1:9a8MnZMP0X2nLJdBg+pBmGgkJlSaKC2KaQmTCk1XDtE=
|
||||
github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M=
|
||||
github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/soheilhy/cmux v0.1.3/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||
github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=
|
||||
@ -161,7 +161,6 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||
go.starlark.net v0.0.0-20190506145734-95b2783e7d63/go.mod h1:c1/X6cHgvdXj6pUlmWKMkuqRnW4K8x2vwt6JAaaircg=
|
||||
go.starlark.net v0.0.0-20190604130855-6ddc71c0ba77 h1:KPzANX1mXqnSWenqVWkSTsQWiaUSpTY5GyGZKI6lStw=
|
||||
go.starlark.net v0.0.0-20190604130855-6ddc71c0ba77/go.mod h1:c1/X6cHgvdXj6pUlmWKMkuqRnW4K8x2vwt6JAaaircg=
|
||||
go.uber.org/atomic v0.0.0-20181018215023-8dc6146f7569/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
@ -188,7 +187,6 @@ golang.org/x/net v0.0.0-20190206173232-65e2d4e15006 h1:bfLnR+k0tq5Lqt6dflRLcZiz6
|
||||
golang.org/x/net v0.0.0-20190206173232-65e2d4e15006/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65 h1:+rhAzEzT3f4JtomfC371qB+0Ola2caSKcY69NUBZrRQ=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
|
||||
24
hack/test/example-deployment.yaml
Normal file
24
hack/test/example-deployment.yaml
Normal file
@ -0,0 +1,24 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: example
|
||||
labels:
|
||||
app: example
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: example
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: example
|
||||
spec:
|
||||
containers:
|
||||
- name: httpecho
|
||||
image: hashicorp/http-echo
|
||||
args:
|
||||
- "-listen=:8080"
|
||||
- "-text=hello world"
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
24
hack/test/example-deployment2.yaml
Normal file
24
hack/test/example-deployment2.yaml
Normal file
@ -0,0 +1,24 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: example2
|
||||
labels:
|
||||
app: example2
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: example2
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: example2
|
||||
spec:
|
||||
containers:
|
||||
- name: httpecho
|
||||
image: hashicorp/http-echo
|
||||
args:
|
||||
- "-listen=:8080"
|
||||
- "-text=hello world 2"
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
19
hack/test/example-ingress.yaml
Normal file
19
hack/test/example-ingress.yaml
Normal file
@ -0,0 +1,19 @@
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: example
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: caddy
|
||||
spec:
|
||||
rules:
|
||||
- host: caddy2.kubed.co
|
||||
http:
|
||||
paths:
|
||||
- path: /hello2
|
||||
backend:
|
||||
serviceName: example2
|
||||
servicePort: 8080
|
||||
- path: /hello
|
||||
backend:
|
||||
serviceName: example
|
||||
servicePort: 8080
|
||||
12
hack/test/example-service.yaml
Normal file
12
hack/test/example-service.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
kind: Service
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: example
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: example
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 80
|
||||
targetPort: 8080
|
||||
12
hack/test/example-service2.yaml
Normal file
12
hack/test/example-service2.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
kind: Service
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: example2
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: example2
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 80
|
||||
targetPort: 8080
|
||||
@ -99,8 +99,8 @@ func NewConfig(namespace string, cfg ControllerConfig) *Config {
|
||||
Automation: caddytls.AutomationConfig{
|
||||
Policies: []caddytls.AutomationPolicy{
|
||||
caddytls.AutomationPolicy{
|
||||
Hosts: nil,
|
||||
Management: autoPolicyBytes,
|
||||
Hosts: nil,
|
||||
ManagementRaw: autoPolicyBytes,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@ -5,8 +5,8 @@ import (
|
||||
|
||||
"github.com/caddyserver/ingress/internal/caddy"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"k8s.io/api/extensions/v1beta1"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
// onResourceAdded runs when an ingress resource is added to the cluster.
|
||||
@ -58,7 +58,7 @@ type ResourceDeletedAction struct {
|
||||
}
|
||||
|
||||
func (r ResourceAddedAction) handle(c *CaddyController) error {
|
||||
klog.Info("New ingress resource detected, updating Caddy config...")
|
||||
logrus.Info("New ingress resource detected, updating Caddy config...")
|
||||
|
||||
// configure caddy to handle this resource
|
||||
ing, ok := r.resource.(*v1beta1.Ingress)
|
||||
@ -80,12 +80,12 @@ func (r ResourceAddedAction) handle(c *CaddyController) error {
|
||||
return errors.Wrapf(err, "syncing ingress source address name: %v", ing.GetName())
|
||||
}
|
||||
|
||||
klog.Info("Caddy reloaded successfully.")
|
||||
logrus.Info("Caddy reloaded successfully.")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r ResourceUpdatedAction) handle(c *CaddyController) error {
|
||||
klog.Info("Ingress resource update detected, updating Caddy config...")
|
||||
logrus.Info("Ingress resource update detected, updating Caddy config...")
|
||||
|
||||
// update caddy config regarding this ingress
|
||||
ing, ok := r.resource.(*v1beta1.Ingress)
|
||||
@ -101,12 +101,12 @@ func (r ResourceUpdatedAction) handle(c *CaddyController) error {
|
||||
return err
|
||||
}
|
||||
|
||||
klog.Info("Caddy reloaded successfully.")
|
||||
logrus.Info("Caddy reloaded successfully.")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r ResourceDeletedAction) handle(c *CaddyController) error {
|
||||
klog.Info("Ingress resource deletion detected, updating Caddy config...")
|
||||
logrus.Info("Ingress resource deletion detected, updating Caddy config...")
|
||||
|
||||
// delete all resources from caddy config that are associated with this resource
|
||||
// reload caddy config
|
||||
@ -123,7 +123,7 @@ func (r ResourceDeletedAction) handle(c *CaddyController) error {
|
||||
return err
|
||||
}
|
||||
|
||||
klog.Info("Caddy reloaded successfully.")
|
||||
logrus.Info("Caddy reloaded successfully.")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ import (
|
||||
"github.com/caddyserver/ingress/internal/pod"
|
||||
"github.com/caddyserver/ingress/internal/store"
|
||||
"github.com/caddyserver/ingress/pkg/storage"
|
||||
"github.com/sirupsen/logrus"
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
"k8s.io/api/extensions/v1beta1"
|
||||
"k8s.io/apimachinery/pkg/fields"
|
||||
@ -23,7 +24,6 @@ import (
|
||||
"k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
"k8s.io/client-go/util/workqueue"
|
||||
"k8s.io/klog"
|
||||
|
||||
// load required caddy plugins
|
||||
_ "github.com/caddyserver/caddy2/modules/caddyhttp"
|
||||
@ -68,7 +68,7 @@ func NewCaddyController(kubeClient *kubernetes.Clientset, restClient rest.Interf
|
||||
|
||||
podInfo, err := pod.GetPodDetails(kubeClient)
|
||||
if err != nil {
|
||||
klog.Fatalf("Unexpected error obtaining pod information: %v", err)
|
||||
logrus.Fatalf("Unexpected error obtaining pod information: %v", err)
|
||||
}
|
||||
|
||||
controller.podInfo = podInfo
|
||||
@ -95,7 +95,7 @@ func NewCaddyController(kubeClient *kubernetes.Clientset, restClient rest.Interf
|
||||
// start caddy2
|
||||
err = caddy2.StartAdmin("127.0.0.1:1234")
|
||||
if err != nil {
|
||||
klog.Fatal(err)
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
return controller
|
||||
@ -112,7 +112,7 @@ func (c *CaddyController) Shutdown() error {
|
||||
func (c *CaddyController) Run(stopCh chan struct{}) {
|
||||
err := c.reloadCaddy()
|
||||
if err != nil {
|
||||
klog.Errorf("initial caddy config load failed, %v", err.Error())
|
||||
logrus.Errorf("initial caddy config load failed, %v", err.Error())
|
||||
}
|
||||
|
||||
defer runtime.HandleCrash()
|
||||
@ -136,12 +136,12 @@ func (c *CaddyController) Run(stopCh chan struct{}) {
|
||||
|
||||
// wait for SIGTERM
|
||||
<-stopCh
|
||||
klog.Info("stopping ingress controller")
|
||||
logrus.Info("stopping ingress controller")
|
||||
|
||||
var exitCode int
|
||||
err = c.Shutdown()
|
||||
if err != nil {
|
||||
klog.Errorf("could not shutdown ingress controller properly, %v", err.Error())
|
||||
logrus.Errorf("could not shutdown ingress controller properly, %v", err.Error())
|
||||
exitCode = 1
|
||||
}
|
||||
|
||||
@ -178,7 +178,7 @@ func (c *CaddyController) processNextItem() bool {
|
||||
|
||||
// handleErrs reports errors received from queue actions.
|
||||
func (c *CaddyController) handleErr(err error, action interface{}) {
|
||||
klog.Error(err)
|
||||
logrus.Error(err)
|
||||
}
|
||||
|
||||
// reloadCaddy reloads the internal caddy instance with new config.
|
||||
@ -188,6 +188,8 @@ func (c *CaddyController) reloadCaddy() error {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println(string(j))
|
||||
|
||||
// post to load endpoint
|
||||
resp, err := http.Post("http://127.0.0.1:1234/load", "application/json", bytes.NewBuffer(j))
|
||||
if err != nil {
|
||||
|
||||
@ -6,12 +6,12 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
pool "gopkg.in/go-playground/pool.v3"
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
"k8s.io/api/extensions/v1beta1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
// updateIngStatuses starts a queue and adds all monitored ingresses to update their status source address to the on
|
||||
@ -29,7 +29,7 @@ func (c *CaddyController) updateIngStatuses(controllerAddresses []apiv1.LoadBala
|
||||
|
||||
// check to see if ingresses source address does not match the ingress controller's.
|
||||
if ingressSliceEqual(curIPs, controllerAddresses) {
|
||||
klog.V(3).Infof("skipping update of Ingress %v/%v (no change)", ing.Namespace, ing.Name)
|
||||
logrus.Infof("skipping update of Ingress %v/%v (no change)", ing.Namespace, ing.Name)
|
||||
continue
|
||||
}
|
||||
|
||||
@ -54,12 +54,12 @@ func runUpdate(ing *v1beta1.Ingress, status []apiv1.LoadBalancerIngress, client
|
||||
return nil, errors.Wrap(err, fmt.Sprintf("unexpected error searching Ingress %v/%v", ing.Namespace, ing.Name))
|
||||
}
|
||||
|
||||
klog.Infof("updating Ingress %v/%v status from %v to %v", currIng.Namespace, currIng.Name, currIng.Status.LoadBalancer.Ingress, status)
|
||||
logrus.Infof("updating Ingress %v/%v status from %v to %v", currIng.Namespace, currIng.Name, currIng.Status.LoadBalancer.Ingress, status)
|
||||
currIng.Status.LoadBalancer.Ingress = status
|
||||
|
||||
_, err = ingClient.UpdateStatus(currIng)
|
||||
if err != nil {
|
||||
klog.Warningf("error updating ingress rule: %v", err)
|
||||
logrus.Warningf("error updating ingress rule: %v", err)
|
||||
}
|
||||
|
||||
return true, nil
|
||||
|
||||
@ -5,9 +5,9 @@ import (
|
||||
"sort"
|
||||
|
||||
"github.com/caddyserver/ingress/internal/pod"
|
||||
"github.com/sirupsen/logrus"
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
"k8s.io/api/extensions/v1beta1"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
// dispatchSync is run every syncInterval duration to sync ingress source address fields.
|
||||
@ -33,7 +33,7 @@ func (c *CaddyController) syncStatus(ings []*v1beta1.Ingress) error {
|
||||
|
||||
// this happens about every 30 seconds and can pollute the logs, so we
|
||||
// only want to log on higher verbosity levels.
|
||||
klog.V(2).Info("Synching Ingress resource source addresses")
|
||||
logrus.Info("Synching Ingress resource source addresses")
|
||||
|
||||
c.updateIngStatuses(sliceToLoadBalancerIngress(addrs), ings)
|
||||
|
||||
|
||||
@ -4,11 +4,11 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/klog"
|
||||
"k8s.io/kubernetes/pkg/kubelet/util/sliceutils"
|
||||
)
|
||||
|
||||
@ -53,7 +53,7 @@ func GetAddresses(p *Info, kubeClient *kubernetes.Clientset) ([]string, error) {
|
||||
func GetNodeIPOrName(kubeClient *kubernetes.Clientset, name string, useInternalIP bool) string {
|
||||
node, err := kubeClient.CoreV1().Nodes().Get(name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
klog.Errorf("Error getting node %v: %v", name, err)
|
||||
logrus.Errorf("Error getting node %v: %v", name, err)
|
||||
return ""
|
||||
}
|
||||
|
||||
|
||||
@ -2,10 +2,10 @@ package store
|
||||
|
||||
import (
|
||||
"github.com/caddyserver/ingress/internal/caddy"
|
||||
"github.com/sirupsen/logrus"
|
||||
"k8s.io/api/extensions/v1beta1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
// Store represents a collection of ingresses and secrets that we are monitoring.
|
||||
@ -20,7 +20,7 @@ type Store struct {
|
||||
func NewStore(kubeClient *kubernetes.Clientset, namespace string, cfg caddy.ControllerConfig) *Store {
|
||||
ingresses, err := kubeClient.ExtensionsV1beta1().Ingresses("").List(v1.ListOptions{})
|
||||
if err != nil {
|
||||
klog.Errorf("could not get existing ingresses in cluster")
|
||||
logrus.Errorf("could not get existing ingresses in cluster")
|
||||
return &Store{}
|
||||
}
|
||||
|
||||
|
||||
26
kubernetes/generated/clusterrole.yaml
Executable file
26
kubernetes/generated/clusterrole.yaml
Executable file
@ -0,0 +1,26 @@
|
||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: caddy-ingress-controller-role
|
||||
namespace: caddy-system
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
- "extensions"
|
||||
resources:
|
||||
- ingresses
|
||||
- ingresses/status
|
||||
- secrets
|
||||
verbs: ["*"]
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- services
|
||||
- pods
|
||||
- nodes
|
||||
- routes
|
||||
- extensions
|
||||
verbs:
|
||||
- list
|
||||
- get
|
||||
- watch
|
||||
13
kubernetes/generated/clusterrolebinding.yaml
Executable file
13
kubernetes/generated/clusterrolebinding.yaml
Executable file
@ -0,0 +1,13 @@
|
||||
kind: ClusterRoleBinding
|
||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||
metadata:
|
||||
name: caddy-ingress-controller-role-binding
|
||||
namespace: caddy-system
|
||||
roleRef:
|
||||
kind: ClusterRole
|
||||
name: caddy-ingress-controller-role
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: caddy-ingress-controller
|
||||
namespace: caddy-system
|
||||
67
kubernetes/generated/deployment.yaml
Executable file
67
kubernetes/generated/deployment.yaml
Executable file
@ -0,0 +1,67 @@
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: caddy-ingress-controller
|
||||
namespace: caddy-system
|
||||
labels:
|
||||
app: caddy-ingress-controller
|
||||
chart: "caddy-ingress-controller-v0.1.0"
|
||||
release: "release-name"
|
||||
heritage: "Tiller"
|
||||
version: v0.1.0
|
||||
|
||||
spec:
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: caddy-ingress-controller
|
||||
release: "release-name"
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: caddy-ingress-controller
|
||||
chart: "caddy-ingress-controller-v0.1.2"
|
||||
release: "release-name"
|
||||
heritage: "Tiller"
|
||||
version: v0.1.0
|
||||
|
||||
spec:
|
||||
serviceAccountName: caddy-ingress-controller
|
||||
volumes:
|
||||
- name: tmp
|
||||
emptyDir: {}
|
||||
containers:
|
||||
- name: caddy-ingress-controller
|
||||
image: "gcr.io/danny-239313/ingresscontroller:v0.1.2"
|
||||
imagePullPolicy: IfNotPresent
|
||||
volumeMounts:
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: true
|
||||
capabilities:
|
||||
drop:
|
||||
- ALL
|
||||
add:
|
||||
- NET_BIND_SERVICE
|
||||
# www-data -> 33
|
||||
runAsUser: 0
|
||||
runAsGroup: 0
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 80
|
||||
- name: https
|
||||
containerPort: 443
|
||||
env:
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.name
|
||||
- name: POD_NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.namespace
|
||||
args:
|
||||
- -tls
|
||||
- -email=navdgo@gmail.com
|
||||
20
kubernetes/generated/loadbalancer.yaml
Executable file
20
kubernetes/generated/loadbalancer.yaml
Executable file
@ -0,0 +1,20 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: caddy-ingress-controller
|
||||
namespace: caddy-system
|
||||
labels:
|
||||
app: caddy-ingress-controller
|
||||
spec:
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
||||
protocol: TCP
|
||||
targetPort: http
|
||||
- name: https
|
||||
port: 443
|
||||
protocol: TCP
|
||||
targetPort: https
|
||||
selector:
|
||||
app: caddy-ingress-controller
|
||||
type: "LoadBalancer"
|
||||
12
kubernetes/generated/serviceaccount.yaml
Executable file
12
kubernetes/generated/serviceaccount.yaml
Executable file
@ -0,0 +1,12 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
namespace: caddy-system
|
||||
labels:
|
||||
app: caddy-ingress-controller
|
||||
chart: "caddy-ingress-controller-v0.1.0"
|
||||
release: "release-name"
|
||||
heritage: "Tiller"
|
||||
version: v0.1.0
|
||||
|
||||
name: caddy-ingress-controller
|
||||
@ -6,10 +6,10 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/mholt/certmagic"
|
||||
"github.com/sirupsen/logrus"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
// matchLabels are attached to each resource so that they can be found in the future.
|
||||
@ -46,7 +46,7 @@ func (s *SecretStorage) Exists(key string) bool {
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
logrus.Error(err)
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user