k8s

package
v0.0.0-...-a1f8bd1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourceTypeHelmPostgresOperator = "kubernetes-helm-postgres-operator"
	ResourceTypeHelmRedisOperator    = "kubernetes-helm-redis-operator"
	ResourceTypeHelmRabbitmqOperator = "kubernetes-helm-rabbitmq-operator"
	ResourceTypeHelmMongodbOperator  = "kubernetes-helm-mongodb-operator"
)
View Source
const (
	AuthTypeKubeconfig = "kubernetes"
)
View Source
const ProviderType = "kubernetes"
View Source
const ResourceTypeCaddy = "kubernetes-caddy"
View Source
const (
	TemplateTypeKubernetesCloudrun = "kubernetes-cloudrun"
)

Variables

This section is empty.

Functions

func CaddyReadConfig

func CaddyReadConfig(config *api.Config) (api.Config, error)

func ReadHelmMongodbOperatorConfig

func ReadHelmMongodbOperatorConfig(config *api.Config) (api.Config, error)

func ReadHelmPostgresOperatorConfig

func ReadHelmPostgresOperatorConfig(config *api.Config) (api.Config, error)

func ReadHelmRabbitmqOperatorConfig

func ReadHelmRabbitmqOperatorConfig(config *api.Config) (api.Config, error)

func ReadHelmRedisOperatorConfig

func ReadHelmRedisOperatorConfig(config *api.Config) (api.Config, error)

func ReadKubernetesConfig

func ReadKubernetesConfig(config *api.Config) (api.Config, error)

func ReadTemplateConfig

func ReadTemplateConfig(config *api.Config) (api.Config, error)

func ToKubernetesRunConfig

func ToKubernetesRunConfig(tpl any, composeCfg compose.Config, stackCfg *api.StackConfigCompose) (any, error)

Types

type AffinityRules

type AffinityRules struct {
	// NodePool specifies the target node pool for pod scheduling
	NodePool *string `json:"nodePool" yaml:"nodePool"`
	// ExclusiveNodePool ensures pods only run on the specified node pool
	ExclusiveNodePool *bool `json:"exclusiveNodePool" yaml:"exclusiveNodePool"`
	// ComputeClass specifies the compute class (Performance, Scale-Out, general-purpose)
	ComputeClass *string `json:"computeClass" yaml:"computeClass"`
	// NodeAffinity provides direct Kubernetes node affinity configuration
	NodeAffinity *NodeAffinity `json:"nodeAffinity" yaml:"nodeAffinity"`
	// PodAffinity provides pod affinity rules
	PodAffinity *PodAffinity `json:"podAffinity" yaml:"podAffinity"`
	// PodAntiAffinity provides pod anti-affinity rules
	PodAntiAffinity *PodAffinity `json:"podAntiAffinity" yaml:"podAntiAffinity"`
}

AffinityRules defines pod affinity and anti-affinity rules for node pool isolation

type CaddyConfig

type CaddyConfig struct {
	Enable           *bool      `json:"enable,omitempty" yaml:"enable,omitempty"`
	Caddyfile        *string    `json:"caddyfile,omitempty" yaml:"caddyfile,omitempty"`             // TODO: support overwriting
	CaddyfilePrefix  *string    `json:"caddyfilePrefix,omitempty" yaml:"caddyfilePrefix,omitempty"` // custom content to inject at the top of Caddyfile (e.g., storage configuration)
	Namespace        *string    `json:"namespace,omitempty" yaml:"namespace,omitempty"`
	Image            *string    `json:"image,omitempty" yaml:"image,omitempty"`
	Replicas         *int       `json:"replicas,omitempty" yaml:"replicas,omitempty"`
	Resources        *Resources `json:"resources,omitempty" yaml:"resources,omitempty"`               // CPU and memory limits/requests for Caddy container
	VPA              *VPAConfig `json:"vpa,omitempty" yaml:"vpa,omitempty"`                           // Vertical Pod Autoscaler configuration for Caddy
	UsePrefixes      bool       `json:"usePrefixes,omitempty" yaml:"usePrefixes,omitempty"`           // whether to use prefixes instead of domains (default: false)
	ServiceType      *string    `json:"serviceType,omitempty" yaml:"serviceType,omitempty"`           // whether to use custom service type instead of LoadBalancer (default: LoadBalancer)
	ProvisionIngress bool       `json:"provisionIngress,omitempty" yaml:"provisionIngress,omitempty"` // whether to provision ingress for caddy (default: false)
	UseSSL           *bool      `json:"useSSL,omitempty" yaml:"useSSL,omitempty"`                     // whether to use ssl by default (default: true)
}

