Skip to content

Commit

Permalink
Fixes #3086 - amd64 images always pulled irrespective of underlying s…
Browse files Browse the repository at this point in the history
…ystem architecture
  • Loading branch information
bahetiamit committed Oct 7, 2020
1 parent 4186fdb commit 5ec8000
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/pod/entrypoint_lookup_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ package pod

import (
"fmt"

"github.com/google/go-containerregistry/pkg/authn"
"github.com/google/go-containerregistry/pkg/authn/k8schain"
"github.com/google/go-containerregistry/pkg/name"
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/remote"
lru "github.com/hashicorp/golang-lru"
"k8s.io/client-go/kubernetes"
"runtime"
)

const cacheSize = 1024
Expand Down Expand Up @@ -67,7 +67,13 @@ func (e *entrypointCache) Get(ref name.Reference, namespace, serviceAccountName
return nil, fmt.Errorf("error creating k8schain: %v", err)
}
mkc := authn.NewMultiKeychain(kc)
img, err := remote.Image(ref, remote.WithAuthFromKeychain(mkc))
//By default go-containerregistry pulls amd64 images.
//Setting correct image pull architecture based on the underlying platform
var pf = v1.Platform{
Architecture: runtime.GOARCH,
OS: runtime.GOOS,
}
img, err := remote.Image(ref, remote.WithAuthFromKeychain(mkc), remote.WithPlatform(pf))
if err != nil {
return nil, fmt.Errorf("error getting image manifest: %v", err)
}
Expand Down

0 comments on commit 5ec8000

Please sign in to comment.