registryapi

package
v0.6.14 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package registryapi provides deployment management for the registry API component.

Package registryapi provides deployment management for the registry API component.

Index

Constants

View Source
const (

	// RegistryAPIPort is the port number used by the registry API container
	RegistryAPIPort = 8080
	// RegistryAPIPortName is the name assigned to the registry API port
	RegistryAPIPortName = "http"

	// DefaultCPURequest is the default CPU request for the registry API container
	DefaultCPURequest = "100m"
	// DefaultMemoryRequest is the default memory request for the registry API container
	DefaultMemoryRequest = "128Mi"
	// DefaultCPULimit is the default CPU limit for the registry API container
	DefaultCPULimit = "500m"
	// DefaultMemoryLimit is the default memory limit for the registry API container
	DefaultMemoryLimit = "512Mi"

	// HealthCheckPath is the HTTP path for liveness probe checks
	HealthCheckPath = "/health"
	// ReadinessCheckPath is the HTTP path for readiness probe checks
	ReadinessCheckPath = "/readiness"
	// LivenessInitialDelay is the initial delay in seconds for liveness probes
	LivenessInitialDelay = 30
	// LivenessPeriod is the period in seconds for liveness probe checks
	LivenessPeriod = 10
	// ReadinessInitialDelay is the initial delay in seconds for readiness probes
	ReadinessInitialDelay = 5
	// ReadinessPeriod is the period in seconds for readiness probe checks
	ReadinessPeriod = 5

	// RegistryDataVolumeName is the name of the volume used for registry data
	RegistryDataVolumeName = "registry-data"

	// RegistryServerConfigVolumeName is the name of the volume used for registry server config
	RegistryServerConfigVolumeName = "registry-server-config"

	// RegistryDataMountPath is the mount path for registry data in containers
	RegistryDataMountPath = "/data/registry"

	// ServeCommand is the command used to start the registry API server
	ServeCommand = "serve"

	// DefaultReplicas is the default number of replicas for the registry API deployment
	DefaultReplicas = 1
)

Variables

This section is empty.

Functions

func BuildRegistryAPIContainer added in v0.6.8

func BuildRegistryAPIContainer(image string) corev1.Container

BuildRegistryAPIContainer creates the registry-api container with default configuration.

func GetPGPassSecretKey added in v0.6.14

func GetPGPassSecretKey() string

GetPGPassSecretKey returns the key name used for the pgpass file content in secrets

func GetServiceAccountName added in v0.6.10

func GetServiceAccountName(mcpRegistry *mcpv1alpha1.MCPRegistry) string

GetServiceAccountName returns the service account name for a given MCPRegistry. The name follows the pattern: {registry-name}-registry-api

func MergePodTemplateSpecs added in v0.6.9

func MergePodTemplateSpecs(defaultPTS, userPTS *corev1.PodTemplateSpec) corev1.PodTemplateSpec

MergePodTemplateSpecs merges a default PodTemplateSpec with a user-provided one. User-provided values take precedence over defaults. This allows users to customize infrastructure concerns while ensuring sensible defaults are applied where values are not specified.

The merge strategy starts with the user's PodTemplateSpec and fills in defaults only where the user hasn't specified values. This means any field the user sets (affinity, tolerations, nodeSelector, etc.) is automatically preserved.

Merge behavior:

  • Labels/Annotations: Merged, with defaults added for missing keys
  • ServiceAccountName: Default only if user hasn't specified
  • Containers: Merged by name - defaults fill in missing container fields
  • Volumes: Merged by name - defaults added only if not present
  • All other PodSpec fields: User values preserved as-is

func ParsePodTemplateSpec added in v0.6.9

func ParsePodTemplateSpec(raw *runtime.RawExtension) (*corev1.PodTemplateSpec, error)

ParsePodTemplateSpec parses a runtime.RawExtension into a PodTemplateSpec. Returns nil if the raw extension is nil or empty. Returns an error if the raw extension contains invalid PodTemplateSpec data.

func ValidatePodTemplateSpec added in v0.6.9

func ValidatePodTemplateSpec(raw *runtime.RawExtension) error

ValidatePodTemplateSpec validates a runtime.RawExtension contains valid PodTemplateSpec data. Returns nil if the raw extension is nil, empty, or contains valid data. Returns an error if the raw extension contains invalid PodTemplateSpec data.

Types

type Manager

type Manager interface {
	// ReconcileAPIService orchestrates the deployment, service creation, and readiness checking for the registry API
	ReconcileAPIService(ctx context.Context, mcpRegistry *mcpv1alpha1.MCPRegistry) *mcpregistrystatus.Error

	// CheckAPIReadiness verifies that the deployed registry-API Deployment is ready
	CheckAPIReadiness(ctx context.Context, deployment *appsv1.Deployment) bool

	// IsAPIReady checks if the registry API deployment is ready and serving requests
	IsAPIReady(ctx context.Context, mcpRegistry *mcpv1alpha1.MCPRegistry) bool
}

Manager handles registry API deployment operations

func NewManager

func NewManager(
	k8sClient client.Client,
	scheme *runtime.Scheme,
) Manager

