k8simpl

package
v1.6.6 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend added in v0.18.0

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

func NewK8SBackend

func NewK8SBackend(
	restConfig *rest.Config,
	k8sCSet *kubernetes.Clientset,
	traefikClient *traefikv1alpha1.TraefikV1alpha1Client,
	certManagerClient *certmanagerv1.Clientset,
	config Config,
) (*Backend, error)

func (*Backend) AttachContainer added in v0.18.0

func (b *Backend) AttachContainer(ctx context.Context, appID string, stdin io.Reader, stdout, stderr io.Writer) error

func (*Backend) AvailableDomains added in v0.18.0

func (b *Backend) AvailableDomains() domain.AvailableDomainSlice

func (*Backend) AvailablePorts added in v0.18.0

func (b *Backend) AvailablePorts() domain.AvailablePortSlice

func (*Backend) Dispose added in v0.18.0

func (b *Backend) Dispose(_ context.Context) error

func (*Backend) ExecContainer added in v0.18.0

func (b *Backend) ExecContainer(ctx context.Context, appID string, cmd []string, stdin io.Reader, stdout, stderr io.Writer) error

func (*Backend) GetContainer added in v0.18.0

func (b *Backend) GetContainer(ctx context.Context, appID string) (*domain.Container, error)

func (*Backend) ListContainers added in v0.18.0

func (b *Backend) ListContainers(ctx context.Context) ([]*domain.Container, error)

func (*Backend) ListenContainerEvents added in v0.18.0

func (b *Backend) ListenContainerEvents() (sub <-chan *domain.ContainerEvent, unsub func())

func (*Backend) Start added in v0.18.0

func (b *Backend) Start(_ context.Context) error

func (*Backend) Synchronize added in v0.18.0

func (b *Backend) Synchronize(ctx context.Context, s *domain.DesiredState) error

type Config

