Merge pull request #2895 from tomxor/main-ctx-snippet-cfg

support custom configuration to main context of nginx config
This commit is contained in:
k8s-ci-robot 2018-08-03 15:19:19 -07:00 committed by GitHub
commit af7fe6bff9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 3 deletions

View file

@ -114,6 +114,7 @@ The following table shows a configuration option's name, type, and the default v
|[jaeger-service-name](#jaeger-service-name)|string|"nginx"| |[jaeger-service-name](#jaeger-service-name)|string|"nginx"|
|[jaeger-sampler-type](#jaeger-sampler-type)|string|"const"| |[jaeger-sampler-type](#jaeger-sampler-type)|string|"const"|
|[jaeger-sampler-param](#jaeger-sampler-param)|string|"1"| |[jaeger-sampler-param](#jaeger-sampler-param)|string|"1"|
|[main-snippet](#main-snippet)|string|""|
|[http-snippet](#http-snippet)|string|""| |[http-snippet](#http-snippet)|string|""|
|[server-snippet](#server-snippet)|string|""| |[server-snippet](#server-snippet)|string|""|
|[location-snippet](#location-snippet)|string|""| |[location-snippet](#location-snippet)|string|""|
@ -633,20 +634,21 @@ Specifies the sampler to be used when sampling traces. The available samplers ar
Specifies the argument to be passed to the sampler constructor. Must be a number. Specifies the argument to be passed to the sampler constructor. Must be a number.
For const this should be 0 to never sample and 1 to always sample. _**default:**_ 1 For const this should be 0 to never sample and 1 to always sample. _**default:**_ 1
## main-snippet
Adds custom configuration to the main section of the nginx configuration.
## http-snippet ## http-snippet
Adds custom configuration to the http section of the nginx configuration. Adds custom configuration to the http section of the nginx configuration.
_**default:**_ ""
## server-snippet ## server-snippet
Adds custom configuration to all the servers in the nginx configuration. Adds custom configuration to all the servers in the nginx configuration.
_**default:**_ ""
## location-snippet ## location-snippet
Adds custom configuration to all the locations in the nginx configuration. Adds custom configuration to all the locations in the nginx configuration.
_**default:**_ ""
## custom-http-errors ## custom-http-errors

View file

@ -459,6 +459,9 @@ type Configuration struct {
// Default: 1 // Default: 1
JaegerSamplerParam string `json:"jaeger-sampler-param"` JaegerSamplerParam string `json:"jaeger-sampler-param"`
// MainSnippet adds custom configuration to the main section of the nginx configuration
MainSnippet string `json:"main-snippet"`
// HTTPSnippet adds custom configuration to the http section of the nginx configuration // HTTPSnippet adds custom configuration to the http section of the nginx configuration
HTTPSnippet string `json:"http-snippet"` HTTPSnippet string `json:"http-snippet"`

View file

@ -41,6 +41,10 @@ events {
use epoll; use epoll;
} }
{{ if not (empty $cfg.MainSnippet) }}
{{ $cfg.MainSnippet }}
{{ end }}
http { http {
{{ if not $all.DisableLua }} {{ if not $all.DisableLua }}
lua_package_cpath "/usr/local/lib/lua/?.so;/usr/lib/lua-platform-path/lua/5.1/?.so;;"; lua_package_cpath "/usr/local/lib/lua/?.so;/usr/lib/lua-platform-path/lua/5.1/?.so;;";

View file

@ -0,0 +1,43 @@
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package settings
import (
"strings"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"k8s.io/ingress-nginx/test/e2e/framework"
)
var _ = framework.IngressNginxDescribe("Main Snippet", func() {
f := framework.NewDefaultFramework("main-snippet")
mainSnippet := "main-snippet"
It("should add value of main-snippet setting to nginx config", func() {
expectedComment := "# main snippet"
err := f.UpdateNginxConfigMapData(mainSnippet, expectedComment)
Expect(err).NotTo(HaveOccurred())
err = f.WaitForNginxConfiguration(
func(cfg string) bool {
return strings.Contains(cfg, expectedComment)
})
Expect(err).NotTo(HaveOccurred())
})
})