GoogleContainerTools / kaniko

Build Container Images In Kubernetes
Apache License 2.0
14.67k stars 1.42k forks source link

Kaniko doesnt support Variant label for images #992

Open PhoenixMage opened 4 years ago

PhoenixMage commented 4 years ago

Actual behavior When using kaniko on an armv7 instance kaniko seems to use the armhf architecture. If I use docker build then armv7 is correctly used.

Expected behavior Kaniko should use the armv7 architecture.

To Reproduce /kaniko/executor -f Dockerfile --no-push gives armhf docker build gives armv7

Additional Information

PhoenixMage commented 4 years ago

Seems runtime.GOARM doesnt exist, goarm is a private symbol which you can access using "unsafe"

My thoughts were to set a symbol at compile time using the linker but I lack the skills to implement that.

tejal29 commented 4 years ago

We did merge a #980 which prefers platform you are currently running on. I tried adding Variant to goarm, however i got this error

import (
  _ "unsafe"
)

var (
    goarm uint8
)
func currentPlatform() v1.Platform {
    return v1.Platform{
        OS:           runtime.GOOS,
        Architecture: runtime.GOARCH,
+       Variant: string(goarm),
    }
}

However, i got this error so not sure if adding the Variant is the right way.

/ # /kaniko/executor -f dockerfiles/Dockerfile_test1 --context=dir:///workspace --destination=gcr.io/tejal-test/test --tarPath=image.tar
INFO[0000] Resolved base name ubuntu:latest to ubuntu:latest 
INFO[0000] Using dockerignore file: /workspace/.dockerignore 
INFO[0000] Resolved base name ubuntu:latest to ubuntu:latest 
INFO[0000] Retrieving image manifest ubuntu:latest      
ERRO[0001] Error while retrieving image from cache: ubuntu:latest no child with platform amd64/linux in index index.docker.io/library/ubuntu:latest 
INFO[0001] Retrieving image manifest ubuntu:latest      
error building image: no child with platform amd64/linux in index index.docker.io/library/ubuntu:latest
tejal29 commented 4 years ago

Forgot to mention, I modified the Makefile to retrieve GOARM from the current platform i am building on. However it is empty

tejaldesai@@kaniko (507)$ make && docker cp /usr/local/google/home/tejaldesai/workspace/kaniko/out/executor c765d295c9cb:/kaniko
GOARCH=amd64 GOARM= GOOS=linux CGO_ENABLED=0 go build -ldflags '-extldflags "-static" -X github.com/GoogleContainerTools/kaniko/pkg/version.version=v0.16.0 -w -s  ' -o out/executor github.com/GoogleContainerTools/kaniko/cmd/executor
tejaldesai@@kaniko (507)$