type Config struct {
	// Domains define available domains to be used by user apps.
	Domains []*domainConf `mapstructure:"domains" yaml:"domains"`
	// Ports define available port-forward ports to be used by user apps.
	Ports []*portConf `mapstructure:"ports" yaml:"ports"`

	// SS defines static-site server endpoint.
	SS struct {
		Namespace string `mapstructure:"namespace" yaml:"namespace"`
		Kind      string `mapstructure:"kind" yaml:"kind"`
		Name      string `mapstructure:"name" yaml:"name"`
		Port      int    `mapstructure:"port" yaml:"port"`
		Scheme    string `mapstructure:"scheme" yaml:"scheme"`
	} `mapstructure:"ss" yaml:"ss"`

	// Routing section defines ingress controller settings.
	Routing struct {
		// Type defines which ingress controller to use.
		// Possible values:
		// 	"traefik": Uses traefik ingress controller.
		Type    string `mapstructure:"type" yaml:"type"`
		Traefik struct {
			// PriorityOffset defines HTTP routes' priority offset for user apps.
			// This is optionally used to optimize routing performance.
			PriorityOffset int `mapstructure:"priorityOffset" yaml:"priorityOffset"`
		} `mapstructure:"traefik" yaml:"traefik"`
	} `mapstructure:"routing" yaml:"routing"`
	// Service section defines Service (L4) routing settings.
	Service struct {
		// IPFamilies defines ipFamilies field for the service objects.
		// Allowed values: IPv4, IPv6
		IPFamilies []v1.IPFamily `mapstructure:"ipFamilies" yaml:"ipFamilies"`
		// IPFamilyPolicy defines ipFamilyPolicy field for the service objects.
		// Allowed values: "", "SingleStack", "PreferDualStack", "RequireDualStack"
		IPFamilyPolicy v1.IPFamilyPolicy `mapstructure:"ipFamilyPolicy" yaml:"ipFamilyPolicy"`
	} `mapstructure:"service" yaml:"service"`

	// Middleware section defines middleware settings.
	Middleware struct {
		// Sablier (https://github.com/acouvreur/sablier) starts user apps on demand and shuts them down after a certain time.
		Sablier struct {
			Enable     bool   `mapstructure:"enable" yaml:"enable"`
			SablierURL string `mapstructure:"url" yaml:"url"`
			// SessionDuration defines how long the session should last.
			//
			// Example: "10m"
			SessionDuration string `mapstructure:"sessionDuration" yaml:"sessionDuration"`
			Dynamic         struct {
				Theme string `mapstructure:"theme" yaml:"theme"`
			} `mapstructure:"dynamic" yaml:"dynamic"`
			Blocking struct {
				// Timeout defines how long the blocking should last.
				Timeout string `mapstructure:"timeout" yaml:"timeout"`
			} `mapstructure:"blocking" yaml:"blocking"`
		} `mapstructure:"sablier" yaml:"sablier"`
	}
	// TLS section defines tls setting for user app ingress.
	TLS struct {
		// Type defines which provider is responsible for obtaining http certificates.
		// Possible values:
		// 	"traefik: Uses traefik internal Lets Encrypt resolver.
		// 	"cert-manager": Delegates to cert-resolver with its own CRD.
		//
		// NOTE: If using multiple instances of traefik, the traefik internal Lets Encrypt resolver is not supported.
		// https://doc.traefik.io/traefik/providers/kubernetes-crd/#letsencrypt-support-with-the-custom-resource-definition-provider
		Type string `mapstructure:"type" yaml:"type"`

		// Traefik section defines options for type "traefik".
		Traefik struct {
			CertResolver string `mapstructure:"certResolver" yaml:"certResolver"`
			Wildcard     struct {
				Domains domain.WildcardDomains `mapstructure:"domains" yaml:"domains"`
			} `mapstructure:"wildcard" yaml:"wildcard"`
		} `mapstructure:"traefik" yaml:"traefik"`

		// CertManager section defines options for type "cert-manager".
		CertManager struct {
			// Issuer defines cert-manager Issuer object reference to be used with CRD.
			Issuer struct {
				Name string `mapstructure:"name" yaml:"name"`
				Kind string `mapstructure:"kind" yaml:"kind"`
			} `mapstructure:"issuer" yaml:"issuer"`
			Wildcard struct {
				// Domains define for which (wildcard) domains cert-manager supports configuring DNS records.
				Domains domain.WildcardDomains `mapstructure:"domains" yaml:"domains"`
			} `mapstructure:"wildcard" yaml:"wildcard"`
		} `mapstructure:"certManager" yaml:"certManager"`
	} `mapstructure:"tls" yaml:"tls"`

	// Namespace defines in which namespace to deploy user apps.
	Namespace string `mapstructure:"namespace" yaml:"namespace"`
	// ImagePullSecret defines secret name to pull user app images with. Required if registry is private.
	ImagePullSecret string `mapstructure:"imagePullSecret" yaml:"imagePullSecret"`
	// Labels define common labels put to all NeoShowcase-managed Kubernetes objects.
	Labels []*labelConf `mapstructure:"labels" yaml:"labels"`
	// Scheduling defines user app pod scheduling constraints.
	Scheduling struct {
		NodeSelector      []*nodeSelector     `mapstructure:"nodeSelector" yaml:"nodeSelector"`
		Tolerations       []*toleration       `mapstructure:"tolerations" yaml:"tolerations"`
		SpreadConstraints []*spreadConstraint `mapstructure:"spreadConstraints" yaml:"spreadConstraints"`
		ForceHosts        []string            `mapstructure:"forceHosts" yaml:"forceHosts"`
	} `mapstructure:"scheduling" yaml:"scheduling"`
	// Resources define user app pod resource constraints.
	Resources struct {
		Requests struct {
			CPU    string `mapstructure:"cpu" yaml:"cpu"`
			Memory string `mapstructure:"memory" yaml:"memory"`
		} `mapstructure:"requests" yaml:"requests"`
		Limits struct {
			CPU    string `mapstructure:"cpu" yaml:"cpu"`
			Memory string `mapstructure:"memory" yaml:"memory"`
		} `mapstructure:"limits" yaml:"limits"`
	} `mapstructure:"resources" yaml:"resources"`
}

func (*Config) Validate

func (c *Config) Validate() error

Jump to

Keyboard shortcuts

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