type CaddyResource

type CaddyResource struct {
	*KubernetesConfig `json:",inline" yaml:",inline"`
	*CaddyConfig      `json:",inline" yaml:",inline"`
}

type CloudExtras

type CloudExtras struct {
	NodeSelector     map[string]string `json:"nodeSelector" yaml:"nodeSelector"`
	DisruptionBudget *DisruptionBudget `json:"disruptionBudget" yaml:"disruptionBudget"`
	RollingUpdate    *RollingUpdate    `json:"rollingUpdate" yaml:"rollingUpdate"`
	Affinity         *AffinityRules    `json:"affinity" yaml:"affinity"`
	Tolerations      []Toleration      `json:"tolerations" yaml:"tolerations"`
	VPA              *VPAConfig        `json:"vpa" yaml:"vpa"`
	ReadinessProbe   *CloudRunProbe    `json:"readinessProbe" yaml:"readinessProbe"`
	LivenessProbe    *CloudRunProbe    `json:"livenessProbe" yaml:"livenessProbe"`
}

type CloudRunContainer

type CloudRunContainer struct {
	Name            string             `json:"name" yaml:"name"`
	Command         []string           `json:"command" yaml:"command"`
	Args            []string           `json:"args" yaml:"args"`
	Image           api.ContainerImage `json:"image" yaml:"image"`
	Env             map[string]string  `json:"env" yaml:"env"`
	Secrets         map[string]string  `json:"secrets" yaml:"secrets"`
	Ports           []int              `json:"ports" yaml:"ports"`
	MainPort        *int               `json:"mainPort" yaml:"mainPort"`
	ReadinessProbe  *CloudRunProbe     `json:"readinessProbe" yaml:"readinessProbe"`
	LivenessProbe   *CloudRunProbe     `json:"livenessProbe" yaml:"livenessProbe"`
	StartupProbe    *CloudRunProbe     `json:"startupProbe" yaml:"startupProbe"`
	ComposeDir      string             `json:"composeDir" yaml:"composeDir"`
	Resources       *Resources         `json:"resources" yaml:"resources"`
	Volumes         []PersistentVolume `json:"volumes" yaml:"volumes"`
	ImagePullPolicy *string            `json:"imagePullPolicy" yaml:"imagePullPolicy"`

	Warnings []string `json:"warnings" yaml:"warnings"` // non-critical errors happened during conversion (should be reported later)
}

func ConvertComposeToContainers

func ConvertComposeToContainers(composeCfg compose.Config, stackCfg *api.StackConfigCompose) ([]CloudRunContainer, error)

func FindIngressContainer

func FindIngressContainer(composeCfg compose.Config, contaniers []CloudRunContainer) (*CloudRunContainer, error)

type CloudRunProbe

type CloudRunProbe struct {
	HttpGet             ProbeHttpGet   `json:"httpGet" yaml:"httpGet"`
	Interval            *time.Duration `json:"interval" yaml:"interval"`
	InitialDelaySeconds *int           `json:"initialDelaySeconds" yaml:"initialDelaySeconds"`
	IntervaSeconds      *int           `json:"intervaSeconds" yaml:"intervaSeconds"`
	FailureThreshold    *int           `json:"failureThreshold" yaml:"failureThreshold"`
	SuccessThreshold    *int           `json:"successThreshold" yaml:"successThreshold"`
	TimeoutSeconds      *int           `json:"timeoutSeconds" yaml:"timeoutSeconds"`
}

type CloudRunScale

type CloudRunScale struct {
	Min int `json:"min" yaml:"min"`
	Max int `json:"max" yaml:"max"`
}

type CloudrunTemplate