NewManager creates a new registry API manager

type PodTemplateSpecBuilder added in v0.6.8

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

PodTemplateSpecBuilder builds a PodTemplateSpec using the functional options pattern. When created with NewPodTemplateSpecBuilderFrom, the builder stores the user's template and applies options as defaults. Build() merges them with user values taking precedence.

func NewPodTemplateSpecBuilder added in v0.6.8

func NewPodTemplateSpecBuilder() *PodTemplateSpecBuilder

NewPodTemplateSpecBuilder creates a new PodTemplateSpecBuilder with an empty template.

func NewPodTemplateSpecBuilderFrom added in v0.6.9

func NewPodTemplateSpecBuilderFrom(userTemplate *corev1.PodTemplateSpec) *PodTemplateSpecBuilder

NewPodTemplateSpecBuilderFrom creates a new PodTemplateSpecBuilder with a user-provided template. The user template is deep-copied to avoid mutating the original. Options applied via Apply() act as defaults - Build() will merge them with user values, where user values take precedence over defaults.

func (*PodTemplateSpecBuilder) Apply added in v0.6.8

Apply applies the given options to build up the default PodTemplateSpec.

func (*PodTemplateSpecBuilder) Build added in v0.6.8

Build returns the final PodTemplateSpec. If a user template was provided, merges defaults with user values (user takes precedence).

type PodTemplateSpecOption added in v0.6.8

type PodTemplateSpecOption func(*corev1.PodTemplateSpec)

PodTemplateSpecOption is a functional option for configuring a PodTemplateSpec.

func WithAnnotations added in v0.6.8

func WithAnnotations(annotations map[string]string) PodTemplateSpecOption

WithAnnotations sets the annotations on the PodTemplateSpec.

func WithContainer added in v0.6.8

func WithContainer(container corev1.Container) PodTemplateSpecOption

WithContainer adds a container to the PodSpec.

func WithContainerArgs added in v0.6.8

func WithContainerArgs(containerName string, args []string) PodTemplateSpecOption

WithContainerArgs sets the args for a specific container by name. This replaces any existing args for the container.

func WithEnvVar added in v0.6.14

func WithEnvVar(containerName string, envVar corev1.EnvVar) PodTemplateSpecOption

WithEnvVar adds an environment variable to a specific container by name.

func WithInitContainer added in v0.6.14

func WithInitContainer(container corev1.Container) PodTemplateSpecOption

WithInitContainer adds an init container to the PodSpec. If an init container with the same name already exists, it is replaced for idempotency.

func WithLabels added in v0.6.8

func WithLabels(labels map[string]string) PodTemplateSpecOption

WithLabels sets the labels on the PodTemplateSpec.

func WithPGPassMount added in v0.6.14

func WithPGPassMount(containerName, secretName string) PodTemplateSpecOption

WithPGPassMount configures the pgpass secret mounting for PostgreSQL authentication. Kubernetes secret volumes don't allow changing file permissions after mounting, so this function uses an init container to copy the file and set proper permissions.

This function adds: 1. A volume from the secret containing the pgpass file (mounted in init container) 2. An emptyDir volume for the prepared pgpass file (mounted in app container) 3. An init container that copies the file and sets permissions (600) and ownership (65532:65532) 4. A volume mount in the registry-api container for the pgpass file from the emptyDir 5. The PGPASSFILE environment variable pointing to the mounted file

func WithRegistryServerConfigMount added in v0.6.8

func WithRegistryServerConfigMount(containerName, configMapName string) PodTemplateSpecOption

WithRegistryServerConfigMount creates a volume and mount for the registry server config. This adds both the ConfigMap volume and the corresponding volume mount to the specified container.

func WithRegistrySourceMounts added in v0.6.8

func WithRegistrySourceMounts(containerName string, registries []mcpv1alpha1.MCPRegistryConfig) PodTemplateSpecOption

WithRegistrySourceMounts creates volumes and mounts for all registry sources (ConfigMap and PVC). Each registry source (ConfigMap or PVC) gets its own volume and mount point at /config/registry/{registryName}/. Multiple registries can share the same PVC by mounting it at different paths.

func WithRegistryStorageMount added in v0.6.8

func WithRegistryStorageMount(containerName string) PodTemplateSpecOption

WithRegistryStorageMount creates an emptyDir volume and mount for registry storage. This adds both the emptyDir volume and the corresponding volume mount to the specified container.

func WithServiceAccountName added in v0.6.8

func WithServiceAccountName(name string) PodTemplateSpecOption

WithServiceAccountName sets the service account name for the pod.

func WithVolume added in v0.6.8

func WithVolume(volume corev1.Volume) PodTemplateSpecOption

WithVolume adds a volume to the PodSpec.

func WithVolumeMount added in v0.6.8

func WithVolumeMount(containerName string, mount corev1.VolumeMount) PodTemplateSpecOption

WithVolumeMount adds a volume mount to a specific container by name.

Directories

Path Synopsis
Package config provides management for the registry server configuration
Package config provides management for the registry server configuration
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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