kubernetes

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package kubernetes provides Go structs for Kubernetes/Helm deployment configuration. These structs provide a reusable base for agent-based Helm charts with validation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentConfig

type AgentConfig struct {
	Enabled      bool              `yaml:"enabled"`
	ReplicaCount int               `yaml:"replicaCount" validate:"omitempty,min=0,max=100"`
	Image        AgentImageConfig  `yaml:"image"`
	Service      ServiceConfig     `yaml:"service"`
	Resources    ResourcesConfig   `yaml:"resources"`
	Autoscaling  AutoscalingConfig `yaml:"autoscaling"`
	PDB          PDBConfig         `yaml:"pdb"`
	NodeSelector map[string]string `yaml:"nodeSelector"`
	Tolerations  []Toleration      `yaml:"tolerations"`
	Affinity     map[string]any    `yaml:"affinity"`
	Env          []EnvVar          `yaml:"env"`
}

AgentConfig defines configuration for an individual agent.

type AgentImageConfig

type AgentImageConfig struct {
	Repository string `yaml:"repository"`
	Tag        string `yaml:"tag"`
}

AgentImageConfig defines agent-specific image settings.

type AutoscalingBehavior

type AutoscalingBehavior struct {
	ScaleDown *ScalingRules `yaml:"scaleDown,omitempty"`
	ScaleUp   *ScalingRules `yaml:"scaleUp,omitempty"`
}

AutoscalingBehavior defines scaling behavior policies.

type AutoscalingConfig

type AutoscalingConfig struct {
	Enabled                           bool                 `yaml:"enabled"`
	MinReplicas                       int                  `yaml:"minReplicas" validate:"omitempty,min=1"`
	MaxReplicas                       int                  `yaml:"maxReplicas" validate:"omitempty,min=1,max=1000"`
	TargetCPUUtilizationPercentage    int                  `yaml:"targetCPUUtilizationPercentage" validate:"omitempty,min=1,max=100"`
	TargetMemoryUtilizationPercentage int                  `yaml:"targetMemoryUtilizationPercentage" validate:"omitempty,min=1,max=100"`
	Behavior                          *AutoscalingBehavior `yaml:"behavior,omitempty"`
}

AutoscalingConfig defines Horizontal Pod Autoscaler settings.

type Capabilities

type Capabilities struct {
	Add  []string `yaml:"add"`
	Drop []string `yaml:"drop"`
}

Capabilities defines Linux capabilities settings.

type ConfigMapKeyRef

type ConfigMapKeyRef struct {
	Name string `yaml:"name" validate:"required"`
	Key  string `yaml:"key" validate:"required"`
}

ConfigMapKeyRef references a key in a configmap.

type EnvVar

type EnvVar struct {
	Name      string        `yaml:"name" validate:"required"`
	Value     string        `yaml:"value"`
	ValueFrom *EnvVarSource `yaml:"valueFrom,omitempty"`
}

EnvVar defines an environment variable.

type EnvVarSource

type EnvVarSource struct {
	SecretKeyRef    *SecretKeyRef    `yaml:"secretKeyRef,omitempty"`
	ConfigMapKeyRef *ConfigMapKeyRef `yaml:"configMapKeyRef,omitempty"`
}

EnvVarSource defines the source of an environment variable value.

type GlobalConfig

type GlobalConfig struct {
	Image            ImageConfig       `yaml:"image" validate:"required"`
	ImagePullSecrets []ImagePullSecret `yaml:"imagePullSecrets"`
}

GlobalConfig contains global settings for all agents.

type ImageConfig

type ImageConfig struct {
	Registry   string `yaml:"registry"`
	Repository string `yaml:"repository"`
	PullPolicy string `yaml:"pullPolicy" validate:"omitempty,oneof=Always IfNotPresent Never"`
	Tag        string `yaml:"tag" validate:"required"`
}

ImageConfig defines container image settings.

type ImagePullSecret

type ImagePullSecret struct {
	Name string `yaml:"name" validate:"required"`
}

ImagePullSecret references a Kubernetes secret for pulling images.

type IngressConfig