type CloudrunTemplate struct {
	KubernetesConfig           `json:",inline" yaml:",inline"`
	docker.RegistryCredentials `json:",inline" yaml:",inline"`
	CaddyResource              *string `json:"caddyResource,omitempty" yaml:"caddyResource,omitempty"` // name of the caddy resource in base stack
	UseSSL                     *bool   `json:"useSSL,omitempty" yaml:"useSSL,omitempty"`               // whether to assume connection must be over https only (default: true)
}

type DeploymentConfig

type DeploymentConfig struct {
	StackConfig      *api.StackConfigCompose `json:"stackConfig" yaml:"stackConfig"`
	Containers       []CloudRunContainer     `json:"containers" yaml:"containers"`
	IngressContainer *CloudRunContainer      `json:"ingressContainer" yaml:"ingressContainer"`
	Scale            *Scale                  `json:"scale" yaml:"replicas"`
	Headers          *Headers                `json:"headers" yaml:"headers"`
	TextVolumes      []SimpleTextVolume      `json:"textVolumes" yaml:"textVolumes"`
	DisruptionBudget *DisruptionBudget       `json:"disruptionBudget" yaml:"disruptionBudget"`
	RollingUpdate    *RollingUpdate          `json:"rollingUpdate" yaml:"rollingUpdate"`
	NodeSelector     map[string]string       `json:"nodeSelector" yaml:"nodeSelector"`
	Affinity         *AffinityRules          `json:"affinity" yaml:"affinity"`
	Tolerations      []Toleration            `json:"tolerations" yaml:"tolerations"`
	VPA              *VPAConfig              `json:"vpa" yaml:"vpa"`                       // Vertical Pod Autoscaler configuration
	ReadinessProbe   *CloudRunProbe          `json:"readinessProbe" yaml:"readinessProbe"` // Global readiness probe configuration
	LivenessProbe    *CloudRunProbe          `json:"livenessProbe" yaml:"livenessProbe"`   // Global liveness probe configuration
}

type DisruptionBudget

type DisruptionBudget struct {
	MaxUnavailable *int `json:"maxUnavailable" yaml:"maxUnavailable"`
	MinAvailable   *int `json:"minAvailable" yaml:"minAvailable"`
}

type Headers

type Headers = map[string]string

func ToHeaders

func ToHeaders(headers *api.Headers) Headers

type HelmChartConfig

type HelmChartConfig struct {
	ValuesMap             HelmValues `json:"values,omitempty" yaml:"values,omitempty" `
	OperatorNamespaceName *string    `json:"operatorNamespace,omitempty" yaml:"operatorNamespace,omitempty"`
	NamespaceName         *string    `json:"namespace,omitempty" yaml:"namespace,omitempty"`
}

func (*HelmChartConfig) Namespace

func (c *HelmChartConfig) Namespace() *string

func (*HelmChartConfig) OperatorNamespace

func (c *HelmChartConfig) OperatorNamespace() *string

func (*HelmChartConfig) Values

func (c *HelmChartConfig) Values() HelmValues

type HelmMongodbOperator

type HelmMongodbOperator struct {
	*KubernetesConfig `json:",inline" yaml:",inline"`
	HelmChartConfig   `json:",inline" yaml:",inline"`
	Version           *string `json:"version,omitempty" yaml:"version,omitempty"`
	Replicas          *int    `json:"replicas,omitempty" yaml:"replicas,omitempty"`
}

type HelmOperatorChart

type HelmOperatorChart interface {
	OperatorNamespace() *string
	Values() HelmValues
}

type HelmPostgresOperator

type HelmPostgresOperator struct {
	*KubernetesConfig `json:",inline" yaml:",inline"`
	HelmChartConfig   `json:",inline" yaml:",inline"`
	VolumeSize        *string  `json:"volumeSize,omitempty" yaml:"volumeSize,omitempty"`
	NumberOfInstances *int     `json:"numberOfInstances,omitempty" yaml:"numberOfInstances,omitempty"`
	Version           *string  `json:"version,omitempty" yaml:"version,omitempty"`
	PgHbaEntries      []string `json:"pg_hba" yaml:"pg_hba"`
	InitSQL           *string  `json:"initSQL,omitempty" yaml:"initSQL,omitempty"`
}

