config

package
v0.0.0-...-585cebd Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ManagedLabel is a managed-by k8s label for kratos
	ManagedLabel = "app.kubernetes.io/managed-by=kratos"
	// LiveProbe represent the live config keyword
	LiveProbe = "live"
	// ReadyProbe represent the ready config keyword
	ReadyProbe = "ready"
	// ConfigSuffix is the suffix of the kratos release secret
	ConfigSuffix = "-kratos-config"
	// ConfigKey is the key in the secret for the configuration of the release
	ConfigKey = "config"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check struct {
	Probe               string `yaml:"probe" validate:"required,uri"`
	Port                int32  `yaml:"port" validate:"required,gte=1,lte=65535"`
	InitialDelaySeconds int32  `yaml:"initialDelaySeconds,omitempty" validate:"omitempty,gte=1,lte=600"`
	PeriodSeconds       int32  `yaml:"periodSeconds,omitempty" validate:"omitempty,gte=1,lte=600"`
}

Check represent the information about the healthcheck

type Common

type Common struct {
	Labels      map[string]string `yaml:"labels,omitempty"`
	Annotations map[string]string `yaml:"annotations,omitempty"`
}

Common represent the common fields

type Config

type Config struct {
	*Common     `yaml:"common,omitempty"`
	*Cronjob    `yaml:"cronjob,omitempty"`
	*Deployment `yaml:"deployment,omitempty"`
	*ConfigMaps `yaml:"configmaps,omitempty"`
	*Secrets    `yaml:"secrets,omitempty"`
}

Config of kratos

func CreateInit

func CreateInit() *Config

CreateInit return an sample config

func (*Config) Load

func (c *Config) Load(file string) error

Load configuration of the specified file

func (*Config) LoadFromString

func (c *Config) LoadFromString(conf string) error

LoadFromString load configuration from a specified string

type ConfigMaps

type ConfigMaps DataFiles

ConfigMaps represent the Kubernetes configmaps

type Container

type Container struct {
	Name      string     `yaml:"name" validate:"required,alphanum,lowercase"`
	Image     string     `yaml:"image" validate:"required,ascii"`
	Tag       string     `yaml:"tag" validate:"required,ascii"`
	Resources *Resources `yaml:"resources,omitempty"`
	Health    *Health    `yaml:"health,omitempty"`
}

Container represent the Kubernetes container

func (*Container) FormatProbe

func (c *Container) FormatProbe(healthType string) *corev1.Probe

FormatProbe format the container healthcheck to return a *corev1.Probe

func (*Container) FormatResources

func (c *Container) FormatResources() corev1.ResourceRequirements

FormatResources format the resource of the container to return a corev1.ResourceRequirements

type Cronjob

type Cronjob struct {
	Labels      map[string]string `yaml:"labels,omitempty"`
	Annotations map[string]string `yaml:"annotations,omitempty"`
	Schedule    string            `yaml:"schedule" validate:"required"`
	Retry       int32             `yaml:"retry,omitempty" validate:"omitempty,gte=0,lte=100"`
	Container   *Container        `yaml:"container" validate:"required"`
}

Cronjob represent the Kubernetes cronjobs

type DataFiles

type DataFiles struct {
	Labels      map[string]string `yaml:"labels,omitempty"`
	Annotations map[string]string `yaml:"annotations,omitempty"`
	Files       []File            `yaml:"files" validate:"required,dive"`
}

DataFiles represent the common data struct for ConfigMaps and Secrets

type Deployment

type Deployment struct {
	Labels      map[string]string `yaml:"labels,omitempty"`
	Annotations map[string]string `yaml:"annotations,omitempty"`
	Replicas    int32             `yaml:"replicas,omitempty" validate:"required,gte=0,lte=100" `
	Port        int32             `yaml:"port" validate:"required,gte=1,lte=65535"`
	Containers  []Container       `yaml:"containers" validate:"required,dive"`
	Ingress     *Ingress          `yaml:"ingress" validate:"required,dive"`
}

Deployment represent the Kubernetes deployment

type File

type File struct {
	Name  string `yaml:"name" validate:"required"`
	Data  string `yaml:"data" validate:"required"`
	Mount *Mount `yaml:"mount" validate:"required,dive"`
}

File contains secrets and configmaps informations

type Health

type Health struct {
	Live  *Check `yaml:"live,omitempty"`
	Ready *Check `yaml:"ready,omitempty"`
}

Health represent the healthcheck for the container

type Ingress

type Ingress struct {
	Labels        map[string]string `yaml:"labels,omitempty"`
	Annotations   map[string]string `yaml:"annotations,omitempty"`
	IngressClass  string            `yaml:"ingressClass" validate:"required,alphanum"`
	ClusterIssuer string            `yaml:"clusterIssuer" validate:"required,alphanum"`
	Hostnames     []string          `yaml:"hostnames" validate:"required,dive,hostname"`
}

Ingress represent the Kubernetes ingress

type Mount

type Mount struct {
	Path      string   `yaml:"path" validate:"required"`
	ExposedTo []string `yaml:"exposedTo" validate:"required"`
}

Mount contains the information how to exposed the secrets

type ResourceType

type ResourceType struct {
	CPU    string `yaml:"cpu,omitempty"`
	Memory string `yaml:"memory,omitempty"`
}

ResourceType represent CPU & Memory allocations

type Resources

type Resources struct {
	Requests *ResourceType `yaml:"requests,omitempty"`
	Limits   *ResourceType `yaml:"limits,omitempty"`
}

Resources represent requests and limits allocations

type Secrets

type Secrets DataFiles

Secrets represent the Kubernetes secrets

Jump to

Keyboard shortcuts

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