mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-03 04:07:51 +08:00
Merge pull request #177 from GLYASAI/V5.0
make resyncPeriod a configurable parameter. add two parameters for upstream-tcp.tmpl. the two parameters are max_fails and fail_timeout
This commit is contained in:
commit
f1ddf2c108
@ -57,6 +57,7 @@ type Config struct {
|
||||
KeepaliveRequests int
|
||||
NginxUser string
|
||||
IP string
|
||||
ResyncPeriod time.Duration
|
||||
// health check
|
||||
HealthPath string
|
||||
HealthCheckTimeout time.Duration
|
||||
@ -99,7 +100,8 @@ func (g *GWServer) AddFlags(fs *pflag.FlagSet) {
|
||||
fs.StringVar(&g.NginxUser, "nginx-user", "root", "nginx user name")
|
||||
fs.IntVar(&g.KeepaliveRequests, "keepalive-requests", 10000, "Number of requests a client can make over the keep-alive connection. ")
|
||||
fs.IntVar(&g.KeepaliveTimeout, "keepalive-timeout", 30, "Timeout for keep-alive connections. Server will close connections after this time.")
|
||||
fs.StringVar(&g.IP, "ip", "0.0.0.0", "Node ip.") // TODO: more detail
|
||||
fs.StringVar(&g.IP, "ip", "0.0.0.0", "Node ip.") // TODO: more detail
|
||||
fs.DurationVar(&g.ResyncPeriod, "resync-period", 10, "the default resync period for any handlers added via AddEventHandler and how frequently the listener wants a full resync from the shared informer")
|
||||
// etcd
|
||||
fs.StringSliceVar(&g.EtcdEndpoint, "etcd-endpoints", []string{"http://127.0.0.1:2379"}, "etcd cluster endpoints.")
|
||||
fs.IntVar(&g.EtcdTimeout, "etcd-timeout", 5, "etcd http timeout seconds")
|
||||
|
@ -22,14 +22,12 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/goodrain/rainbond/gateway/annotations/l4"
|
||||
"github.com/goodrain/rainbond/gateway/util"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/goodrain/rainbond/gateway/util"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/eapache/channels"
|
||||
@ -142,7 +140,7 @@ func New(client kubernetes.Interface,
|
||||
store.listers.IngressAnnotation.Store = cache.NewStore(cache.DeletionHandlingMetaNamespaceKeyFunc)
|
||||
|
||||
// create informers factory, enable and assign required informers
|
||||
infFactory := informers.NewFilteredSharedInformerFactory(client, time.Second, corev1.NamespaceAll,
|
||||
infFactory := informers.NewFilteredSharedInformerFactory(client, conf.ResyncPeriod, corev1.NamespaceAll,
|
||||
func(options *metav1.ListOptions) {
|
||||
options.LabelSelector = "creater=Rainbond"
|
||||
})
|
||||
@ -317,9 +315,9 @@ func New(client kubernetes.Interface,
|
||||
},
|
||||
}
|
||||
|
||||
store.informers.Ingress.AddEventHandlerWithResyncPeriod(ingEventHandler, 10*time.Second)
|
||||
store.informers.Secret.AddEventHandlerWithResyncPeriod(secEventHandler, 10*time.Second)
|
||||
store.informers.Endpoint.AddEventHandlerWithResyncPeriod(epEventHandler, 10*time.Second)
|
||||
store.informers.Ingress.AddEventHandler(ingEventHandler)
|
||||
store.informers.Secret.AddEventHandler(secEventHandler)
|
||||
store.informers.Endpoint.AddEventHandler(epEventHandler)
|
||||
store.informers.Service.AddEventHandler(cache.ResourceEventHandlerFuncs{})
|
||||
|
||||
return store
|
||||
|
@ -3,7 +3,11 @@ upstream {{$upstream.Name}} {
|
||||
{{ if $upstream.UseLeastConn }} least_conn; {{ end }}
|
||||
{{ range $server := $upstream.Servers }}
|
||||
{{ $params := $server.Params }}
|
||||
server {{$server.Address}} weight={{$params.Weight}};
|
||||
server {{ $server.Address }}
|
||||
{{if gt $params.Weight 0}}weight={{$params.Weight}}{{end}}
|
||||
{{if gt $params.MaxFails 0}}max_fails={{$params.MaxFails}}{{end}}
|
||||
{{if $params.FailTimeout }}fail_timeout={{$params.FailTimeout}}{{end}}
|
||||
;
|
||||
{{ end }}
|
||||
}
|
||||
{{ end }}
|
Loading…
Reference in New Issue
Block a user