Skip to content

Commit

Permalink
Feature/flag include year (#2884)
Browse files Browse the repository at this point in the history
* replace glog with forked version to include years

* replace glog with forked version to include years

* Add flag to include year in log header

* Add cmd flag to include year in log header

* Fix linter

* Remove white space

* Add `-include-year` flag to OSS ingress deployment and daemon-set configurations

* Add section for `controller.includeYear` to helm installation docs

* Update nginxinc/glog to v1.1.2

Co-authored-by: Haywood Shannon <[email protected]>
Co-authored-by: “shaun-nx” <“[email protected]”>
  • Loading branch information
3 people authored Jul 27, 2022
1 parent 99fba9e commit 06ec33b
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 3 deletions.
9 changes: 9 additions & 0 deletions cmd/nginx-ingress/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net"
"os"
"regexp"
"strconv"
"strings"

"github.com/golang/glog"
Expand Down Expand Up @@ -174,6 +175,9 @@ var (
enableExternalDNS = flag.Bool("enable-external-dns", false,
"Enable external-dns controller for VirtualServer resources. Requires -enable-custom-resources")

includeYearInLogs = flag.Bool("include-year", false,
"Option to include the year in the log header")

startupCheckFn func() error
)

Expand Down Expand Up @@ -261,6 +265,11 @@ func initialChecks() {
glog.Fatalf("Error setting logtostderr to true: %v", err)
}

err = flag.Lookup("include_year").Value.Set(strconv.FormatBool(*includeYearInLogs))
if err != nil {
glog.Fatalf("Error setting include_year flag: %v", err)
}

if startupCheckFn != nil {
err := startupCheckFn()
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions deployments/daemon-set/nginx-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ spec:
args:
- -nginx-configmaps=$(POD_NAMESPACE)/nginx-config
- -default-server-tls-secret=$(POD_NAMESPACE)/default-server-secret
#- -include-year
#- -v=3 # Enables extensive logging. Useful for troubleshooting.
#- -report-ingress-status
#- -external-service=nginx-ingress
Expand Down
1 change: 1 addition & 0 deletions deployments/daemon-set/nginx-plus-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ spec:
- -nginx-plus
- -nginx-configmaps=$(POD_NAMESPACE)/nginx-config
- -default-server-tls-secret=$(POD_NAMESPACE)/default-server-secret
#- -include-year
#- -enable-app-protect
#- -enable-app-protect-dos
#- -v=3 # Enables extensive logging. Useful for troubleshooting.
Expand Down
1 change: 1 addition & 0 deletions deployments/deployment/nginx-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ spec:
args:
- -nginx-configmaps=$(POD_NAMESPACE)/nginx-config
- -default-server-tls-secret=$(POD_NAMESPACE)/default-server-secret
#- -include-year
#- -enable-cert-manager
#- -enable-external-dns
#- -v=3 # Enables extensive logging. Useful for troubleshooting.
Expand Down
1 change: 1 addition & 0 deletions deployments/deployment/nginx-plus-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ spec:
- -nginx-plus
- -nginx-configmaps=$(POD_NAMESPACE)/nginx-config
- -default-server-tls-secret=$(POD_NAMESPACE)/default-server-secret
#- -include-year
#- -enable-cert-manager
#- -enable-external-dns
#- -enable-app-protect
Expand Down
1 change: 1 addition & 0 deletions deployments/helm-chart/templates/controller-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ spec:
- -prometheus-tls-secret={{ .Values.prometheus.secret }}
- -enable-custom-resources={{ .Values.controller.enableCustomResources }}
- -enable-snippets={{ .Values.controller.enableSnippets }}
- -include-year={{ .Values.controller.includeYear }}
{{- if .Values.controller.enableCustomResources }}
- -enable-tls-passthrough={{ .Values.controller.enableTLSPassthrough }}
- -enable-preview-policies={{ .Values.controller.enablePreviewPolicies }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ spec:
- -prometheus-tls-secret={{ .Values.prometheus.secret }}
- -enable-custom-resources={{ .Values.controller.enableCustomResources }}
- -enable-snippets={{ .Values.controller.enableSnippets }}
- -include-year={{ .Values.controller.includeYear }}
{{- if .Values.controller.enableCustomResources }}
- -enable-tls-passthrough={{ .Values.controller.enableTLSPassthrough }}
- -enable-preview-policies={{ .Values.controller.enablePreviewPolicies }}
Expand Down
3 changes: 3 additions & 0 deletions deployments/helm-chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ controller:
## Enable OIDC policies.
enableOIDC: false

## Include year in log header. This parameter will be removed in release 2.7 and the year will be included by default.
includeYear: false

## Enable TLS Passthrough on port 443. Requires controller.enableCustomResources.
enableTLSPassthrough: false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ Default `false`.
&nbsp;
<a name="cmdoption-enable-leader-election"></a>

### -inlcude-year
Adds year to log headers.

Default `false`.

**NOTE**: This flag will be removed in release 2.7 and the year will be included by default.

### -enable-leader-election

Enables Leader election to avoid multiple replicas of the controller reporting the status of Ingress, VirtualServer and VirtualServerRoute resources -- only one replica will report status.
Expand Down
1 change: 1 addition & 0 deletions docs/content/installation/installation-with-helm.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ The following tables lists the configurable parameters of the NGINX Ingress Cont
|``controller.enableCustomResources`` | Enable the custom resources. | true |
|``controller.enablePreviewPolicies`` | Enable preview policies. This parameter is deprecated. To enable OIDC Policies please use ``controller.enableOIDC`` instead. | false |
|``controller.enableOIDC`` | Enable OIDC policies. | false |
|``controller.includeYear`` | Include year in log header. This parameter will be removed in release 2.7 and the year will be included by default. | false |
|``controller.enableTLSPassthrough`` | Enable TLS Passthrough on port 443. Requires ``controller.enableCustomResources``. | false |
`controller.enableCertManager` | Enable x509 automated certificate management for VirtualServer resources using cert-manager (cert-manager.io). Requires `controller.enableCustomResources`. | false
`controller.enableExternalDNS` | Enable integration with ExternalDNS for configuring public DNS entries for VirtualServer resources using [ExternalDNS](https://github.com/kubernetes-sigs/external-dns). Requires `controller.enableCustomResources`. | false
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,6 @@ require (
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace github.com/golang/glog v1.0.0 => github.com/nginxinc/glog v1.1.1
replace github.com/golang/glog v1.0.0 => github.com/nginxinc/glog v1.1.2
// temprary fix for CVE-2022-29526 in github.com/prometheus/client_golang v1.12.2
replace golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 => golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,8 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8m
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
github.com/nginxinc/glog v1.1.1 h1:+NI8YAEa0pkR4lyfK0Fp+rCwpD7VIQAinq3NwK3TQzs=
github.com/nginxinc/glog v1.1.1/go.mod h1:Q2FpGp/qFhJEVnuC88BVfbLDPmio9aHYUj4al6w0138=
github.com/nginxinc/glog v1.1.2 h1:zyoZXhCoYvNMJq4qMsKislUCGyJ4eU2gNl3Nt7cjESg=
github.com/nginxinc/glog v1.1.2/go.mod h1:Q2FpGp/qFhJEVnuC88BVfbLDPmio9aHYUj4al6w0138=
github.com/nginxinc/nginx-plus-go-client v0.10.0 h1:3zsMMkPvRDo8D7ZSprXtbAEW/SDmezZWzxdyS+6oAlc=
github.com/nginxinc/nginx-plus-go-client v0.10.0/go.mod h1:0v3RsQCvRn/IyrMtW+DK6CNkz+PxEsXDJPjQ3yUMBF0=
github.com/nginxinc/nginx-prometheus-exporter v0.10.0 h1:wFP8mYMtmn8uK1I5tzXb3s4CQq+r3h6Y0Qdc7d+QpyM=
Expand Down

0 comments on commit 06ec33b

Please sign in to comment.