Skip to content

Commit

Permalink
Get namespace from admission request in pod mutator (kubeflow#430)
Browse files Browse the repository at this point in the history
* Set pod namespace from SERVING_NAMESPACE env

* Get namespace from admission request
  • Loading branch information
yuzisun authored and k8s-ci-robot committed Oct 16, 2019
1 parent bccbd59 commit 4dbc635
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ func (c *CredentialBuilder) CreateSecretVolumeAndEnv(namespace string, serviceAc
err := c.client.Get(context.TODO(), types.NamespacedName{Name: serviceAccountName,
Namespace: namespace}, serviceAccount)
if err != nil {
log.Error(err, "Failed to find service account", "ServiceAccountName", serviceAccountName)
log.Error(err, "Failed to find service account", "ServiceAccountName", serviceAccountName,
"Namespace", namespace)
return nil
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/webhook/admission/pod/mutator.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ func (mutator *Mutator) Handle(ctx context.Context, req types.Request) types.Res
return admission.ErrorResponse(http.StatusInternalServerError, err)
}

// For some reason pod namespace is always empty when coming to pod mutator, need to set from admission request
pod.Namespace = req.AdmissionRequest.Namespace

if err := mutator.mutate(pod, configMap); err != nil {
return admission.ErrorResponse(http.StatusInternalServerError, err)
}
Expand Down
1 change: 0 additions & 1 deletion pkg/webhook/admission/pod/storage_initializer_injector.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ func (mi *StorageInitializerInjector) InjectStorageInitializer(pod *v1.Pod) erro
ReadOnly: true,
}
userContainer.VolumeMounts = append(userContainer.VolumeMounts, sharedVolumeReadMount)

// Change the CustomSpecStorageUri env variable value to the default model path if present
for index, envVar := range userContainer.Env {
if envVar.Name == constants.CustomSpecStorageUriEnvVarKey && envVar.Value != "" {
Expand Down

0 comments on commit 4dbc635

Please sign in to comment.