Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the IC so that GlobalConfiguration is not mandatory when configured #1492

Merged
merged 1 commit into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 3 additions & 22 deletions cmd/nginx-ingress/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,7 @@ var (
"Enable custom NGINX configuration snippets in VirtualServer, VirtualServerRoute and TransportServer resources.")

globalConfiguration = flag.String("global-configuration", "",
`A GlobalConfiguration resource for global configuration of the Ingress Controller. Requires -enable-custom-resources. If the flag is set,
but the Ingress controller is not able to fetch the corresponding resource from Kubernetes API, the Ingress Controller
will fail to start. Format: <namespace>/<name>`)
`The namespace/name of the GlobalConfiguration resource for global configuration of the Ingress Controller. Requires -enable-custom-resources. Format: <namespace>/<name>`)

enableTLSPassthrough = flag.Bool("enable-tls-passthrough", false,
"Enable TLS Passthrough on port 443. Requires -enable-custom-resources")
Expand Down Expand Up @@ -458,32 +456,15 @@ func main() {

globalConfigurationValidator := createGlobalConfigurationValidator()

globalCfgParams := configs.NewDefaultGlobalConfigParams()
if *enableTLSPassthrough {
globalCfgParams = configs.NewGlobalConfigParamsWithTLSPassthrough()
}

if *globalConfiguration != "" {
ns, name, err := k8s.ParseNamespaceName(*globalConfiguration)
_, _, err := k8s.ParseNamespaceName(*globalConfiguration)
if err != nil {
glog.Fatalf("Error parsing the global-configuration argument: %v", err)
}

if !*enableCustomResources {
glog.Fatal("global-configuration flag requires -enable-custom-resources")
}

gc, err := confClient.K8sV1alpha1().GlobalConfigurations(ns).Get(context.TODO(), name, meta_v1.GetOptions{})
if err != nil {
glog.Fatalf("Error when getting %s: %v", *globalConfiguration, err)
}

err = globalConfigurationValidator.ValidateGlobalConfiguration(gc)
if err != nil {
glog.Fatalf("GlobalConfiguration %s is invalid: %v", *globalConfiguration, err)
}

globalCfgParams = configs.ParseGlobalConfiguration(gc, *enableTLSPassthrough)
}

cfgParams := configs.NewDefaultConfigParams()
Expand Down Expand Up @@ -609,7 +590,7 @@ func main() {
}

isWildcardEnabled := *wildcardTLSSecret != ""
cnf := configs.NewConfigurator(nginxManager, staticCfgParams, cfgParams, globalCfgParams, templateExecutor,
cnf := configs.NewConfigurator(nginxManager, staticCfgParams, cfgParams, templateExecutor,
templateExecutorV2, *nginxPlus, isWildcardEnabled, plusCollector, *enablePrometheusMetrics, latencyCollector, *enableLatencyMetrics)
controllerNamespace := os.Getenv("POD_NAMESPACE")

Expand Down
5 changes: 0 additions & 5 deletions deployments/common/global-configuration.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Below we describe the available command-line arguments:

.. option:: -global-configuration <string>

A GlobalConfiguration resource for global configuration of the Ingress Controller. If the flag is set, but the Ingress Controller is not able to fetch the corresponding resource from Kubernetes API, the Ingress Controller will fail to start.
A GlobalConfiguration resource for global configuration of the Ingress Controller.

Format: ``<namespace>/<name>``

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ protocol: TCP

## Using GlobalConfiguration

As mentioned in the [Prerequisites](#prerequisites) section, the GlobalConfiguration must be deployed during the installation of the Ingress Controller.

You can use the usual `kubectl` commands to work with a GlobalConfiguration resource.

For example, the following command creates a GlobalConfiguration resource defined in `global-configuration.yaml` with the name `nginx-configuration`:
Expand Down
5 changes: 0 additions & 5 deletions docs-web/installation/installation-with-manifests.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ If you would like to use the TCP and UDP load balancing features of the Ingress
```
$ kubectl apply -f common/crds/k8s.nginx.org_globalconfigurations.yaml
```
1. Create a GlobalConfiguration resource:
```
$ kubectl apply -f common/global-configuration.yaml
```
**Note**: Make sure to reference this resource in the [`-global-configuration`](/nginx-ingress-controller/configuration/global-configuration/command-line-arguments#cmdoption-global-configuration) command-line argument.

> **Feature Status**: The TransportServer, GlobalConfiguration and Policy resources are available as a preview feature: it is suitable for experimenting and testing; however, it must be used with caution in production environments. Additionally, while the feature is in preview, we might introduce some backward-incompatible changes to the resources specification in the next releases.

Expand Down
4 changes: 1 addition & 3 deletions internal/configs/configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ type Configurator struct {
nginxManager nginx.Manager
staticCfgParams *StaticConfigParams
cfgParams *ConfigParams
globalCfgParams *GlobalConfigParams
soneillf5 marked this conversation as resolved.
Show resolved Hide resolved
templateExecutor *version1.TemplateExecutor
templateExecutorV2 *version2.TemplateExecutor
ingresses map[string]*IngressEx
Expand All @@ -113,7 +112,7 @@ type Configurator struct {
}

// NewConfigurator creates a new Configurator.
func NewConfigurator(nginxManager nginx.Manager, staticCfgParams *StaticConfigParams, config *ConfigParams, globalCfgParams *GlobalConfigParams,
func NewConfigurator(nginxManager nginx.Manager, staticCfgParams *StaticConfigParams, config *ConfigParams,
templateExecutor *version1.TemplateExecutor, templateExecutorV2 *version2.TemplateExecutor, isPlus bool, isWildcardEnabled bool,
labelUpdater collector.LabelUpdater, isPrometheusEnabled bool, latencyCollector latCollector.LatencyCollector, isLatencyMetricsEnabled bool) *Configurator {
metricLabelsIndex := &metricLabelsIndex{
Expand All @@ -132,7 +131,6 @@ func NewConfigurator(nginxManager nginx.Manager, staticCfgParams *StaticConfigPa
nginxManager: nginxManager,
staticCfgParams: staticCfgParams,
cfgParams: config,
globalCfgParams: globalCfgParams,
ingresses: make(map[string]*IngressEx),
virtualServers: make(map[string]*VirtualServerEx),
templateExecutor: templateExecutor,
Expand Down
4 changes: 2 additions & 2 deletions internal/configs/configurator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func createTestConfigurator() (*Configurator, error) {

manager := nginx.NewFakeManager("/etc/nginx")

return NewConfigurator(manager, createTestStaticConfigParams(), NewDefaultConfigParams(), NewDefaultGlobalConfigParams(), templateExecutor, templateExecutorV2, false, false, nil, false, nil, false), nil
return NewConfigurator(manager, createTestStaticConfigParams(), NewDefaultConfigParams(), templateExecutor, templateExecutorV2, false, false, nil, false, nil, false), nil
}

func createTestConfiguratorInvalidIngressTemplate() (*Configurator, error) {
Expand All @@ -56,7 +56,7 @@ func createTestConfiguratorInvalidIngressTemplate() (*Configurator, error) {

manager := nginx.NewFakeManager("/etc/nginx")

return NewConfigurator(manager, createTestStaticConfigParams(), NewDefaultConfigParams(), NewDefaultGlobalConfigParams(), templateExecutor, &version2.TemplateExecutor{}, false, false, nil, false, nil, false), nil
return NewConfigurator(manager, createTestStaticConfigParams(), NewDefaultConfigParams(), templateExecutor, &version2.TemplateExecutor{}, false, false, nil, false, nil, false), nil
}

func TestAddOrUpdateIngress(t *testing.T) {
Expand Down
19 changes: 0 additions & 19 deletions internal/configs/globalconfiguration.go

This file was deleted.

91 changes: 0 additions & 91 deletions internal/configs/globalconfiguration_test.go

This file was deleted.

2 changes: 0 additions & 2 deletions internal/k8s/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,7 @@ func NewLoadBalancerController(input NewLoadBalancerControllerInput) *LoadBalanc

if input.GlobalConfiguration != "" {
lbc.watchGlobalConfiguration = true

ns, name, _ := ParseNamespaceName(input.GlobalConfiguration)

lbc.addGlobalConfigurationHandler(createGlobalConfigurationHandlers(lbc), ns, name)
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/k8s/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ func TestFindProbeForPods(t *testing.T) {

func TestGetServicePortForIngressPort(t *testing.T) {
fakeClient := fake.NewSimpleClientset()
cnf := configs.NewConfigurator(&nginx.LocalManager{}, &configs.StaticConfigParams{}, &configs.ConfigParams{}, &configs.GlobalConfigParams{}, &version1.TemplateExecutor{}, &version2.TemplateExecutor{}, false, false, nil, false, nil, false)
cnf := configs.NewConfigurator(&nginx.LocalManager{}, &configs.StaticConfigParams{}, &configs.ConfigParams{}, &version1.TemplateExecutor{}, &version2.TemplateExecutor{}, false, false, nil, false, nil, false)
lbc := LoadBalancerController{
client: fakeClient,
ingressClass: "nginx",
Expand Down