configs

package
v1.5.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultServerSecretName = "default"

DefaultServerSecretName is the filename of the Secret with a TLS cert and a key for the default server.

View Source
const JWTKeyAnnotation = "nginx.com/jwt-key"

JWTKeyAnnotation is the annotation where the Secret with a JWK is specified.

View Source
const JWTKeyKey = "jwk"

JWTKeyKey is the key of the data field of a Secret where the JWK must be stored.

View Source
const WildcardSecretName = "wildcard"

WildcardSecretName is the filename of the Secret with a TLS cert and a key for the ingress resources with TLS termination enabled but not secret defined.

Variables

This section is empty.

Functions

func GenerateCertAndKeyFileContent

func GenerateCertAndKeyFileContent(secret *api_v1.Secret) []byte

GenerateCertAndKeyFileContent generates a pem file content from the TLS secret.

func GenerateEndpointsKey

func GenerateEndpointsKey(serviceNamespace string, serviceName string, port uint16) string

GenerateEndpointsKey generates a key for the Endpoints map in VirtualServerEx.

func GenerateNginxMainConfig

func GenerateNginxMainConfig(staticCfgParams *StaticConfigParams, config *ConfigParams) *version1.MainConfig

GenerateNginxMainConfig generates MainConfig.

func GetMapKeyAsBool

func GetMapKeyAsBool(m map[string]string, key string, context apiObject) (bool, bool, error)

GetMapKeyAsBool searches the map for the given key and parses the key as bool.

func GetMapKeyAsInt

func GetMapKeyAsInt(m map[string]string, key string, context apiObject) (int, bool, error)

GetMapKeyAsInt tries to find and parse a key in a map as int.

func GetMapKeyAsInt64

func GetMapKeyAsInt64(m map[string]string, key string, context apiObject) (int64, bool, error)

GetMapKeyAsInt64 tries to find and parse a key in a map as int64.

func GetMapKeyAsStringSlice

func GetMapKeyAsStringSlice(m map[string]string, key string, context apiObject, delimiter string) ([]string, bool, error)

GetMapKeyAsStringSlice tries to find and parse a key in the map as string slice splitting it on delimiter.

func GetMapKeyAsUint64

func GetMapKeyAsUint64(m map[string]string, key string, context apiObject, nonZero bool) (uint64, bool, error)

GetMapKeyAsUint64 tries to find and parse a key in a map as uint64.

func ParseLBMethod

func ParseLBMethod(method string) (string, error)

ParseLBMethod parses method and matches it to a corresponding load balancing method in NGINX. An error is returned if method is not valid.

func ParseLBMethodForPlus

func ParseLBMethodForPlus(method string) (string, error)

ParseLBMethodForPlus parses method and matches it to a corresponding load balancing method in NGINX Plus. An error is returned if method is not valid.

Types

type ConfigParams

type ConfigParams struct {
	LocationSnippets              []string
	ServerSnippets                []string
	ServerTokens                  string
	ProxyConnectTimeout           string
	ProxyReadTimeout              string
	ClientMaxBodySize             string
	HTTP2                         bool
	RedirectToHTTPS               bool
	SSLRedirect                   bool
	MainMainSnippets              []string
	MainHTTPSnippets              []string
	MainStreamSnippets            []string
	MainServerNamesHashBucketSize string
	MainServerNamesHashMaxSize    string
	MainAccessLogOff              bool
	MainLogFormat                 string
	MainErrorLogLevel             string
	MainStreamLogFormat           string
	ProxyBuffering                bool
	ProxyBuffers                  string
	ProxyBufferSize               string
	ProxyMaxTempFileSize          string
	ProxyProtocol                 bool
	ProxyHideHeaders              []string
	ProxyPassHeaders              []string
	HSTS                          bool
	HSTSBehindProxy               bool
	HSTSMaxAge                    int64
	HSTSIncludeSubdomains         bool
	LBMethod                      string
	MainWorkerProcesses           string
	MainWorkerCPUAffinity         string
	MainWorkerShutdownTimeout     string
	MainWorkerConnections         string
	MainWorkerRlimitNofile        string
	Keepalive                     int64
	MaxFails                      int
	FailTimeout                   string
	HealthCheckEnabled            bool
	HealthCheckMandatory          bool
	HealthCheckMandatoryQueue     int64
	SlowStart                     string
	ResolverAddresses             []string
	ResolverIPV6                  bool
	ResolverValid                 string
	ResolverTimeout               string
	MainKeepaliveTimeout          string
	MainKeepaliveRequests         int64
	VariablesHashBucketSize       uint64
	VariablesHashMaxSize          uint64

	RealIPHeader    string
	SetRealIPFrom   []string
	RealIPRecursive bool

	MainServerSSLProtocols           string
	MainServerSSLPreferServerCiphers bool
	MainServerSSLCiphers             string
	MainServerSSLDHParam             string
	MainServerSSLDHParamFileContent  *string

	MainTemplate    *string
	IngressTemplate *string

	JWTRealm    string
	JWTKey      string
	JWTToken    string
	JWTLoginURL string

	Ports    []int
	SSLPorts []int
}

