controller

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppImageName    = "jkaninda/goma-gateway"
	ExtraConfigPath = "/etc/goma/extra/"
	BasicAuth       = "basic" // basic authentication middlewares
	JWTAuth         = "jwt"   // JWT authentication middlewares
	OAuth           = "oauth"

	RateLimit            = "rateLimit"
	BelongsTo            = "goma-gateway"
	GatewayConfigVersion = "1.0"
	FinalizerName        = "finalizer.gomaproj.jonaskaninda.com"
	ConfigName           = "goma.yml"
)

Variables

View Source
var (
	ReplicaCount int32 = 1
)

Functions

func ConvertRawExtensionToStruct

func ConvertRawExtensionToStruct(raw runtime.RawExtension, out interface{}) error

Types

type BasicRuleMiddleware

type BasicRuleMiddleware struct {
	Username string `yaml:"username" json:"username"`
	Password string `yaml:"password" json:"password"`
}

type Gateway

type Gateway struct {
	// SSLCertFile  SSL Certificate file
	SSLCertFile string `yaml:"sslCertFile"`
	// SSLKeyFile SSL Private key  file
	SSLKeyFile string `yaml:"sslKeyFile"`
	// Redis contains redis database details
	Redis Redis `yaml:"redis"`
	// WriteTimeout defines proxy write timeout
	WriteTimeout int `yaml:"writeTimeout"`
	// ReadTimeout defines proxy read timeout
	ReadTimeout int `yaml:"readTimeout"`
	// IdleTimeout defines proxy idle timeout
	IdleTimeout int                  `yaml:"idleTimeout"`
	LogLevel    string               `yaml:"logLevel"`
	Cors        gomaprojv1beta1.Cors `yaml:"cors"`
	// DisableHealthCheckStatus enable and disable routes health check
	DisableHealthCheckStatus bool `yaml:"disableHealthCheckStatus"`
	// DisableRouteHealthCheckError allows enabling and disabling backend healthcheck errors
	DisableRouteHealthCheckError bool `yaml:"disableRouteHealthCheckError"`
	// Disable allows enabling and disabling displaying routes on start
	DisableDisplayRouteOnStart bool `yaml:"disableDisplayRouteOnStart"`
	// DisableKeepAlive allows enabling and disabling KeepALive server
	DisableKeepAlive bool `yaml:"disableKeepAlive"`
	EnableMetrics    bool `yaml:"enableMetrics"`
	// InterceptErrors holds the status codes to intercept the error from backend
	InterceptErrors []int                         `yaml:"interceptErrors,omitempty"`
	Routes          []gomaprojv1beta1.RouteConfig `json:"routes,omitempty" yaml:"routes,omitempty"`
}

Gateway contains Goma Proxy Gateway's configs

type GatewayConfig

type GatewayConfig struct {
	Version     string       `json:"version" yaml:"version"`
	Gateway     Gateway      `json:"gateway" yaml:"gateway"`
	Middlewares []Middleware `json:"middlewares,omitempty" yaml:"middlewares,omitempty"`
}

type GatewayReconciler

type GatewayReconciler struct {
	client.Client
	Scheme *runtime.Scheme
}

GatewayReconciler reconciles a Gateway object

func (*GatewayReconciler) Reconcile

func (r *GatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state. the Gateway object against the actual cluster state, and then perform operations to make the cluster state reflect the state specified by the user.

For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.1/pkg/reconcile

func (*GatewayReconciler) SetupWithManager

func (r *GatewayReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type JWTRuleMiddleware

type JWTRuleMiddleware struct {
	URL             string            `yaml:"url" json:"url"`
	RequiredHeaders []string          `yaml:"requiredHeaders" json:"requiredHeaders"`
	Headers         map[string]string `yaml:"headers" json:"headers"`
	Params          map[string]string `yaml:"params" json:"params"`
}

type Middleware

type Middleware struct {
	// Path contains the name of middlewares and must be unique
	Name string `json:"name" yaml:"name"`
	// Type contains authentication types
	//
	// basic, jwt, auth0, rateLimit, access
	Type  string   `json:"type" yaml:"type"`   // Middleware type [basic, jwt, auth0, rateLimit, access]
	Paths []string `json:"paths" yaml:"paths"` // Protected paths
	// Rule contains route middleware rule
	Rule interface{} `json:"rule" yaml:"rule"`
}

type Middlewares

type Middlewares struct {
	Middlewares []Middleware `json:"middlewares,omitempty" yaml:"middlewares,omitempty"`
}

type OauthEndpoint

type OauthEndpoint struct {
	AuthURL     string `yaml:"authUrl"`
	TokenURL    string `yaml:"tokenUrl"`
	UserInfoURL string `yaml:"userInfoUrl"`
}

type OauthRulerMiddleware

type OauthRulerMiddleware struct {
	// ClientID is the application's ID.
	ClientID string `yaml:"clientId"`

	// ClientSecret is the application's secret.
	ClientSecret string `yaml:"clientSecret"`
	// oauth provider google, gitlab, github, amazon, facebook, custom
	Provider string `yaml:"provider"`
	// Endpoint contains the resource server's token endpoint
	Endpoint OauthEndpoint `yaml:"endpoint"`

	// RedirectURL is the URL to redirect users going through
	// the OAuth flow, after the resource owner's URLs.
	RedirectURL string `yaml:"redirectUrl"`
	// RedirectPath is the PATH to redirect users after authentication, e.g: /my-protected-path/dashboard
	RedirectPath string `yaml:"redirectPath"`
	// CookiePath e.g: /my-protected-path or / || by default is applied on a route path
	CookiePath string `yaml:"cookiePath"`

	// Scope specifies optional requested permissions.
	Scopes []string `yaml:"scopes"`
	// contains filtered or unexported fields
	State     string `yaml:"state"`
	JWTSecret string `yaml:"jwtSecret"`
}

type RateLimitRuleMiddleware

type RateLimitRuleMiddleware struct {
	Unit            string `yaml:"unit" json:"unit"`
	RequestsPerUnit int    `yaml:"requestsPerUnit" json:"requestsPerUnit"`
}

type Redis

type Redis struct {
	// Addr redis hostname and port number :
	Addr string `yaml:"addr"`
	// Password redis password
	Password string `yaml:"password"`
}

type RouteReconciler

type RouteReconciler struct {
	client.Client
	Scheme *runtime.Scheme
}

RouteReconciler reconciles a Route object

func (*RouteReconciler) Reconcile

func (r *RouteReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state. TODO(user): Modify the Reconcile function to compare the state specified by the Route object against the actual cluster state, and then perform operations to make the cluster state reflect the state specified by the user.

For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.1/pkg/reconcile

func (*RouteReconciler) RestartDeployment

func (r *RouteReconciler) RestartDeployment(ctx context.Context, req ctrl.Request, gateway gomaprojv1beta1.Gateway) error

func (*RouteReconciler) SetupWithManager

func (r *RouteReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

Jump to

Keyboard shortcuts

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