zero out the build id for reproducible builds

We have been having issues with making builds reproducible, especially
with the `.note.go.buildid` ELF section. One tip from a golang issue was
to set `-ldflags=-buildid=` which seems to work well. You can confirm
that the buildid is set to empty by inspecting the binaries with the go
command example `go tool buildid _output/local/go/bin/kubectl`

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
Davanum Srinivas 2020-03-15 20:39:34 -04:00
parent 84dc704679
commit d70d04f92b
No known key found for this signature in database
GPG Key ID: 80D83A796103BF59

View File

@ -784,7 +784,7 @@ kube::golang::build_binaries() {
# Disable SC2153 for this, as it will throw a warning that the local
# variable goldflags will exist, and it suggest changing it to this.
# shellcheck disable=SC2153
goldflags="${GOLDFLAGS=-s -w} $(kube::version::ldflags)"
goldflags="${GOLDFLAGS=-s -w -buildid=} $(kube::version::ldflags)"
goasmflags="-trimpath=${KUBE_ROOT}"
gogcflags="${GOGCFLAGS:-} -trimpath=${KUBE_ROOT}"