ConfigParams holds NGINX configuration parameters that affect the main NGINX config as well as configs for Ingress resources.

func NewDefaultConfigParams

func NewDefaultConfigParams() *ConfigParams

NewDefaultConfigParams creates a ConfigParams with default values.

func ParseConfigMap

func ParseConfigMap(cfgm *v1.ConfigMap, nginxPlus bool) *ConfigParams

ParseConfigMap parses ConfigMap into ConfigParams.

type Configurator

type Configurator struct {
	// contains filtered or unexported fields
}

Configurator configures NGINX.

func NewConfigurator

func NewConfigurator(nginxManager nginx.Manager, staticCfgParams *StaticConfigParams, config *ConfigParams, templateExecutor *version1.TemplateExecutor,
	templateExecutorV2 *version2.TemplateExecutor, isPlus bool, isWildcardEnabled bool) *Configurator

NewConfigurator creates a new Configurator.

func (*Configurator) AddOrUpdateDHParam

func (cnf *Configurator) AddOrUpdateDHParam(content string) (string, error)

AddOrUpdateDHParam creates a dhparam file with the content of the string.

func (*Configurator) AddOrUpdateIngress

func (cnf *Configurator) AddOrUpdateIngress(ingEx *IngressEx) error

AddOrUpdateIngress adds or updates NGINX configuration for the Ingress resource.

func (*Configurator) AddOrUpdateJWKSecret

func (cnf *Configurator) AddOrUpdateJWKSecret(secret *api_v1.Secret)

func (*Configurator) AddOrUpdateMergeableIngress

func (cnf *Configurator) AddOrUpdateMergeableIngress(mergeableIngs *MergeableIngresses) error

AddOrUpdateMergeableIngress adds or updates NGINX configuration for the Ingress resources with Mergeable Types.

func (*Configurator) AddOrUpdateSpecialTLSSecrets

func (cnf *Configurator) AddOrUpdateSpecialTLSSecrets(secret *api_v1.Secret, secretNames []string) error

AddOrUpdateSpecialTLSSecrets adds or updates a file with a TLS cert and a key from a Special TLS Secret (eg. DefaultServerSecret, WildcardTLSSecret).

func (*Configurator) AddOrUpdateTLSSecret

func (cnf *Configurator) AddOrUpdateTLSSecret(secret *api_v1.Secret, ingExes []IngressEx, mergeableIngresses []MergeableIngresses, virtualServerExes []*VirtualServerEx) error

AddOrUpdateTLSSecret adds or updates a file with the content of the TLS secret.

func (*Configurator) AddOrUpdateVirtualServer

func (cnf *Configurator) AddOrUpdateVirtualServer(virtualServerEx *VirtualServerEx) error

AddOrUpdateVirtualServer adds or updates NGINX configuration for the VirtualServer resource.

func (*Configurator) DeleteIngress

func (cnf *Configurator) DeleteIngress(key string) error

DeleteIngress deletes NGINX configuration for the Ingress resource.

