| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- /*
- Copyright 2026 LocoStack.
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
- package litellm
- import (
- "fmt"
- "github.com/LocoStack/loco-operator/api/v1alpha1"
- corev1 "k8s.io/api/core/v1"
- )
- const (
- LITELLM_MASTER_KEY_ENV_NAME = "MASTER_KEY"
- LITELLM_AUTH_SECRET_KEY = "key"
- LITELLM_CONFIG_KEY = "config.yaml"
- // MCPAuthHeaderName is the header litellm's MCP gateway expects the caller's
- // key in, per https://docs.litellm.ai/docs/mcp_control#method-1-url-based-namespacing.
- MCPAuthHeaderName = "x-litellm-api-key"
- )
- // MasterKeySecretName returns the name of the Secret holding a gateway component's
- // litellm master key, as created by ReconcileKey(ctx, "litellm", LITELLM_AUTH_SECRET_KEY, ...).
- func MasterKeySecretName(gatewayComponentName string) string {
- return gatewayComponentName + "-litellm"
- }
- var LiteLLMTemplate = v1alpha1.Template{
- Name: "litellm",
- Spec: v1alpha1.TemplateSpec{
- Runtime: v1alpha1.RuntimeSpec{
- Name: "litellm",
- Image: "ghcr.io/berriai/litellm:v1.87.1",
- Command: []string{"litellm"},
- Args: []string{"--port", "$(spec.runtime.port)"},
- Env: []corev1.EnvVar{
- {Name: "CONFIG_FILE_PATH", Value: fmt.Sprintf("/etc/litellm/%s", LITELLM_CONFIG_KEY)},
- {Name: LITELLM_MASTER_KEY_ENV_NAME, ValueFrom: &corev1.EnvVarSource{
- SecretKeyRef: &corev1.SecretKeySelector{
- LocalObjectReference: corev1.LocalObjectReference{Name: "$(metadata.name)-litellm"},
- Key: LITELLM_AUTH_SECRET_KEY,
- },
- }},
- },
- VolumeMounts: []corev1.VolumeMount{
- {
- Name: "config",
- MountPath: "/etc/litellm",
- ReadOnly: true,
- },
- },
- Port: 4000,
- },
- Volumes: []corev1.Volume{
- {
- Name: "config",
- VolumeSource: corev1.VolumeSource{
- ConfigMap: &corev1.ConfigMapVolumeSource{
- LocalObjectReference: corev1.LocalObjectReference{Name: "$(metadata.name)-config"},
- },
- },
- },
- },
- },
- }
|