Documentation
¶
Index ¶
- Constants
- Variables
- func GetIndexesOfValue(arr []string, key string, cutset string) []int
- func GetMapKeyAsBool(m map[string]string, key string, context apiObject) (bool, bool, error)
- func GetMapKeyAsInt(m map[string]string, key string, context apiObject) (int64, bool, error)
- func GetMapKeyAsStringSlice(m map[string]string, key string, context apiObject, delimiter string) ([]string, bool, error)
- func GetWatchFrequency() string
- func HandleMutualAuth(annotation parser.ParsedValidatedAnnotation, resourceName, serverName string) (map[string][]string, []string, error)
- func ParseLocationSnippetLine(snippet []string, ingressName string, annotation string, deliminator string) map[string][]string
- func ParseStatsdService(statsdAnnotationsString string) (enableAllLoc bool, err error)
- func RemoveFileIfExist(filename string)
- func SetWatchFrequency(watchFrequencyUpdated string)
- type Config
- type Configurator
- func (cnf *Configurator) AddOrUpdateDHParam(content string) (string, error)
- func (cnf *Configurator) AddOrUpdateIngress(name string, ingEx *IngressEx)
- func (cnf *Configurator) AddOrUpdateTLSSecret(secret *api.Secret, ings []networking.Ingress, sslings []networking.Ingress, ...) error
- func (cnf *Configurator) DeleteIngress(name string)
- func (cnf *Configurator) DeleteSecret(secretName string, ings []networking.Ingress, sslings []networking.Ingress, ...) error
- func (cnf *Configurator) EventLogf(ingEx *IngressEx, msgCode string, format string, args ...interface{})
- func (cnf *Configurator) GetAnnotationModel(annotationStr string, ingEx *IngressEx) (annotationModel parser.ParsedValidatedAnnotation, annotationExists bool)
- func (cnf *Configurator) GetCertificateData(secret []byte) (map[string]string, error)
- func (cnf *Configurator) GetNginxCertsPath() string
- func (cnf *Configurator) GetPodScale() int
- func (cnf *Configurator) GetSSLServices(ingEx *IngressEx) (sslServices map[string]SSLServicesData)
- func (cnf *Configurator) ParseAnnotation(annotationStr string, annotationStringIng string, ingEx *IngressEx) (annotationModel parser.ParsedValidatedAnnotation)
- func (cnf *Configurator) SetPodScale(PodVal int)
- func (cnf *Configurator) UpdateConfig(config *Config)
- func (cnf *Configurator) UpdateEndpoints(name string, ingEx *IngressEx)
- func (cnf *Configurator) VerifyUseOfIstioSvc(ingEx *IngressEx, svc *api.Service) (found bool)
- type CustomErrorActions
- type CustomPort
- type IngressEx
- type IngressNginxConfig
- type IngressNginxController
- func (nginx *IngressNginxController) AddOrUpdateCertAndKey(name string, cert string, key string, ca string) string
- func (nginx *IngressNginxController) AddOrUpdateDHParam(dhparam string) (string, error)
- func (nginx *IngressNginxController) AddOrUpdateIngress(name string, config IngressNginxConfig)
- func (nginx *IngressNginxController) AddOrUpdateIngressStream(name string, StreamConfigs []IngressNginxStreamConfig, ...)
- func (nginx *IngressNginxController) AddOrUpdatePemFile(pemFileName string, content []byte) string
- func (nginx *IngressNginxController) AddOrUpdateTrustedCertAndKey(name string, cert string, key string, trustedCert string) (string, string, string)
- func (nginx *IngressNginxController) DeleteIngress(name string)
- func (nginx *IngressNginxController) DeletePemFile(pemFileName string)
- func (nginx *IngressNginxController) Reload() error
- func (nginx *IngressNginxController) Start()
- func (nginx *IngressNginxController) UpdateDefaultConfFile(cfg *IngressNginxMainConfig)
- func (nginx *IngressNginxController) UpdateDefaultPemFile(cfg *IngressNginxMainConfig)
- func (nginx *IngressNginxController) UpdateIndexHTMLFile(cfg *IngressNginxMainConfig)
- func (nginx *IngressNginxController) UpdateLuaUtilityFile(cfg *IngressNginxMainConfig)
- func (nginx *IngressNginxController) UpdateMainConfigFile(cfg *IngressNginxMainConfig)
- type IngressNginxCustomError
- type IngressNginxMainConfig
- type IngressNginxStreamConfig
- type IngressNginxStreamConfigs
- type IstioIngressUpstream
- type Location
- type ProxyBuffer
- type ProxyPems
- type ProxySSLConfig
- type RateLimitZone
- type SSLServicesData
- type Secrets
- type Server
- type Upstream
- type UpstreamSSLConfig
- type UpstreamServer
Constants ¶
const ( // FrontendRole ... FrontendRole = "frontend" // AllIngressServiceName ... AllIngressServiceName = "fd-k8-all" )
Variables ¶
var IsDefaultServerConfGlobal = true
IsDefaultServerConfGlobal ...
var ( // SnortUpstreamServers used for Snort, if adding new snort container update this Object SnortUpstreamServers = Upstream{ Name: "proxy_snort", UpstreamServers: []UpstreamServer{ { Address: "127.0.0.1", Port: "7481", }, { Address: "127.0.0.1", Port: "7482", }, { Address: "127.0.0.1", Port: "7483", }, }, } )
Functions ¶
func GetIndexesOfValue ¶
GetIndexesOfValue returns all the indexes of a key in the string slice
func GetMapKeyAsBool ¶
GetMapKeyAsBool searches the map for the given key and parses the key as bool
func GetMapKeyAsInt ¶
GetMapKeyAsInt 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 HandleMutualAuth ¶
func HandleMutualAuth(annotation parser.ParsedValidatedAnnotation, resourceName, serverName string) (map[string][]string, []string, error)
HandleMutualAuth ...
func ParseLocationSnippetLine ¶
func ParseLocationSnippetLine(snippet []string, ingressName string, annotation string, deliminator string) map[string][]string
ParseLocationSnippetLine ...
func ParseStatsdService ¶
ParseStatsdService ...
Types ¶
type Config ¶
type Config struct {
LocationSnippets map[string][]string
AllLocationSnippet []string
ServerSnippets []string
ServerTokens bool
ProxyConnectTimeout string
ProxyReadTimeout string
ClientMaxBodySize string
LargeClientHeaderBuffers string
HTTP2 bool
RedirectToHTTPS bool
MainHTTPSnippets []string
MainServerNamesHashBucketSize string
MainServerNamesHashMaxSize string
MainLogFormat string
MainLogFormatEscapeJSON string
VtsStatusZoneSize string
ProxyBuffering bool
ProxyMaxTempFileSize string
ProxyProtocol bool
ProxyHideHeaders []string
ProxyPassHeaders []string
HSTS bool
HSTSMaxAge int
HSTSIncludeSubdomains bool
InKeepAlive string
InKeepaliveRequests string
Backlog string
ReusePort bool
ProxySslVerifyDepth int
// http://nginx.org/en/docs/http/ngx_http_realip_module.html
RealIPHeader string
SetRealIPFrom []string
RealIPRecursive bool
Stream string
// http://nginx.org/en/docs/http/ngx_http_ssl_module.html
MainServerSSLProtocols string
MainServerSSLPreferServerCiphers bool
MainServerSSLCiphers string
MainServerSSLDHParam string
// Ratelimit Annotations
RatelimitMemory string
RatelimitValue string
RatelimitBurst string
//ActivityTracker log
ActivityTracker bool
//Customer Logs
CustomerLogs bool
//Access Logs
AccessLogEnabled bool
AccessLogBuffer string
AccessLogFlush string
//Indicates if istio is present
IsIstioPresent bool
IstioPort int64
IstioIP string
IamGlobalEndpoint string
}
Config holds NGINX configuration parameters
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
NewDefaultConfig creates a Config with default values
type Configurator ¶
type Configurator struct {
// contains filtered or unexported fields
}
Configurator transforms an Ingress resource into NGINX Configuration
func NewConfigurator ¶
func NewConfigurator(nginx *IngressNginxController, config *Config, kubeClient kubernetes.Interface) *Configurator
NewConfigurator creates a new Configurator
func (*Configurator) AddOrUpdateDHParam ¶
func (cnf *Configurator) AddOrUpdateDHParam(content string) (string, error)
AddOrUpdateDHParam ...
func (*Configurator) AddOrUpdateIngress ¶
func (cnf *Configurator) AddOrUpdateIngress(name string, ingEx *IngressEx)
AddOrUpdateIngress adds or updates NGINX configuration for an Ingress resource
func (*Configurator) AddOrUpdateTLSSecret ¶
func (cnf *Configurator) AddOrUpdateTLSSecret(secret *api.Secret, ings []networking.Ingress, sslings []networking.Ingress, mutualAuthings []networking.Ingress, reload bool) error
AddOrUpdateTLSSecret creates or updates a file with the content of the TLS secret
func (*Configurator) DeleteIngress ¶
func (cnf *Configurator) DeleteIngress(name string)
DeleteIngress deletes NGINX configuration for an Ingress resource
func (*Configurator) DeleteSecret ¶
func (cnf *Configurator) DeleteSecret(secretName string, ings []networking.Ingress, sslings []networking.Ingress, mutualAuthings []networking.Ingress) error
DeleteSecret deletes secret
func (*Configurator) EventLogf ¶
func (cnf *Configurator) EventLogf(ingEx *IngressEx, msgCode string, format string, args ...interface{})
EventLogf ...
func (*Configurator) GetAnnotationModel ¶
func (cnf *Configurator) GetAnnotationModel(annotationStr string, ingEx *IngressEx) (annotationModel parser.ParsedValidatedAnnotation, annotationExists bool)
GetAnnotationModel ...
func (*Configurator) GetCertificateData ¶
func (cnf *Configurator) GetCertificateData(secret []byte) (map[string]string, error)
GetCertificateData ...
func (*Configurator) GetNginxCertsPath ¶
func (cnf *Configurator) GetNginxCertsPath() string
GetNginxCertsPath ...
func (*Configurator) GetSSLServices ¶
func (cnf *Configurator) GetSSLServices(ingEx *IngressEx) (sslServices map[string]SSLServicesData)
GetSSLServices ...
func (*Configurator) ParseAnnotation ¶
func (cnf *Configurator) ParseAnnotation(annotationStr string, annotationStringIng string, ingEx *IngressEx) (annotationModel parser.ParsedValidatedAnnotation)
ParseAnnotation ...
func (*Configurator) UpdateConfig ¶
func (cnf *Configurator) UpdateConfig(config *Config)
UpdateConfig updates NGINX Configuration parameters
func (*Configurator) UpdateEndpoints ¶
func (cnf *Configurator) UpdateEndpoints(name string, ingEx *IngressEx)
UpdateEndpoints updates endpoints in NGINX configuration for an Ingress resource
func (*Configurator) VerifyUseOfIstioSvc ¶
func (cnf *Configurator) VerifyUseOfIstioSvc(ingEx *IngressEx, svc *api.Service) (found bool)
VerifyUseOfIstioSvc ...
type CustomErrorActions ¶
CustomErrorActions ...
type IngressEx ¶
type IngressEx struct {
Ingress *networking.Ingress
Secrets map[string]*api.Secret
Endpoints map[string][]string
UpstreamSSLData map[string]UpstreamSSLConfig
IsUpsreamSSLs bool
SSLCommonNames map[string]string
PlainSSL []string
IstioIngressUpstreams []IstioIngressUpstream
}
IngressEx holds an Ingress along with Secrets and Endpoints of the services that are referenced in this Ingress
type IngressNginxConfig ¶
type IngressNginxConfig struct {
Upstreams []Upstream
Servers []Server
GlobalRatelimitzones []RateLimitZone
ServiceRatelimitzones []RateLimitZone
// Snort
SnortEnabled bool
SnortUpstream Upstream
}
IngressNginxConfig describes an NGINX configuration
type IngressNginxController ¶
type IngressNginxController struct {
// contains filtered or unexported fields
}
IngressNginxController Updates NGINX configuration, starts and reloads NGINX
func NewNginxController ¶
func NewNginxController(nginxConfPath string, local bool, healthStatus bool) (*IngressNginxController, error)
NewNginxController creates a NGINX controller
func (*IngressNginxController) AddOrUpdateCertAndKey ¶
func (nginx *IngressNginxController) AddOrUpdateCertAndKey(name string, cert string, key string, ca string) string
AddOrUpdateCertAndKey creates a .pem file wth the cert and the key with the specified name
func (*IngressNginxController) AddOrUpdateDHParam ¶
func (nginx *IngressNginxController) AddOrUpdateDHParam(dhparam string) (string, error)
AddOrUpdateDHParam creates the servers dhparam.pem file
func (*IngressNginxController) AddOrUpdateIngress ¶
func (nginx *IngressNginxController) AddOrUpdateIngress(name string, config IngressNginxConfig)
AddOrUpdateIngress creates or updates a file with the specified configuration for the specified ingress
func (*IngressNginxController) AddOrUpdateIngressStream ¶
func (nginx *IngressNginxController) AddOrUpdateIngressStream(name string, StreamConfigs []IngressNginxStreamConfig, upstreams map[string]Upstream)
AddOrUpdateIngressStream ...
func (*IngressNginxController) AddOrUpdatePemFile ¶
func (nginx *IngressNginxController) AddOrUpdatePemFile(pemFileName string, content []byte) string
AddOrUpdatePemFile creates a .pem file wth the cert and the key with the specified name
func (*IngressNginxController) AddOrUpdateTrustedCertAndKey ¶
func (nginx *IngressNginxController) AddOrUpdateTrustedCertAndKey(name string, cert string, key string, trustedCert string) (string, string, string)
AddOrUpdateTrustedCertAndKey creates a .crt file wth the trusted cert and client cert and client key with the specified name
func (*IngressNginxController) DeleteIngress ¶
func (nginx *IngressNginxController) DeleteIngress(name string)
DeleteIngress deletes the configuration file, which corresponds for the specified ingress from NGINX conf directory
func (*IngressNginxController) DeletePemFile ¶
func (nginx *IngressNginxController) DeletePemFile(pemFileName string)
DeletePemFile deletes the pem file
func (*IngressNginxController) Reload ¶
func (nginx *IngressNginxController) Reload() error
Reload reloads NGINX
func (*IngressNginxController) Start ¶
func (nginx *IngressNginxController) Start()
Start starts NGINX
func (*IngressNginxController) UpdateDefaultConfFile ¶
func (nginx *IngressNginxController) UpdateDefaultConfFile(cfg *IngressNginxMainConfig)
UpdateDefaultConfFile update the default conf file
func (*IngressNginxController) UpdateDefaultPemFile ¶
func (nginx *IngressNginxController) UpdateDefaultPemFile(cfg *IngressNginxMainConfig)
UpdateDefaultPemFile update the index html file
func (*IngressNginxController) UpdateIndexHTMLFile ¶
func (nginx *IngressNginxController) UpdateIndexHTMLFile(cfg *IngressNginxMainConfig)
UpdateIndexHTMLFile update the index html file
func (*IngressNginxController) UpdateLuaUtilityFile ¶
func (nginx *IngressNginxController) UpdateLuaUtilityFile(cfg *IngressNginxMainConfig)
UpdateLuaUtilityFile update the lua utility file
func (*IngressNginxController) UpdateMainConfigFile ¶
func (nginx *IngressNginxController) UpdateMainConfigFile(cfg *IngressNginxMainConfig)
UpdateMainConfigFile update the main NGINX configuration file
type IngressNginxCustomError ¶
IngressNginxCustomError ...
type IngressNginxMainConfig ¶
type IngressNginxMainConfig struct {
ServerNamesHashBucketSize string
ServerNamesHashMaxSize string
LogFormat string
LogFormatEscapeJSON string
VtsStatusZoneSize string
HealthStatus bool
HTTPSnippets []string
InKeepAlive string
InKeepaliveRequests string
Backlog string
ReusePort bool
// http://nginx.org/en/docs/http/ngx_http_ssl_module.html
SSLProtocols string
SSLPreferServerCiphers bool
SSLCiphers string
SSLDHParam string
ActivityTracker bool
CustomerLogs bool
PodName string
// Used to disable default server in default.conf
IsDefaultServerConf bool
// Snort
SnortEnabled bool
SnortUpstream Upstream
//Access Log buffering
AccessLogEnabled bool
AccessLogBuffer string
AccessLogFlush string
}
IngressNginxMainConfig describe the main NGINX configuration file
type IngressNginxStreamConfig ¶
IngressNginxStreamConfig ...
func ParseSingleStream ¶
func ParseSingleStream(stream string) (config IngressNginxStreamConfig, err error)
ParseSingleStream ... ingress.bluemix.net/tcp-ports: "ingressPort=80 serviceName=tea-svc servicePort=8080;ingressPort=81 serviceName=coffee-svc servicePort=8081"
func ParseStreamConfigs ¶
func ParseStreamConfigs(streams string) (configs []IngressNginxStreamConfig, err error)
ParseStreamConfigs ...
type IngressNginxStreamConfigs ¶
type IngressNginxStreamConfigs struct {
StreamConfigs []IngressNginxStreamConfig
Ups []Upstream
}
IngressNginxStreamConfigs ...
type IstioIngressUpstream ¶
IstioIngressUpstream ...
type Location ¶
type Location struct {
LocationSnippets []string
Path string
Upstream Upstream
ProxyConnectTimeout string
ProxyReadTimeout string
ClientMaxBodySize string
Websocket bool
Rewrite string
SSL bool
ProxyMaxTempFileSize string
RatelimitMemory string
RatelimitValue string
RatelimitBurst string
ActivityTracker bool
CustomerLogs bool
ProxySetHeaders []string
MoreSetHeaders []string
MoreClearHeaders []string
LocationModifier string
//watson configurations
MapPath string
WatsonAuthURL bool
WatsonSecondaryHost string
WatsonSecondarySvc string
WatsonUpstream bool
AuthCookie bool
Options bool
// IAM Oauth Configurations
IamAuthURL bool
ClientID string
ClientSecret string
ClientSecretNS string
SvcName string
ClientRedirectURL string
// IAM CLI Configurations
IamCLIAuthURL bool
IamLogoutEnabled bool
// AppId Configurations
AppIDSecret string
AppIDNameSpace string
AppIDRequestType string
AppIDToken bool
//proxy_next_upstream configuration
ProxyNextUpstreamValues string
ProxyNextUpstreamTimeout string
ProxyNextUpstreamTries int
ExternalLocation bool
ExternalSvc string
ExtDNSResolver string
SSLAuthentication bool
SSLTwoWayAuthentication bool
ProxySslTrustedCertificate string
ProxySslCertificate string
ProxySslCertificateKey string
LocationRateLimitZones []RateLimitZone
ProxySslVerifyDepth int
PlainSSLAuthentication bool
ProxySSLName string
KeepAliveTimeout string
KeepAliveRequests string
AllLocationSnippet []string
CustomErrors []IngressNginxCustomError
ProxyBuffering bool
AddHostPort bool
ProxyBuffers ProxyBuffer
ProxyBufferSize string
ProxyBusyBufferSize string
IstioEnabled bool
IstioPort int64
IstioIP string
StatsdConfigEnabled bool
}
Location describes an NGINX location
type ProxySSLConfig ¶
ProxySSLConfig is to store the SSL config parameters that are used on the upstream connections
type RateLimitZone ¶
type RateLimitZone struct {
Name string
Key string
Rate string
RateUnit string
Conn string
ConnMem string
RateMem string
Burst int
}
RateLimitZone Struct
type SSLServicesData ¶
SSLServicesData holds the value of the attrtibutes parsed from the ssl-services annotation of Ingresses
type Server ¶
type Server struct {
ServerSnippets []string
Name string
ServerTokens bool
Locations []Location
SSL bool
SSLCertificate string
SSLCertificateKey string
HTTP2 bool
RedirectToHTTPS bool
ProxyProtocol bool
HSTS bool
HSTSMaxAge int
HSTSIncludeSubdomains bool
ProxyHideHeaders []string
ProxyPassHeaders []string
GlobalSerRateLimitZones []RateLimitZone
LargeClientHeaderBuffers string
// Port configurations
HTTPPort string
HTTPSPort string
MutualAuthPort string
SSLClientCertificate string
MutualAuthPaths []string
NonMutualAuthPaths []string
// http://nginx.org/en/docs/http/ngx_http_realip_module.html
RealIPHeader string
SetRealIPFrom []string
RealIPRecursive bool
// Watson configurations
OptionLocation bool
WatsonAuthLocation string
IamAuthLocation bool
IamCliAuthLocation bool
IamAllCliAuthLocation bool
KeepAliveTimeout string
KeepAliveRequests string
CustomerLogs bool
IamLogoutEnabled bool
IamGlobalEndpoint string
// AppID
AppIDEnabled bool
AppIDWebEnabled bool
// Used for Healthcheck
IsDefaultHealthcheck bool
// Used for setting up a default Server
IsDefaultServer bool
ErrorActions []CustomErrorActions
GlobalCustomErrors []IngressNginxCustomError
}
Server describes an NGINX server
type Upstream ¶
type Upstream struct {
Name string
UpstreamServers []UpstreamServer
StickyCookie string
KeepAlive int
LBType string
KeepAliveTimeout string
}
Upstream describes an NGINX upstream
func NewUpstreamWithDefaultServer ¶
NewUpstreamWithDefaultServer creates an upstream with the default server. proxy_pass to an upstream with the default server returns 502. We use it for services that have no endpoints
type UpstreamSSLConfig ¶
type UpstreamSSLConfig struct {
Secrets Secrets
ProxySSLConfig ProxySSLConfig
}
UpstreamSSLConfig is to store the secrets and other SSL config parameters that are used on the upstream connections