diff --git a/pkg/annotations/cfgSnippet.go b/pkg/annotations/cfgSnippet.go index 2b2d367f..bc20aa4f 100644 --- a/pkg/annotations/cfgSnippet.go +++ b/pkg/annotations/cfgSnippet.go @@ -28,18 +28,18 @@ const ( ) type CfgSnippet struct { + ingress *store.Ingress + service *store.Service name string frontend string backend string - ingress *store.Ingress - service *store.Service } type cfgData struct { + status store.Status value []string updated []string disabled bool - status store.Status } // CfgSnippetType represents type of a config snippet @@ -82,10 +82,10 @@ func InitCfgSnippet() { } type ConfigSnippetOptions struct { - Name string Backend *string Frontend *string Ingress *store.Ingress + Name string } // DisableConfigSnippets fills a map[cfgSnippetType]struct{} of disabled config snippet types: diff --git a/pkg/controller/builder.go b/pkg/controller/builder.go index 11b36619..103235be 100644 --- a/pkg/controller/builder.go +++ b/pkg/controller/builder.go @@ -43,20 +43,20 @@ import ( ) type Builder struct { + store store.K8s annotations annotations.Annotations haproxyClient api.HAProxyClient gatewayManager gateway.GatewayManager haproxyProcess process.Process haproxyRules rules.Rules restClientSet client.Client + updateStatusManager status.UpdateStatusManager updatePublishServiceFunc func(ingresses []*ingress.Ingress, publishServiceAddresses []string) eventChan chan k8s.SyncDataEvent clientSet *kubernetes.Clientset - haproxyEnv env.Env haproxyCfgFile []byte - store store.K8s + haproxyEnv env.Env osArgs utils.OSArgs - updateStatusManager status.UpdateStatusManager } var defaultEnv = env.Env{ diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index cd70b30b..65980223 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -40,21 +40,21 @@ var logger = utils.GetLogger() // HAProxyController is ingress controller type HAProxyController struct { + store store.K8s gatewayManager gateway.GatewayManager annotations annotations.Annotations + updateStatusManager status.UpdateStatusManager eventChan chan k8s.SyncDataEvent updatePublishServiceFunc func(ingresses []*ingress.Ingress, publishServiceAddresses []string) chShutdown chan struct{} podNamespace string podPrefix string - haproxy haproxy.HAProxy updateHandlers []UpdateHandler - store store.K8s + beforeUpdateHandlers []UpdateHandler + haproxy haproxy.HAProxy osArgs utils.OSArgs auxCfgModTime int64 ready bool - updateStatusManager status.UpdateStatusManager - beforeUpdateHandlers []UpdateHandler } // Wrapping a Native-Client transaction and commit it. diff --git a/pkg/handler/quic.go b/pkg/handler/quic.go index 3f638bef..0d1841fe 100644 --- a/pkg/handler/quic.go +++ b/pkg/handler/quic.go @@ -21,12 +21,12 @@ const ( type Quic struct { AddrIPv4 string AddrIPv6 string - IPv4 bool - IPv6 bool CertDir string - QuicAnnouncePort int64 MaxAge string + QuicAnnouncePort int64 QuicBindPort int64 + IPv4 bool + IPv6 bool } func (q *Quic) Update(k store.K8s, h haproxy.HAProxy, a annotations.Annotations) (err error) { diff --git a/pkg/haproxy/api/runtime.go b/pkg/haproxy/api/runtime.go index 37b828ed..a1a3543d 100644 --- a/pkg/haproxy/api/runtime.go +++ b/pkg/haproxy/api/runtime.go @@ -19,8 +19,8 @@ type RuntimeServerData struct { BackendName string ServerName string IP string - Port int State string + Port int } func (c *clientNative) ExecuteRaw(command string) (result []string, err error) { diff --git a/pkg/haproxy/instance/configuration.go b/pkg/haproxy/instance/configuration.go index ad2d71bd..7fc5d1d2 100644 --- a/pkg/haproxy/instance/configuration.go +++ b/pkg/haproxy/instance/configuration.go @@ -42,8 +42,8 @@ func NeedAction() bool { } type configurationManagerImpl struct { - reload, restart bool logger utils.Logger + reload, restart bool } func NewConfigurationManager() *configurationManagerImpl { diff --git a/pkg/k8s/main.go b/pkg/k8s/main.go index 94872bc2..aab73434 100644 --- a/pkg/k8s/main.go +++ b/pkg/k8s/main.go @@ -76,13 +76,13 @@ type k8s struct { apiExtensionsClient *crdclientset.Clientset publishSvc *utils.NamespaceValue gatewayClient *gatewayclientset.Clientset + crdClient *crdclientset.Clientset podPrefix string podNamespace string whiteListedNS []string syncPeriod time.Duration cacheResyncPeriod time.Duration disableSvcExternalName bool // CVE-2021-25740 - crdClient *crdclientset.Clientset gatewayAPIInstalled bool } diff --git a/pkg/service/service.go b/pkg/service/service.go index 7a788ce8..a36357c4 100644 --- a/pkg/service/service.go +++ b/pkg/service/service.go @@ -35,17 +35,17 @@ var logger = utils.GetLogger() const cookieKey = "ohph7OoGhong" type Service struct { - path *store.IngressPath - resource *store.Service - backend *models.Backend - certs certs.Certificates + certs certs.Certificates + path *store.IngressPath + resource *store.Service + backend *models.Backend + // ingressName string + // ingressNamespace string + ingress *store.Ingress annotations []map[string]string modeTCP bool newBackend bool standalone bool - // ingressName string - // ingressNamespace string - ingress *store.Ingress } // New returns a Service instance to handle the k8s IngressPath resource given in params. diff --git a/pkg/status/updatestatus.go b/pkg/status/updatestatus.go index 71ce119b..35734768 100644 --- a/pkg/status/updatestatus.go +++ b/pkg/status/updatestatus.go @@ -17,9 +17,9 @@ type UpdateStatusManager interface { } type UpdateStatusManagerImpl struct { - updateIngresses []*ingress.Ingress client *kubernetes.Clientset ingressClass string + updateIngresses []*ingress.Ingress emptyIngressClass bool } diff --git a/pkg/store/store.go b/pkg/store/store.go index e1934a99..2b813002 100644 --- a/pkg/store/store.go +++ b/pkg/store/store.go @@ -31,11 +31,11 @@ type K8s struct { SecretsProcessed map[string]struct{} BackendsProcessed map[string]struct{} GatewayClasses map[string]*GatewayClass + HaProxyPods map[string]struct{} + BackendsWithNoConfigSnippets map[string]struct{} GatewayControllerName string PublishServiceAddresses []string - HaProxyPods map[string]struct{} UpdateAllIngresses bool - BackendsWithNoConfigSnippets map[string]struct{} } type NamespacesWatch struct { diff --git a/pkg/utils/flags.go b/pkg/utils/flags.go index 7aea083d..a6ee54d6 100644 --- a/pkg/utils/flags.go +++ b/pkg/utils/flags.go @@ -81,6 +81,7 @@ type OSArgs struct { CfgDir string `long:"config-dir" description:"path to HAProxy configuration directory. NOTE: works only in External mode"` Program string `long:"program" description:"path to HAProxy program. NOTE: works only with External mode"` KubeConfig string `long:"kubeconfig" default:"" description:"combined with -e. location of kube config file"` + DisableConfigSnippets string `long:"disable-config-snippets" description:"Allow to disable config snippets. List of comma separated values (possible values: all/global/backend/frontend)"` Version []bool `short:"v" long:"version" description:"version"` NamespaceWhitelist []string `long:"namespace-whitelist" description:"whitelisted namespaces"` NamespaceBlacklist []string `long:"namespace-blacklist" description:"blacklisted namespaces"` @@ -95,6 +96,8 @@ type OSArgs struct { SyncPeriod time.Duration `long:"sync-period" default:"5s" description:"Sets the period at which the controller syncs HAProxy configuration file"` CacheResyncPeriod time.Duration `long:"cache-resync-period" default:"10m" description:"Sets the underlying Shared Informer resync period: resyncing controller with informers cache"` HealthzBindPort int64 `long:"healthz-bind-port" default:"1042" description:"port to listen on for probes"` + QuicAnnouncePort int64 `long:"quic-announce-port" description:"sets the port in the alt-svc header"` + QuicBindPort int64 `long:"quic-bind-port" description:"sets the binding port for quic in HTTPS frontend"` LogLevel LogLevelValue `long:"log" default:"info" description:"level of log messages you can see"` DisableIPV4 bool `long:"disable-ipv4" description:"toggle to disable the IPv4 protocol from all frontends"` External bool `short:"e" long:"external" description:"use as external Ingress Controller (out of k8s cluster)"` @@ -107,10 +110,7 @@ type OSArgs struct { PrometheusEnabled bool `long:"prometheus" description:"enable prometheus of IC data"` DisableHTTP bool `long:"disable-http" description:"toggle to disable the HTTP frontend"` DisableIPV6 bool `long:"disable-ipv6" description:"toggle to disable the IPv6 protocol from all frontends"` - DisableConfigSnippets string `long:"disable-config-snippets" description:"Allow to disable config snippets. List of comma separated values (possible values: all/global/backend/frontend)"` UseWithPebble bool `long:"with-pebble" description:"use pebble to start/stop/reload HAProxy"` JobCheckCRD bool `long:"job-check-crd" description:"does not execute IC, but adds/updates CRDs"` DisableQuic bool `long:"disable-quic" description:"disable quic protocol in http frontend bindings"` - QuicAnnouncePort int64 `long:"quic-announce-port" description:"sets the port in the alt-svc header"` - QuicBindPort int64 `long:"quic-bind-port" description:"sets the binding port for quic in HTTPS frontend"` } diff --git a/pkg/utils/logging.go b/pkg/utils/logging.go index ef34c47f..fccfff45 100644 --- a/pkg/utils/logging.go +++ b/pkg/utils/logging.go @@ -92,9 +92,9 @@ type Logger interface { //nolint:interfacebloat } type logger struct { + fields map[string]interface{} Level LogLevel FileName bool - fields map[string]interface{} } var (