type HelmRabbitmqOperator

type HelmRabbitmqOperator struct {
	*KubernetesConfig `json:",inline" yaml:",inline"`
	HelmChartConfig   `json:",inline" yaml:",inline"`
	Replicas          *int `json:"replicas,omitempty" yaml:"replicas,omitempty"`
}

type HelmRedisOperator

type HelmRedisOperator struct {
	*KubernetesConfig `json:",inline" yaml:",inline"`
	HelmChartConfig   `json:",inline" yaml:",inline"`
}

type HelmValues

type HelmValues map[string]any

type KubeRunInput

type KubeRunInput struct {
	CloudrunTemplate `json:"templateConfig" yaml:"templateConfig"`
	Deployment       DeploymentConfig `json:"deployment" yaml:"deployment"`
}

func (*KubeRunInput) DependsOnResources

func (i *KubeRunInput) DependsOnResources() []api.StackConfigDependencyResource

func (*KubeRunInput) Uses

func (i *KubeRunInput) Uses() []string

type KubernetesConfig

type KubernetesConfig struct {
	Kubeconfig string `json:"kubeconfig" yaml:"kubeconfig"`
}

func (*KubernetesConfig) CredentialsValue

func (r *KubernetesConfig) CredentialsValue() string

func (*KubernetesConfig) ProjectIdValue

func (r *KubernetesConfig) ProjectIdValue() string

func (*KubernetesConfig) ProviderType

func (r *KubernetesConfig) ProviderType() string

type LabelSelector

type LabelSelector struct {
	MatchLabels      map[string]string          `json:"matchLabels" yaml:"matchLabels"`
	MatchExpressions []LabelSelectorRequirement `json:"matchExpressions" yaml:"matchExpressions"`
}

LabelSelector defines a label selector

type LabelSelectorRequirement

type LabelSelectorRequirement struct {
	Key      string   `json:"key" yaml:"key"`
	Operator string   `json:"operator" yaml:"operator"`
	Values   []string `json:"values" yaml:"values"`
}

LabelSelectorRequirement defines a label selector requirement

type NodeAffinity

type NodeAffinity struct {
	RequiredDuringSchedulingIgnoredDuringExecution  *NodeSelector             `json:"requiredDuringSchedulingIgnoredDuringExecution" yaml:"requiredDuringSchedulingIgnoredDuringExecution"`
	PreferredDuringSchedulingIgnoredDuringExecution []PreferredSchedulingTerm `json:"preferredDuringSchedulingIgnoredDuringExecution" yaml:"preferredDuringSchedulingIgnoredDuringExecution"`
}

NodeAffinity defines node affinity rules

type NodeSelector

type NodeSelector struct {
	NodeSelectorTerms []NodeSelectorTerm `json:"nodeSelectorTerms" yaml:"nodeSelectorTerms"`
}

NodeSelector defines node selector requirements

type NodeSelectorRequirement

type NodeSelectorRequirement struct {
	Key      string   `json:"key" yaml:"key"`
	Operator string   `json:"operator" yaml:"operator"`
	Values   []string `json:"values" yaml:"values"`
}

NodeSelectorRequirement defines a node selector requirement

type NodeSelectorTerm

type NodeSelectorTerm struct {
	MatchExpressions []NodeSelectorRequirement `json:"matchExpressions" yaml:"matchExpressions"`
	MatchFields      []NodeSelectorRequirement `json:"matchFields" yaml:"matchFields"`
}

NodeSelectorTerm defines a node selector term

type PersistentVolume

type PersistentVolume struct {
	Name             string   `json:"name" yaml:"name"`
	MountPath        string   `json:"mountPath" yaml:"mountPath"`
	Storage          string   `json:"storage" yaml:"storage"`
	AccessModes      []string `json:"accessModes" yaml:"accessModes"`
	StorageClassName *string  `json:"storageClassName" yaml:"storageClassName"`
}

func ToPersistentVolumes

func ToPersistentVolumes(svc types.ServiceConfig, cfg compose.Config) []PersistentVolume

type PodAffinity