func (*Configurator) DeleteSecret

func (cnf *Configurator) DeleteSecret(key string, ingExes []IngressEx, mergeableIngresses []MergeableIngresses, virtualServerExes []*VirtualServerEx) error

DeleteSecret deletes the file associated with the secret and the configuration files for Ingress and VirtualServer resources. NGINX is reloaded only when the total number of the resources > 0.

func (*Configurator) DeleteVirtualServer

func (cnf *Configurator) DeleteVirtualServer(key string) error

DeleteVirtualServer deletes NGINX configuration for the VirtualServer resource.

func (*Configurator) GetIngressCounts

func (cnf *Configurator) GetIngressCounts() map[string]int

GetIngressCounts returns the total count of Ingress resources that are handled by the Ingress Controller grouped by their type

func (*Configurator) HasIngress

func (cnf *Configurator) HasIngress(ing *extensions.Ingress) bool

HasIngress checks if the Ingress resource is present in NGINX configuration.

func (*Configurator) HasMinion

func (cnf *Configurator) HasMinion(master *extensions.Ingress, minion *extensions.Ingress) bool

HasMinion checks if the minion Ingress resource of the master is present in NGINX configuration.

func (*Configurator) IsResolverConfigured

func (cnf *Configurator) IsResolverConfigured() bool

IsResolverConfigured checks if a DNS resolver is present in NGINX configuration.

func (*Configurator) UpdateConfig

func (cnf *Configurator) UpdateConfig(cfgParams *ConfigParams, ingExes []*IngressEx, mergeableIngs map[string]*MergeableIngresses, virtualServerExes []*VirtualServerEx) error

UpdateConfig updates NGINX configuration parameters.

func (*Configurator) UpdateEndpoints

func (cnf *Configurator) UpdateEndpoints(ingExes []*IngressEx) error

UpdateEndpoints updates endpoints in NGINX configuration for the Ingress resources.

func (*Configurator) UpdateEndpointsForVirtualServers

func (cnf *Configurator) UpdateEndpointsForVirtualServers(virtualServerExes []*VirtualServerEx) error

UpdateEndpointsForVirtualServers updates endpoints in NGINX configuration for the s resources.

func (*Configurator) UpdateEndpointsMergeableIngress

func (cnf *Configurator) UpdateEndpointsMergeableIngress(mergeableIngresses []*MergeableIngresses) error

UpdateEndpointsMergeableIngress updates endpoints in NGINX configuration for a mergeable Ingress resource.

type IngressEx

type IngressEx struct {
	Ingress          *extensions.Ingress
	TLSSecrets       map[string]*api_v1.Secret
	JWTKey           JWTKey
	Endpoints        map[string][]string
	HealthChecks     map[string]*api_v1.Probe
	ExternalNameSvcs map[string]bool
}

IngressEx holds an Ingress along with the resources that are referenced in this Ingress.

func (*IngressEx) String

func (ingEx *IngressEx) String() string

type JWTKey

type JWTKey struct {
	Name   string
	Secret *api_v1.Secret
}

JWTKey represents a secret that holds JSON Web Key.

type MergeableIngresses

type MergeableIngresses struct {
	Master  *IngressEx
	Minions []*IngressEx
}

MergeableIngresses is a mergeable ingress of a master and minions.

type StaticConfigParams

type StaticConfigParams struct {
	HealthStatus                   bool
	NginxStatus                    bool
	NginxStatusAllowCIDRs          []string
	NginxStatusPort                int
	StubStatusOverUnixSocketForOSS bool
}

StaticConfigParams holds immutable NGINX configuration parameters that affect the main NGINX config.

type VirtualServerEx

type VirtualServerEx struct {
	VirtualServer       *conf_v1alpha1.VirtualServer
	Endpoints           map[string][]string
	TLSSecret           *api_v1.Secret
	VirtualServerRoutes []*conf_v1alpha1.VirtualServerRoute
}

VirtualServerEx holds a VirtualServer along with the resources that are referenced in this VirtualServer.

func (*VirtualServerEx) String

func (vsx *VirtualServerEx) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL