Skip to content

Commit 7f2a049

Browse files
authored
feat: support remote storage URI injection for serving runtimes (kserve#4492)
Signed-off-by: de0725 <debosora.52901@gmail.com>
1 parent 4413753 commit 7f2a049

File tree

3 files changed

+218
-0
lines changed

3 files changed

+218
-0
lines changed

pkg/constants/constants.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ var (
7272
ModelConfigFileName = "models.json"
7373
)
7474

75+
// Remote Storage URI
76+
const (
77+
RemoteStorageEnvVarName = "REMOTE_STORAGE_URI"
78+
)
79+
7580
// Model agent Constants
7681
const (
7782
AgentContainerName = "agent"

pkg/webhook/admission/pod/storage_initializer_injector.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
"github.com/kserve/kserve/pkg/constants"
3737
"github.com/kserve/kserve/pkg/credentials"
3838
"github.com/kserve/kserve/pkg/credentials/s3"
39+
"github.com/kserve/kserve/pkg/utils"
3940
)
4041

4142
const (
@@ -54,6 +55,7 @@ const (
5455
ModelInitModeEnv = "MODEL_INIT_MODE"
5556
CpuModelcarDefault = "10m"
5657
MemoryModelcarDefault = "15Mi"
58+
RemoteStorageEnvVarName = "REMOTE_STORAGE_URI"
5759
)
5860

5961
type StorageInitializerConfig struct {
@@ -245,6 +247,16 @@ func (mi *StorageInitializerInjector) InjectStorageInitializer(pod *corev1.Pod)
245247
}
246248
}
247249

250+
if _, exists := utils.GetEnvVarValue(userContainer.Env, RemoteStorageEnvVarName); !exists {
251+
addOrReplaceEnv(userContainer, RemoteStorageEnvVarName, srcURI)
252+
}
253+
254+
if transformerContainer != nil {
255+
if _, exists := utils.GetEnvVarValue(transformerContainer.Env, RemoteStorageEnvVarName); !exists {
256+
addOrReplaceEnv(transformerContainer, RemoteStorageEnvVarName, srcURI)
257+
}
258+
}
259+
248260
// Mount pvc directly if local model label exists
249261
if modelName, ok := pod.ObjectMeta.Labels[constants.LocalModelLabel]; ok {
250262
subPath, _ := strings.CutPrefix(srcURI, pod.ObjectMeta.Annotations[constants.LocalModelSourceUriAnnotationKey])

0 commit comments

Comments
 (0)