Skip to content

Commit a5aefd8

Browse files
authored
revert: deprecate and replace flag family --publish-service, etc. with --ingress-service (#4765 & #4820) (#4921)
Adjust existing code and reverted (partially - leave adjustments in tests) commits: - ad292cd - 15a036f
1 parent 41ab6ed commit a5aefd8

23 files changed

+111
-189
lines changed

CHANGELOG.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,6 @@ Adding a new version? You'll need three changes:
165165
[#4737](https://github.com/Kong/kubernetes-ingress-controller/pull/4737)
166166
- Telemetry now reports the router flavor.
167167
[#4762](https://github.com/Kong/kubernetes-ingress-controller/pull/4762)
168-
- The following flags were renamed and marked as deprecated
169-
- `--publish-service` to `--ingress-service`
170-
- `--publish-status-address` to `--ingress-address`
171-
- `--publish-service-udp` to `--ingress-service-udp`
172-
- `--publish-status-address-udp` to `--ingress-address-udp`
173-
[#4765](https://github.com/Kong/kubernetes-ingress-controller/pull/4765)
174168
- Support Query Parameter matching of `HTTPRoute` when expression router enabled.
175169
[#4780](https://github.com/Kong/kubernetes-ingress-controller/pull/4780)
176170

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export POD_NAMESPACE=kong
157157

158158
go run -tags gcp ./internal/cmd/main.go \
159159
--kubeconfig ~/.kube/config \
160-
--ingress-service=kong/kong-proxy \
160+
--publish-service=kong/kong-proxy \
161161
--apiserver-host=http://localhost:8002 \
162162
--kong-admin-url https://localhost:8444 \
163163
--kong-admin-tls-skip-verify true

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,8 @@ debug: install _ensure-namespace
545545
$(DLV) debug ./internal/cmd/main.go -- \
546546
--anonymous-reports=false \
547547
--kong-admin-url $(KONG_ADMIN_URL) \
548-
--ingress-service $(KONG_NAMESPACE)/$(KONG_PROXY_SERVICE) \
549-
--ingress-service-udp $(KONG_NAMESPACE)/$(KONG_PROXY_UDP_SERVICE) \
548+
--publish-service $(KONG_NAMESPACE)/$(KONG_PROXY_SERVICE) \
549+
--publish-service-udp $(KONG_NAMESPACE)/$(KONG_PROXY_UDP_SERVICE) \
550550
--kubeconfig $(KUBECONFIG) \
551551
--feature-gates=$(KONG_CONTROLLER_FEATURE_GATES)
552552

@@ -618,8 +618,8 @@ _run:
618618
go run ./internal/cmd/main.go \
619619
--anonymous-reports=false \
620620
--kong-admin-url $(KONG_ADMIN_URL) \
621-
--ingress-service $(KONG_NAMESPACE)/$(KONG_PROXY_SERVICE) \
622-
--ingress-service-udp $(KONG_NAMESPACE)/$(KONG_PROXY_UDP_SERVICE) \
621+
--publish-service $(KONG_NAMESPACE)/$(KONG_PROXY_SERVICE) \
622+
--publish-service-udp $(KONG_NAMESPACE)/$(KONG_PROXY_UDP_SERVICE) \
623623
--kubeconfig $(KUBECONFIG) \
624624
--feature-gates=$(KONG_CONTROLLER_FEATURE_GATES)
625625

docs/cli-arguments.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@
3333
| `--gateway-api-controller-name` | `string` | The controller name to match on Gateway API resources. | `konghq.com/kic-gateway-controller` |
3434
| `--gateway-discovery-dns-strategy` | `dns-strategy` | DNS strategy to use when creating Gateway's Admin API addresses. One of: ip, service, pod. | `"ip"` |
3535
| `--health-probe-bind-address` | `string` | The address the probe endpoint binds to. | `:10254` |
36-
| `--ingress-address` | `stringSlice` | User-provided address(es) in comma-separated string format (or specify this flag multiple times), for use in lieu of "publish-service" when that Service lacks useful address information (for example, in bare-metal environments). | `[]` |
37-
| `--ingress-address-udp` | `stringSlice` | User-provided address(es) in comma-separated string format (or specify this flag multiple times), for use in lieu of "publish-service-udp" when that Service lacks useful address information. | `[]` |
3836
| `--ingress-class` | `string` | Name of the ingress class to route through this controller. | `kong` |
39-
| `--ingress-service` | `namespacedName` | Service fronting Ingress resources in "namespace/name" format. The controller will update Ingress status information with this Service's endpoints. | |
40-
| `--ingress-service-udp` | `namespacedName` | Service fronting UDP routing resources in "namespace/name" format. The controller will update UDP route status information with this Service's endpoints. If omitted, the same Service will be used for both TCP and UDP routes. | |
4137
| `--kong-admin-ca-cert` | `string` | PEM-encoded CA certificate to verify Kong's Admin SSL certificate. | |
4238
| `--kong-admin-ca-cert-file` | `string` | Path to PEM-encoded CA certificate file to verify Kong's Admin SSL certificate. | |
4339
| `--kong-admin-concurrency` | `int` | Max number of concurrent requests sent to Kong's Admin API. | `10` |
@@ -75,6 +71,10 @@
7571
| `--profiling` | `bool` | Enable profiling via web interface host:10256/debug/pprof/. | `false` |
7672
| `--proxy-sync-seconds` | `float32` | Define the rate (in seconds) in which configuration updates will be applied to the Kong Admin API. | `3` |
7773
| `--proxy-timeout-seconds` | `float32` | Sets the timeout (in seconds) for all requests to Kong's Admin API. | `30` |
74+
| `--publish-service` | `namespacedName` | Service fronting Ingress resources in "namespace/name" format. The controller will update Ingress status information with this Service's endpoints. | |
75+
| `--publish-service-udp` | `namespacedName` | Service fronting UDP routing resources in "namespace/name" format. The controller will update UDP route status information with this Service's endpoints. If omitted, the same Service will be used for both TCP and UDP routes. | |
76+
| `--publish-status-address` | `stringSlice` | User-provided addresses in comma-separated string format, for use in lieu of "publish-service" when that Service lacks useful address information (for example, in bare-metal environments). | `[]` |
77+
| `--publish-status-address-udp` | `stringSlice` | User-provided address CSV, for use in lieu of "publish-service-udp" when that Service lacks useful address information. | `[]` |
7878
| `--skip-ca-certificates` | `bool` | Disable syncing CA certificate syncing (for use with multi-workspace environments). | `false` |
7979
| `--sync-period` | `duration` | Relist and confirm cloud resources this often. | `48h0m0s` |
8080
| `--term-delay` | `duration` | The time delay to sleep before SIGTERM or SIGINT will shut down the Ingress Controller. | `0s` |

internal/cmd/rootcmd/rootcmd_test.go

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,24 @@ func TestRootCmd(t *testing.T) {
1616
require.NoError(t, rootCmd.PersistentPreRunE(rootCmd, os.Args[:0]))
1717
})
1818

19-
t.Run("binding environment variables succeeds when flag validation passes", func(t *testing.T) {
20-
t.Setenv("CONTROLLER_INGRESS_SERVICE", "namespace/servicename")
19+
t.Run("root command succeeds when correct flags where provided", func(t *testing.T) {
2120
var cfg manager.Config
2221
rootCmd := GetRootCmd(&cfg)
23-
require.NoError(t, rootCmd.PersistentPreRunE(rootCmd, os.Args[:0]))
22+
require.NoError(t, rootCmd.PersistentPreRunE(rootCmd,
23+
append(os.Args[:0],
24+
"--publish-service", "namespace/servicename",
25+
),
26+
))
2427
})
2528

26-
t.Run("binding environment variables fails when flag validation fails", func(t *testing.T) {
27-
t.Setenv("CONTROLLER_INGRESS_SERVICE", "servicename")
28-
var cfg manager.Config
29-
rootCmd := GetRootCmd(&cfg)
30-
require.Error(t, rootCmd.PersistentPreRunE(rootCmd, os.Args[:0]),
31-
"binding env vars should fail because a non namespaced name of ingress service was provided",
32-
)
33-
})
34-
35-
t.Run("binding deprecated environment variables succeeds when flag validation passes", func(t *testing.T) {
29+
t.Run("binding environment variables succeeds when flag validation passes", func(t *testing.T) {
3630
t.Setenv("CONTROLLER_PUBLISH_SERVICE", "namespace/servicename")
3731
var cfg manager.Config
3832
rootCmd := GetRootCmd(&cfg)
3933
require.NoError(t, rootCmd.PersistentPreRunE(rootCmd, os.Args[:0]))
4034
})
4135

42-
t.Run("binding deprecated environment variables fails when flag validation fails", func(t *testing.T) {
36+
t.Run("binding environment variables fails when flag validation fails", func(t *testing.T) {
4337
t.Setenv("CONTROLLER_PUBLISH_SERVICE", "servicename")
4438
var cfg manager.Config
4539
rootCmd := GetRootCmd(&cfg)

internal/controllers/gateway/gateway_controller.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ type GatewayReconciler struct { //nolint:revive
5656

5757
ReferenceIndexers ctrlref.CacheIndexers
5858

59-
IngressServiceRef k8stypes.NamespacedName
60-
IngressServiceUDPRef mo.Option[k8stypes.NamespacedName]
59+
PublishServiceRef k8stypes.NamespacedName
60+
PublishServiceUDPRef mo.Option[k8stypes.NamespacedName]
6161

6262
// If enableReferenceGrant is true, controller will watch ReferenceGrants
6363
// to invalidate or allow cross-namespace TLSConfigs in gateways.
@@ -67,9 +67,9 @@ type GatewayReconciler struct { //nolint:revive
6767

6868
// SetupWithManager sets up the controller with the Manager.
6969
func (r *GatewayReconciler) SetupWithManager(mgr ctrl.Manager) error {
70-
// Verify that the Ingress Service was configured properly.
71-
if r.IngressServiceRef.Name == "" || r.IngressServiceRef.Namespace == "" {
72-
return fmt.Errorf("ingress service must be configured")
70+
// verify that the PublishService was configured properly
71+
if r.PublishServiceRef.Name == "" || r.PublishServiceRef.Namespace == "" {
72+
return fmt.Errorf("publish service must be configured")
7373
}
7474

7575
// We're verifying whether ReferenceGrant CRD is installed at setup of the GatewayReconciler
@@ -298,13 +298,13 @@ func (r *GatewayReconciler) listGatewaysForHTTPRoute(_ context.Context, obj clie
298298
}
299299

300300
// isGatewayService is a watch predicate that filters out events for objects that aren't
301-
// the gateway service referenced by --ingress-service or --ingress-service-udp.
301+
// the gateway service referenced by --publish-service or --publish-service-udp.
302302
func (r *GatewayReconciler) isGatewayService(obj client.Object) bool {
303-
isIngressService := fmt.Sprintf("%s/%s", obj.GetNamespace(), obj.GetName()) == r.IngressServiceRef.String()
304-
isIngressServiceUDP := r.IngressServiceUDPRef.IsPresent() &&
305-
fmt.Sprintf("%s/%s", obj.GetNamespace(), obj.GetName()) == r.IngressServiceUDPRef.MustGet().String()
303+
isPublishService := fmt.Sprintf("%s/%s", obj.GetNamespace(), obj.GetName()) == r.PublishServiceRef.String()
304+
isUDPPublishService := r.PublishServiceUDPRef.IsPresent() &&
305+
fmt.Sprintf("%s/%s", obj.GetNamespace(), obj.GetName()) == r.PublishServiceUDPRef.MustGet().String()
306306

307-
return isIngressService || isIngressServiceUDP
307+
return isPublishService || isUDPPublishService
308308
}
309309

310310
func referenceGrantHasGatewayFrom(obj client.Object) bool {
@@ -441,10 +441,10 @@ func (r *GatewayReconciler) reconcileUnmanagedGateway(ctx context.Context, log l
441441
// enforce the service reference as the annotation value for the key UnmanagedGateway.
442442
debug(log, gateway, "initializing admin service annotation if unset")
443443
if len(annotations.ExtractGatewayPublishService(gateway.Annotations)) == 0 {
444-
services := []string{r.IngressServiceRef.String()}
444+
services := []string{r.PublishServiceRef.String()}
445445

446446
// UDP service is optional.
447-
if udpRef, ok := r.IngressServiceUDPRef.Get(); ok {
447+
if udpRef, ok := r.PublishServiceUDPRef.Get(); ok {
448448
services = append(services, udpRef.String())
449449
}
450450

@@ -459,7 +459,7 @@ func (r *GatewayReconciler) reconcileUnmanagedGateway(ctx context.Context, log l
459459
serviceRefs := annotations.ExtractGatewayPublishService(gateway.Annotations)
460460
// Validation check of the Gateway to ensure that the ingress service is actually available
461461
// in the cluster. If it is not the object will be requeued until it exists (or is otherwise retrievable).
462-
debug(log, gateway, "gathering the gateway ingress service") // This will also be done by the validating webhook, this is a fallback.
462+
debug(log, gateway, "gathering the gateway publish service") // this will also be done by the validating webhook, this is a fallback
463463
var gatewayServices []*corev1.Service
464464
for _, ref := range serviceRefs {
465465
r.Log.V(util.DebugLevel).Info("determining service for ref", "ref", ref)
@@ -503,7 +503,7 @@ func (r *GatewayReconciler) reconcileUnmanagedGateway(ctx context.Context, log l
503503
// from the Kubernetes Service which will also give us all the L4 information about the proxy. From there
504504
// we can use that L4 information to derive the higher level TLS and HTTP,GRPC, e.t.c. information from
505505
// the data-plane's metadata.
506-
debug(log, gateway, "determining listener configurations from ingress services")
506+
debug(log, gateway, "determining listener configurations from publish services")
507507
var combinedAddresses []gatewayapi.GatewayAddress
508508
var combinedListeners []gatewayapi.Listener
509509
for _, svc := range gatewayServices {
@@ -596,22 +596,22 @@ func init() {
596596
}
597597
}
598598

599-
// determineServiceForGateway provides the "ingress service" (aka the proxy Service) object which
599+
// determineServiceForGateway provides the "publish service" (aka the proxy Service) object which
600600
// will be used to populate unmanaged gateways.
601601
func (r *GatewayReconciler) determineServiceForGateway(ctx context.Context, ref string) (*corev1.Service, error) {
602-
// Currently the gateway controller ONLY supports service references that correspond with the --ingress-service
602+
// currently the gateway controller ONLY supports service references that correspond with the --publish-service
603603
// provided to the controller manager via flags when operating on unmanaged gateways. This constraint may
604604
// be loosened in later iterations if there is need.
605605

606606
var name k8stypes.NamespacedName
607607
switch {
608-
case ref == r.IngressServiceRef.String():
609-
name = r.IngressServiceRef
610-
case r.IngressServiceUDPRef.IsPresent() && ref == r.IngressServiceUDPRef.MustGet().String():
611-
name = r.IngressServiceUDPRef.MustGet()
608+
case ref == r.PublishServiceRef.String():
609+
name = r.PublishServiceRef
610+
case r.PublishServiceUDPRef.IsPresent() && ref == r.PublishServiceUDPRef.MustGet().String():
611+
name = r.PublishServiceUDPRef.MustGet()
612612
default:
613613
return nil, fmt.Errorf("service ref %s did not match controller manager ref %s or %s",
614-
ref, r.IngressServiceRef.String(), r.IngressServiceUDPRef.OrEmpty())
614+
ref, r.PublishServiceRef.String(), r.PublishServiceUDPRef.OrEmpty())
615615
}
616616

617617
// retrieve the service for the kong gateway

internal/manager/config.go

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ type Config struct {
8585
GatewayAPIControllerName string
8686
Impersonate string
8787

88-
// Ingress status.
89-
IngressServiceUDP OptionalNamespacedName
90-
IngressService OptionalNamespacedName
91-
IngressAddresses []string
92-
IngressAddressesUDP []string
88+
// Ingress status
89+
PublishServiceUDP OptionalNamespacedName
90+
PublishService OptionalNamespacedName
91+
PublishStatusAddress []string
92+
PublishStatusAddressUDP []string
9393

9494
UpdateStatus bool
9595
UpdateStatusQueueBufferSize int
@@ -202,16 +202,16 @@ func (c *Config) FlagSet() *pflag.FlagSet {
202202
`Namespace(s) to watch for Kubernetes resources. Defaults to all namespaces. To watch multiple namespaces, use a comma-separated list of namespaces.`)
203203

204204
// Ingress status
205-
flagSet.Var(flags.NewValidatedValue(&c.IngressService, namespacedNameFromFlagValue, nnTypeNameOverride), "ingress-service",
205+
flagSet.Var(flags.NewValidatedValue(&c.PublishService, namespacedNameFromFlagValue, nnTypeNameOverride), "publish-service",
206206
`Service fronting Ingress resources in "namespace/name" format. The controller will update Ingress status information with this Service's endpoints.`)
207-
flagSet.StringSliceVar(&c.IngressAddresses, "ingress-address", []string{},
208-
`User-provided address(es) in comma-separated string format (or specify this flag multiple times), for use in lieu of "publish-service" `+
207+
flagSet.StringSliceVar(&c.PublishStatusAddress, "publish-status-address", []string{},
208+
`User-provided addresses in comma-separated string format, for use in lieu of "publish-service" `+
209209
`when that Service lacks useful address information (for example, in bare-metal environments).`)
210-
flagSet.Var(flags.NewValidatedValue(&c.IngressServiceUDP, namespacedNameFromFlagValue, nnTypeNameOverride), "ingress-service-udp", `Service fronting UDP routing resources in `+
210+
flagSet.Var(flags.NewValidatedValue(&c.PublishServiceUDP, namespacedNameFromFlagValue, nnTypeNameOverride), "publish-service-udp", `Service fronting UDP routing resources in `+
211211
`"namespace/name" format. The controller will update UDP route status information with this Service's `+
212212
`endpoints. If omitted, the same Service will be used for both TCP and UDP routes.`)
213-
flagSet.StringSliceVar(&c.IngressAddressesUDP, "ingress-address-udp", []string{},
214-
`User-provided address(es) in comma-separated string format (or specify this flag multiple times), for use in lieu of "publish-service-udp" when that Service lacks useful address information.`)
213+
flagSet.StringSliceVar(&c.PublishStatusAddressUDP, "publish-status-address-udp", []string{},
214+
`User-provided address CSV, for use in lieu of "publish-service-udp" when that Service lacks useful address information.`)
215215

216216
flagSet.BoolVar(&c.UpdateStatus, "update-status", true,
217217
`Indicates if the ingress controller should update the status of resources (e.g. IP/Hostname for v1.Ingress, e.t.c.)`)
@@ -269,18 +269,30 @@ func (c *Config) FlagSet() *pflag.FlagSet {
269269
flagSet.DurationVar(&c.Konnect.RefreshNodePeriod, "konnect-refresh-node-period", konnect.DefaultRefreshNodePeriod, "Period of uploading status of KIC and controlled kong gateway instances")
270270

271271
// Deprecated flags
272-
flagSet.Var(flags.NewValidatedValue(&c.IngressService, namespacedNameFromFlagValue, nnTypeNameOverride), "publish-service", "Use --ingress-service instead")
273-
_ = flagSet.MarkDeprecated("publish-service", "Use --ingress-service instead")
274-
flagSet.Var(flags.NewValidatedValue(&c.IngressServiceUDP, namespacedNameFromFlagValue, nnTypeNameOverride), "publish-service-udp", "Use --ingress-service-udp instead")
275-
_ = flagSet.MarkDeprecated("publish-service-udp", "Use --ingress-service-udp instead")
276-
flagSet.StringSliceVar(&c.IngressAddresses, "publish-status-address", []string{}, "")
277-
_ = flagSet.MarkDeprecated("publish-status-address", "Use --ingress-address instead")
278-
flagSet.StringSliceVar(&c.IngressAddressesUDP, "publish-status-address-udp", []string{}, "")
279-
_ = flagSet.MarkDeprecated("publish-status-address-udp", "Use --ingress-address-udp instead")
280-
281272
flagSet.StringVar(&c.Konnect.ControlPlaneID, "konnect-runtime-group-id", "", "Use --konnect-control-plane-id instead.")
282273
_ = flagSet.MarkDeprecated("konnect-runtime-group-id", "Use --konnect-control-plane-id instead.")
283274

275+
_ = flagSet.Float32("sync-rate-limit", dataplane.DefaultSyncSeconds, "Use --proxy-sync-seconds instead")
276+
_ = flagSet.MarkDeprecated("sync-rate-limit", "Use --proxy-sync-seconds instead")
277+
278+
_ = flagSet.Int("stderrthreshold", 0, "Has no effect and will be removed in future releases (see github issue #1297)")
279+
_ = flagSet.MarkDeprecated("stderrthreshold", "Has no effect and will be removed in future releases (see github issue #1297)")
280+
281+
_ = flagSet.Bool("update-status-on-shutdown", false, "No longer has any effect and will be removed in a later release (see github issue #1304)")
282+
_ = flagSet.MarkDeprecated("update-status-on-shutdown", "No longer has any effect and will be removed in a later release (see github issue #1304)")
283+
284+
_ = flagSet.String("kong-custom-entities-secret", "", "Will be removed in next major release.")
285+
_ = flagSet.MarkDeprecated("kong-custom-entities-secret", "Will be removed in next major release.")
286+
287+
_ = flagSet.Bool("leader-elect", false, "DEPRECATED as of 2.1.0: leader election behavior is determined automatically based on the Kong database setting and this flag has no effect")
288+
_ = flagSet.MarkDeprecated("leader-elect", "DEPRECATED as of 2.1.0: leader election behavior is determined automatically based on the Kong database setting and this flag has no effect")
289+
290+
_ = flagSet.Bool("enable-controller-ingress-extensionsv1beta1", true, "DEPRECATED: Enable the extensions/v1beta1 Ingress controller.")
291+
_ = flagSet.MarkDeprecated("enable-controller-ingress-extensionsv1beta1", "DEPRECATED: Enable the extensions/v1beta1 Ingress controller.")
292+
293+
_ = flagSet.Bool("enable-controller-ingress-networkingv1beta1", true, "Enable the networking.k8s.io/v1beta1 Ingress controller.")
294+
_ = flagSet.MarkDeprecated("enable-controller-ingress-networkingv1beta1", "Enable the networking.k8s.io/v1beta1 Ingress controller.")
295+
284296
c.flagSet = flagSet
285297
return flagSet
286298
}

0 commit comments

Comments
 (0)