Skip to content

Commit

Permalink
Backport --emit-kubernetes-events to release/3.0.x (#5306)
Browse files Browse the repository at this point in the history
* Fix: Add --emit-translation-events to toggle creating of events in translation and config applying (#5296)

* add --emit-translation-events to toggle creating of events in translation and config applying

* update changelog

* Update internal/manager/run.go

Co-authored-by: Jintao Zhang <[email protected]>

* Capitalize logs

Co-authored-by: Jakub Warczarek <[email protected]>

---------

Co-authored-by: Jintao Zhang <[email protected]>
Co-authored-by: Jakub Warczarek <[email protected]>
(cherry picked from commit 8b3d551)

* fix: change events emit toggle name to --emit-kubernetes-events (#5299)

---------

Co-authored-by: Tao Yi <[email protected]>
Co-authored-by: Grzegorz Burzyński <[email protected]>
  • Loading branch information
3 people committed Dec 8, 2023
1 parent 6a4e173 commit fad6167
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
25 changes: 22 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,30 @@ Adding a new version? You'll need three changes:
- [0.0.5](#005)
- [0.0.4 and prior](#004-and-prior)

## Unreleased
## [3.0.2]

Nothing yet.
> Release date: TBD
### Added

- Added `--emit-kubernetes-events` CLI flag to disable the creation of events
in translating and applying configurations to Kong.
[#5296](https://github.com/Kong/kubernetes-ingress-controller/pull/5296)
[#5299](https://github.com/Kong/kubernetes-ingress-controller/pull/5299)

## [3.0.1]

> Release date: 2023-11-22
### Fixed

- Using an Ingress with annotation `konghq.com/rewrite` and another Ingress without it pointing to the same Service,
will no longer cause synchronization loop and random request failures due to incorrect routing.
[#5218](https://github.com/Kong/kubernetes-ingress-controller/pull/5218)
- Using the same Service in one Ingress as a target for ingress rule and default backend works without issues.
[#5219](https://github.com/Kong/kubernetes-ingress-controller/pull/5219)

## 3.0.0
## [3.0.0]

> Release date: 2023-11-03
Expand Down
1 change: 1 addition & 0 deletions docs/cli-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
| `--dump-sensitive-config` | `bool` | Include credentials and TLS secrets in configs exposed with --dump-config flag. | `false` |
| `--election-id` | `string` | Election id to use for status update. | `5b374a9e.konghq.com` |
| `--election-namespace` | `string` | Leader election namespace to use when running outside a cluster. | |
| `--emit-kubernetes-events` | `bool` | Emit Kubernetes events for successful configuration applies, translation failures and configuration apply failures on managed objects. | `true` |
| `--enable-controller-gwapi-gateway` | `bool` | Enable the Gateway API Gateway controller. | `true` |
| `--enable-controller-gwapi-httproute` | `bool` | Enable the Gateway API HTTPRoute controller. | `true` |
| `--enable-controller-gwapi-reference-grant` | `bool` | Enable the Gateway API ReferenceGrant controller. | `true` |
Expand Down
2 changes: 2 additions & 0 deletions internal/manager/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ type Config struct {
WatchNamespaces []string
GatewayAPIControllerName string
Impersonate string
EmitKubernetesEvents bool

// Ingress status
PublishServiceUDP OptionalNamespacedName
Expand Down Expand Up @@ -211,6 +212,7 @@ func (c *Config) FlagSet() *pflag.FlagSet {
flagSet.IntVar(&c.Concurrency, "kong-admin-concurrency", 10, "Max number of concurrent requests sent to Kong's Admin API.")
flagSet.StringSliceVar(&c.WatchNamespaces, "watch-namespace", nil,
`Namespace(s) in comma-separated format (or specify this flag multiple times) to watch for Kubernetes resources. Defaults to all namespaces.`)
flagSet.BoolVar(&c.EmitKubernetesEvents, "emit-kubernetes-events", true, `Emit Kubernetes events for successful configuration applies, translation failures and configuration apply failures on managed objects.`)

// Ingress status
flagSet.Var(flags.NewValidatedValue(&c.PublishService, namespacedNameFromFlagValue, nnTypeNameOverride), "publish-service",
Expand Down
11 changes: 10 additions & 1 deletion internal/manager/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/blang/semver/v4"
"github.com/go-logr/logr"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/client-go/tools/record"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/manager"
Expand Down Expand Up @@ -140,7 +141,15 @@ func Run(
}

setupLog.Info("Initializing Dataplane Client")
eventRecorder := mgr.GetEventRecorderFor(KongClientEventRecorderComponentName)
var eventRecorder record.EventRecorder
if c.EmitKubernetesEvents {
setupLog.Info("Emitting Kubernetes events enabled, creating an event recorder for " + KongClientEventRecorderComponentName)
eventRecorder = mgr.GetEventRecorderFor(KongClientEventRecorderComponentName)
} else {
setupLog.Info("Emitting Kubernetes events disabled, discarding all events")
// Create an empty record.FakeRecorder with no Events channel to discard all events.
eventRecorder = &record.FakeRecorder{}
}

readinessChecker := clients.NewDefaultReadinessChecker(adminAPIClientsFactory, setupLog.WithName("readiness-checker"))
clientsManager, err := clients.NewAdminAPIClientsManager(
Expand Down

0 comments on commit fad6167

Please sign in to comment.