type PodAffinity struct {
	RequiredDuringSchedulingIgnoredDuringExecution  []PodAffinityTerm         `json:"requiredDuringSchedulingIgnoredDuringExecution" yaml:"requiredDuringSchedulingIgnoredDuringExecution"`
	PreferredDuringSchedulingIgnoredDuringExecution []WeightedPodAffinityTerm `json:"preferredDuringSchedulingIgnoredDuringExecution" yaml:"preferredDuringSchedulingIgnoredDuringExecution"`
}

PodAffinity defines pod affinity rules

type PodAffinityTerm

type PodAffinityTerm struct {
	LabelSelector *LabelSelector `json:"labelSelector" yaml:"labelSelector"`
	Namespaces    []string       `json:"namespaces" yaml:"namespaces"`
	TopologyKey   string         `json:"topologyKey" yaml:"topologyKey"`
}

PodAffinityTerm defines a pod affinity term

type PreferredSchedulingTerm

type PreferredSchedulingTerm struct {
	Weight     int32            `json:"weight" yaml:"weight"`
	Preference NodeSelectorTerm `json:"preference" yaml:"preference"`
}

PreferredSchedulingTerm defines a preferred scheduling term

type ProbeHttpGet

type ProbeHttpGet struct {
	Path string `json:"path" yaml:"path"`
	Port int    `json:"port" yaml:"port"`
}

type Resources

type Resources struct {
	Limits   map[string]string `json:"limits" yaml:"limits"`
	Requests map[string]string `json:"requests" yaml:"requests"`
}

func ToResources

func ToResources(cfg *api.StackConfigCompose, svc types.ServiceConfig) (*Resources, error)

type RollingUpdate

type RollingUpdate struct {
	MaxSurge       *int `json:"maxSurge" yaml:"maxSurge"`
	MaxUnavailable *int `json:"maxUnavailable" yaml:"maxUnavailable"`
}

type Scale

type Scale struct {
	Replicas int `json:"replicas" yaml:"replicas"`
}

func ToScale

func ToScale(stack *api.StackConfigCompose) *Scale

type SimpleTextVolume

type SimpleTextVolume struct {
	api.TextVolume `json:",inline" yaml:",inline"`
}

func ToSimpleTextVolumes

func ToSimpleTextVolumes(cfg *api.StackConfigCompose) []SimpleTextVolume

type Toleration

type Toleration struct {
	Key      string `json:"key" yaml:"key"`
	Operator string `json:"operator,omitempty" yaml:"operator,omitempty"` // Equal or Exists
	Value    string `json:"value,omitempty" yaml:"value,omitempty"`
	Effect   string `json:"effect,omitempty" yaml:"effect,omitempty"` // NoSchedule, PreferNoSchedule, NoExecute
}

Toleration represents a Kubernetes toleration for pod scheduling

type VPAConfig

type VPAConfig struct {
	// Enabled controls whether VPA should be created for the deployment
	Enabled bool `json:"enabled" yaml:"enabled"`
	// UpdateMode specifies how VPA should update pods (Off, Initial, Recreation, Auto)
	UpdateMode *string `json:"updateMode" yaml:"updateMode"`
	// MinAllowed specifies minimum allowed resources
	MinAllowed *VPAResourceRequirements `json:"minAllowed" yaml:"minAllowed"`
	// MaxAllowed specifies maximum allowed resources
	MaxAllowed *VPAResourceRequirements `json:"maxAllowed" yaml:"maxAllowed"`
	// ControlledResources specifies which resources VPA should control
	ControlledResources []string `json:"controlledResources" yaml:"controlledResources"`
}

VPAConfig defines Vertical Pod Autoscaler configuration

type VPAResourceRequirements

type VPAResourceRequirements struct {
	CPU    *string `json:"cpu" yaml:"cpu"`
	Memory *string `json:"memory" yaml:"memory"`
}

VPAResourceRequirements defines resource requirements for VPA

type WeightedPodAffinityTerm

type WeightedPodAffinityTerm struct {
	Weight          int32           `json:"weight" yaml:"weight"`
	PodAffinityTerm PodAffinityTerm `json:"podAffinityTerm" yaml:"podAffinityTerm"`
}

WeightedPodAffinityTerm defines a weighted pod affinity term

Jump to

Keyboard shortcuts

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