Drop cp from the etcd images

This was used by migrate-if-needed.sh, but that has been replaced by
the migrate Go program which doesn't need external cp.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
This commit is contained in:
Stephen Kitt 2023-02-13 18:06:59 +01:00
parent 8d25cc3193
commit b62165f445
No known key found for this signature in database
GPG Key ID: 1CC5FA453662A71D
4 changed files with 2 additions and 69 deletions

View File

@ -34,5 +34,4 @@ COPY --from=builder /sh /bin/
EXPOSE 2379 2380 4001 7001 EXPOSE 2379 2380 4001 7001
# etcdctl is used by etcd.manifest for livenessProbe. # etcdctl is used by etcd.manifest for livenessProbe.
COPY etcd* etcdctl* /usr/local/bin/ COPY etcd* etcdctl* /usr/local/bin/
COPY cp* /bin/
COPY migrate-if-needed.sh migrate /usr/local/bin/ COPY migrate-if-needed.sh migrate /usr/local/bin/

View File

@ -18,7 +18,6 @@ FROM ${RUNNERIMAGE}
EXPOSE 2379 2380 4001 7001 EXPOSE 2379 2380 4001 7001
COPY etcd* etcdctl* /usr/local/bin/ COPY etcd* etcdctl* /usr/local/bin/
COPY cp* /usr/local/bin/
COPY migrate-if-needed.bat /usr/local/bin/ COPY migrate-if-needed.bat /usr/local/bin/
COPY migrate /usr/local/bin/migrate.exe COPY migrate /usr/local/bin/migrate.exe

View File

@ -34,7 +34,7 @@ LATEST_ETCD_VERSION?=3.5.7
# REVISION provides a version number for this image and all it's bundled # REVISION provides a version number for this image and all it's bundled
# artifacts. It should start at zero for each LATEST_ETCD_VERSION and increment # artifacts. It should start at zero for each LATEST_ETCD_VERSION and increment
# for each revision of this image at that etcd version. # for each revision of this image at that etcd version.
REVISION?=0 REVISION?=1
# IMAGE_TAG Uniquely identifies registry.k8s.io/etcd docker image with a tag of the form "<etcd-version>-<revision>". # IMAGE_TAG Uniquely identifies registry.k8s.io/etcd docker image with a tag of the form "<etcd-version>-<revision>".
IMAGE_TAG=$(LATEST_ETCD_VERSION)-$(REVISION) IMAGE_TAG=$(LATEST_ETCD_VERSION)-$(REVISION)
@ -125,10 +125,7 @@ build:
migrate_tmp_dir=$(shell mktemp -d); \ migrate_tmp_dir=$(shell mktemp -d); \
docker run --rm --interactive -v $(shell pwd)/../../../:/go/src/k8s.io/kubernetes$(DOCKER_VOL_OPTS) -v $${migrate_tmp_dir}:/build$(DOCKER_VOL_OPTS) -e GOOS=$(OS) -e GOARCH=$(ARCH) golang:$(GOLANG_VERSION) \ docker run --rm --interactive -v $(shell pwd)/../../../:/go/src/k8s.io/kubernetes$(DOCKER_VOL_OPTS) -v $${migrate_tmp_dir}:/build$(DOCKER_VOL_OPTS) -e GOOS=$(OS) -e GOARCH=$(ARCH) golang:$(GOLANG_VERSION) \
/bin/bash -c "CGO_ENABLED=0 GO111MODULE=off go build -o /build/migrate k8s.io/kubernetes/cluster/images/etcd/migrate"; \ /bin/bash -c "CGO_ENABLED=0 GO111MODULE=off go build -o /build/migrate k8s.io/kubernetes/cluster/images/etcd/migrate"; \
$(BIN_INSTALL) $${migrate_tmp_dir}/migrate $(TEMP_DIR); \ $(BIN_INSTALL) $${migrate_tmp_dir}/migrate $(TEMP_DIR);
docker run --rm --interactive -v $(shell pwd)/../../../:/go/src/k8s.io/kubernetes$(DOCKER_VOL_OPTS) -v $${migrate_tmp_dir}:/build$(DOCKER_VOL_OPTS) -e GOOS=$(OS) -e GOARCH=$(ARCH) golang:$(GOLANG_VERSION) \
/bin/bash -c "CGO_ENABLED=0 GO111MODULE=off go build -o /build/cp k8s.io/kubernetes/cluster/images/etcd/cp"; \
$(BIN_INSTALL) $${migrate_tmp_dir}/cp $(TEMP_DIR);
ifeq ($(ARCH),amd64) ifeq ($(ARCH),amd64)

View File

@ -1,62 +0,0 @@
/*
Copyright 2020 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"io"
"log"
"os"
"path/filepath"
)
func main() {
if len(os.Args) != 3 {
log.Fatal("Usage: cp SOURCE DEST")
}
sf, err := os.Open(os.Args[1])
if err != nil {
log.Fatalf("unable to open source file [%s]: %q", os.Args[1], err)
}
defer sf.Close()
fi, err := sf.Stat()
if err != nil {
log.Fatalf("unable to stat source file [%s]: %q", os.Args[1], err)
}
dir := filepath.Dir(os.Args[2])
if err := os.MkdirAll(dir, 0755); err != nil {
log.Fatalf("unable to create directory [%s]: %q", dir, err)
}
df, err := os.Create(os.Args[2])
if err != nil {
log.Fatalf("unable to create destination file [%s]: %q", os.Args[1], err)
}
defer df.Close()
_, err = io.Copy(df, sf)
if err != nil {
log.Fatalf("unable to copy [%s] to [%s]: %q", os.Args[1], os.Args[2], err)
}
if err := df.Close(); err != nil {
log.Fatalf("unable to close destination file: %q", err)
}
if err := os.Chmod(os.Args[2], fi.Mode()); err != nil {
log.Fatalf("unable to close destination file: %q", err)
}
}