type IngressConfig struct {
	Enabled     bool              `yaml:"enabled"`
	ClassName   string            `yaml:"className"`
	Annotations map[string]string `yaml:"annotations"`
	Host        string            `yaml:"host" validate:"omitempty,hostname|fqdn"`
	TLS         []IngressTLS      `yaml:"tls"`
}

IngressConfig defines Kubernetes ingress settings.

type IngressTLS

type IngressTLS struct {
	SecretName string   `yaml:"secretName" validate:"required"`
	Hosts      []string `yaml:"hosts" validate:"required,min=1,dive,hostname|fqdn"`
}

IngressTLS defines TLS configuration for ingress.

type LLMConfig

type LLMConfig struct {
	Provider    string `yaml:"provider" validate:"required,oneof=gemini claude openai ollama xai"`
	BaseURL     string `yaml:"baseUrl"`
	GeminiModel string `yaml:"geminiModel"`
	ClaudeModel string `yaml:"claudeModel"`
	OpenAIModel string `yaml:"openaiModel"`
	XAIModel    string `yaml:"xaiModel"`
	OllamaModel string `yaml:"ollamaModel"`
	OllamaURL   string `yaml:"ollamaUrl" validate:"omitempty,url"`
}

LLMConfig contains LLM provider configuration.

type NamespaceConfig

type NamespaceConfig struct {
	Create bool   `yaml:"create"`
	Name   string `yaml:"name" validate:"required,min=1,max=63"`
}

NamespaceConfig defines Kubernetes namespace settings.

type PDBConfig

type PDBConfig struct {
	Enabled        bool   `yaml:"enabled"`
	MinAvailable   string `yaml:"minAvailable,omitempty"`
	MaxUnavailable string `yaml:"maxUnavailable,omitempty"`
}

PDBConfig defines Pod Disruption Budget settings.

type PodSecurityContext

type PodSecurityContext struct {
	RunAsNonRoot bool  `yaml:"runAsNonRoot"`
	RunAsUser    int64 `yaml:"runAsUser" validate:"omitempty,min=0"`
	RunAsGroup   int64 `yaml:"runAsGroup" validate:"omitempty,min=0"`
	FSGroup      int64 `yaml:"fsGroup" validate:"omitempty,min=0"`
}

PodSecurityContext defines pod-level security settings.

type ResourceSpec

type ResourceSpec struct {
	CPU    string `yaml:"cpu" validate:"omitempty,k8s_resource_quantity"`
	Memory string `yaml:"memory" validate:"omitempty,k8s_resource_quantity"`
}

ResourceSpec defines CPU and memory specifications.

type ResourcesConfig

type ResourcesConfig struct {
	Requests ResourceSpec `yaml:"requests"`
	Limits   ResourceSpec `yaml:"limits"`
}

ResourcesConfig defines Kubernetes resource requests and limits.

type ScalingPolicy

type ScalingPolicy struct {
	Type          string `yaml:"type" validate:"required,oneof=Pods Percent"`
	Value         int    `yaml:"value" validate:"required,min=1"`
	PeriodSeconds int    `yaml:"periodSeconds" validate:"required,min=1,max=1800"`
}

ScalingPolicy defines a single scaling policy.

type ScalingRules

type ScalingRules struct {
	StabilizationWindowSeconds int             `yaml:"stabilizationWindowSeconds,omitempty" validate:"omitempty,min=0,max=3600"`
	Policies                   []ScalingPolicy `yaml:"policies,omitempty"`
	SelectPolicy               string          `yaml:"selectPolicy,omitempty" validate:"omitempty,oneof=Max Min Disabled"`
}

ScalingRules defines scaling stabilization and policies.

type SearchConfig

type SearchConfig struct {
	Provider string `yaml:"provider" validate:"omitempty,oneof=serper serpapi"`
}

SearchConfig contains search provider configuration.

type SecretKeyRef

type SecretKeyRef struct {
	Name string `yaml:"name" validate:"required"`
	Key  string `yaml:"key" validate:"required"`
}

SecretKeyRef references a key in a secret.

type SecretsConfig

