Documentation
¶
Overview ¶
Package registryapi provides deployment management for the registry API component.
Package registryapi provides deployment management for the registry API component.
Index ¶
- Constants
- func BuildRegistryAPIContainer(image string) corev1.Container
- func GetPGPassSecretKey() string
- func GetServiceAccountName(mcpRegistry *mcpv1alpha1.MCPRegistry) string
- func MergePodTemplateSpecs(defaultPTS, userPTS *corev1.PodTemplateSpec) corev1.PodTemplateSpec
- func ParsePodTemplateSpec(raw *runtime.RawExtension) (*corev1.PodTemplateSpec, error)
- func ValidatePodTemplateSpec(raw *runtime.RawExtension) error
- type Error
- type Manager
- type PodTemplateSpecBuilder
- type PodTemplateSpecOption
- func WithAnnotations(annotations map[string]string) PodTemplateSpecOption
- func WithContainer(container corev1.Container) PodTemplateSpecOption
- func WithContainerArgs(containerName string, args []string) PodTemplateSpecOption
- func WithEnvVar(containerName string, envVar corev1.EnvVar) PodTemplateSpecOption
- func WithGitAuthMount(containerName string, secretRef corev1.SecretKeySelector) PodTemplateSpecOption
- func WithInitContainer(container corev1.Container) PodTemplateSpecOption
- func WithLabels(labels map[string]string) PodTemplateSpecOption
- func WithPGPassMount(containerName, secretName string) PodTemplateSpecOption
- func WithPGPassSecretRefMount(containerName string, secretRef corev1.SecretKeySelector) PodTemplateSpecOption
- func WithRegistryServerConfigMount(containerName, configMapName string) PodTemplateSpecOption
- func WithRegistrySourceMounts(containerName string, sources []mcpv1alpha1.MCPRegistrySourceConfig) PodTemplateSpecOption
- func WithRegistryStorageMount(containerName string) PodTemplateSpecOption
- func WithServiceAccountName(name string) PodTemplateSpecOption
- func WithVolume(volume corev1.Volume) PodTemplateSpecOption
- func WithVolumeMount(containerName string, mount corev1.VolumeMount) PodTemplateSpecOption
Constants ¶
const ( // RegistryAPIContainerName is the name of the registry-api container in deployments RegistryAPIContainerName = "registry-api" // 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 // PGPassSecretVolumeName is the name of the volume for the pgpass secret PGPassSecretVolumeName = "pgpass-secret" // PGPassVolumeName is the name of the emptyDir volume for the prepared pgpass file PGPassVolumeName = "pgpass" // PGPassInitContainerName is the name of the init container that sets up the pgpass file PGPassInitContainerName = "setup-pgpass" // PGPassAppUserMountPath is the path where the pgpass file is mounted in the app container // nolint:gosec // G101: This is a file path, not a credential PGPassAppUserMountPath = "/home/appuser/.pgpass" )
Variables ¶
This section is empty.
Functions ¶
func BuildRegistryAPIContainer ¶ added in v0.6.8
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 Error ¶ added in v0.17.0
Error represents a structured error with condition information for operator components
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) *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
// GetReadyReplicas returns the number of ready replicas for the registry API deployment
GetReadyReplicas(ctx context.Context, mcpRegistry *mcpv1alpha1.MCPRegistry) int32
// GetAPIStatus returns the readiness state and ready replica count from a single Deployment fetch
GetAPIStatus(ctx context.Context, mcpRegistry *mcpv1alpha1.MCPRegistry) (ready bool, readyReplicas int32)
}
Manager handles registry API deployment operations
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
func (b *PodTemplateSpecBuilder) Apply(opts ...PodTemplateSpecOption) *PodTemplateSpecBuilder
Apply applies the given options to build up the default PodTemplateSpec.
func (*PodTemplateSpecBuilder) Build ¶ added in v0.6.8
func (b *PodTemplateSpecBuilder) Build() corev1.PodTemplateSpec
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 WithGitAuthMount ¶ added in v0.9.2
func WithGitAuthMount(containerName string, secretRef corev1.SecretKeySelector) PodTemplateSpecOption
WithGitAuthMount configures secret mounting for Git authentication. Unlike pgpass, Git credentials don't require special file permissions (0600), so no init container is needed - the secret is mounted directly.
This function adds: 1. A volume from the secret containing the password/token 2. A volume mount to the specified container at /secrets/{secretName}/
The mount path matches what buildGitPasswordFilePath() generates in the config, ensuring the registry server can find the password file at the expected location.
Volume naming uses the pattern "git-auth-{secretName}". If multiple registries reference the same secret, the volume and mount are idempotent - only one volume will be created due to the idempotency check in WithVolume.
Parameters:
- containerName: The name of the container to add the mount to
- secretRef: The secret key selector referencing the password secret
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 using an operator-generated secret. It constructs the secret volume from the given secret name and operator-defined key, then delegates to withPGPassMountFromVolume.
func WithPGPassSecretRefMount ¶ added in v0.17.0
func WithPGPassSecretRefMount(containerName string, secretRef corev1.SecretKeySelector) PodTemplateSpecOption
WithPGPassSecretRefMount configures pgpass secret mounting for PostgreSQL authentication using a user-provided SecretKeySelector. If the secret reference is incomplete (empty name or key), a no-op option is returned. Otherwise it constructs the secret volume from the selector and delegates to withPGPassMountFromVolume.
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, sources []mcpv1alpha1.MCPRegistrySourceConfig) PodTemplateSpecOption
WithRegistrySourceMounts creates volumes and mounts for all registry sources. Each ConfigMap source gets its own volume and mount point at /config/registry/{sourceName}/.
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.