47 lines
2.0 KiB
Go
47 lines
2.0 KiB
Go
package options
|
|
|
|
import (
|
|
"github.com/spf13/pflag"
|
|
)
|
|
|
|
const (
|
|
defaultBindAddress = "0.0.0.0"
|
|
defaultPort = 8443
|
|
defaultCertDir = "/tmp/k8s-webhook-server/serving-certs"
|
|
)
|
|
|
|
// Options contains everything necessary to create and run webhook server.
|
|
type Options struct {
|
|
// BindAddress is the IP address on which to listen for the --secure-port port.
|
|
// Default is "0.0.0.0".
|
|
BindAddress string
|
|
// SecurePort is the port that the webhook server serves at.
|
|
// Default is 8443.
|
|
SecurePort int
|
|
// CertDir is the directory that contains the server key and certificate.
|
|
// if not set, webhook server would look up the server key and certificate in {TempDir}/k8s-webhook-server/serving-certs.
|
|
// The server key and certificate must be named `tls.key` and `tls.crt`, respectively.
|
|
CertDir string
|
|
// KubeAPIQPS is the QPS to use while talking with karmada-apiserver.
|
|
KubeAPIQPS float32
|
|
// KubeAPIBurst is the burst to allow while talking with karmada-apiserver.
|
|
KubeAPIBurst int
|
|
}
|
|
|
|
// NewOptions builds an empty options.
|
|
func NewOptions() *Options {
|
|
return &Options{}
|
|
}
|
|
|
|
// AddFlags adds flags to the specified FlagSet.
|
|
func (o *Options) AddFlags(flags *pflag.FlagSet) {
|
|
flags.StringVar(&o.BindAddress, "bind-address", defaultBindAddress,
|
|
"The IP address on which to listen for the --secure-port port.")
|
|
flags.IntVar(&o.SecurePort, "secure-port", defaultPort,
|
|
"The secure port on which to serve HTTPS.")
|
|
flags.StringVar(&o.CertDir, "cert-dir", defaultCertDir,
|
|
"The directory that contains the server key(named tls.key) and certificate(named tls.crt).")
|
|
flags.Float32Var(&o.KubeAPIQPS, "kube-api-qps", 40.0, "QPS to use while talking with karmada-apiserver. Doesn't cover events and node heartbeat apis which rate limiting is controlled by a different set of flags.")
|
|
flags.IntVar(&o.KubeAPIBurst, "kube-api-burst", 60, "Burst to use while talking with karmada-apiserver. Doesn't cover events and node heartbeat apis which rate limiting is controlled by a different set of flags.")
|
|
}
|