type SecretsConfig struct {
	Create          bool   `yaml:"create"`
	GeminiAPIKey    string `yaml:"geminiApiKey"`
	ClaudeAPIKey    string `yaml:"claudeApiKey"`
	OpenAIAPIKey    string `yaml:"openaiApiKey"`
	XAIAPIKey       string `yaml:"xaiApiKey"`
	AnthropicAPIKey string `yaml:"anthropicApiKey"`
	SerperAPIKey    string `yaml:"serperApiKey"`
	SerpAPIKey      string `yaml:"serpApiKey"`
}

SecretsConfig defines API key secrets.

type SecurityContext

type SecurityContext struct {
	AllowPrivilegeEscalation bool         `yaml:"allowPrivilegeEscalation"`
	ReadOnlyRootFilesystem   bool         `yaml:"readOnlyRootFilesystem"`
	Capabilities             Capabilities `yaml:"capabilities"`
}

SecurityContext defines container-level security settings.

type ServiceAccountConfig

type ServiceAccountConfig struct {
	Create      bool              `yaml:"create"`
	Annotations map[string]string `yaml:"annotations"`
	Name        string            `yaml:"name"`
}

ServiceAccountConfig defines Kubernetes service account settings.

type ServiceConfig

type ServiceConfig struct {
	Type    string `yaml:"type" validate:"omitempty,oneof=ClusterIP NodePort LoadBalancer"`
	Port    int    `yaml:"port" validate:"omitempty,min=1,max=65535"`
	A2APort int    `yaml:"a2aPort" validate:"omitempty,min=1,max=65535"`
}

ServiceConfig defines Kubernetes service settings.

type Toleration

type Toleration struct {
	Key               string `yaml:"key"`
	Operator          string `yaml:"operator" validate:"omitempty,oneof=Exists Equal"`
	Value             string `yaml:"value"`
	Effect            string `yaml:"effect" validate:"omitempty,oneof=NoSchedule PreferNoSchedule NoExecute"`
	TolerationSeconds *int64 `yaml:"tolerationSeconds"`
}

Toleration defines a Kubernetes pod toleration.

type Validator

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

Validator provides validation for Helm values.

func NewValidator

func NewValidator() *Validator

NewValidator creates a new Validator with custom validation rules.

func (*Validator) Validate

func (v *Validator) Validate(values *Values) error

Validate validates the given Values struct.

func (*Validator) ValidateWithContext

func (v *Validator) ValidateWithContext(values *Values) []error

ValidateWithContext performs validation with additional business logic checks.

type Values

type Values struct {
	Global             GlobalConfig           `yaml:"global" validate:"required"`
	Namespace          NamespaceConfig        `yaml:"namespace" validate:"required"`
	LLM                LLMConfig              `yaml:"llm" validate:"required"`
	Search             SearchConfig           `yaml:"search"`
	Secrets            SecretsConfig          `yaml:"secrets"`
	Agents             map[string]AgentConfig `yaml:"agents"`
	Ingress            IngressConfig          `yaml:"ingress"`
	ServiceAccount     ServiceAccountConfig   `yaml:"serviceAccount"`
	PodSecurityContext PodSecurityContext     `yaml:"podSecurityContext"`
	SecurityContext    SecurityContext        `yaml:"securityContext"`
	VaultGuard         VaultGuardConfig       `yaml:"vaultguard"`
}

Values represents the complete Helm chart values structure for an agent deployment.

func LoadAndMerge

func LoadAndMerge(basePath, overlayPath string) (*Values, error)

LoadAndMerge loads a base values file and merges it with an overlay file.

func LoadAndValidate

func LoadAndValidate(path string) (*Values, []error)

LoadAndValidate loads a values file and validates it.

func LoadValuesFile

func LoadValuesFile(path string) (*Values, error)

LoadValuesFile loads and parses a values YAML file.

func ParseValues

func ParseValues(data []byte) (*Values, error)

ParseValues parses YAML data into a Values struct.

type VaultGuardConfig

type VaultGuardConfig struct {
	Enabled           bool     `yaml:"enabled"`
	MinSecurityScore  int      `yaml:"minSecurityScore" validate:"omitempty,min=0,max=100"`
	RequireEncryption bool     `yaml:"requireEncryption"`
	RequireIAM        bool     `yaml:"requireIam"`
	DeniedNamespaces  []string `yaml:"deniedNamespaces"`
}

VaultGuardConfig defines VaultGuard security settings.

Jump to

Keyboard shortcuts

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