Fresh dep ensure

This commit is contained in:
Mike Cronce
2018-11-26 13:23:56 -05:00
parent 93cb8a04d7
commit 407478ab9a
9016 changed files with 551394 additions and 279685 deletions

View File

@ -0,0 +1,65 @@
load("@io_bazel_rules_docker//container:container.bzl", "container_bundle", "container_image", "container_layer")
container_layer(
name = "cluster-srcs",
data_path = "/",
directory = "/kubernetes",
files = ["//cluster:all-srcs"],
)
container_layer(
name = "bins",
directory = "/usr/local/bin",
files = [
"//cmd/kubectl",
"//test/e2e:e2e.test",
"//vendor/github.com/onsi/ginkgo/ginkgo",
],
)
container_image(
name = "conformance-internal",
base = "@debian-hyperkube-base-amd64//image",
cmd = [
"/bin/bash",
"-c",
"/run_e2e.sh",
],
env = {
"E2E_FOCUS": "\[Conformance\]",
"E2E_SKIP": "",
"E2E_PARALLEL": "1",
"E2E_PROVIDER": "local",
"RESULTS_DIR": "/tmp/results",
"KUBECONFIG": "",
},
files = [
":run_e2e.sh",
],
layers = [
":cluster-srcs",
":bins",
],
stamp = True,
workdir = "/usr/local/bin",
)
container_bundle(
name = "conformance",
images = {"k8s.gcr.io/conformance-amd64:{STABLE_DOCKER_TAG}": "conformance-internal"},
stamp = True,
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@ -0,0 +1,31 @@
# Copyright 2018 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.
FROM BASEIMAGE
COPY ginkgo /usr/local/bin/
COPY e2e.test /usr/local/bin/
COPY kubectl /usr/local/bin/
COPY run_e2e.sh /run_e2e.sh
COPY cluster /kubernetes/cluster
WORKDIR /usr/local/bin
ENV E2E_FOCUS="\[Conformance\]"
ENV E2E_SKIP=""
ENV E2E_PROVIDER="local"
ENV E2E_PARALLEL="1"
ENV RESULTS_DIR="/tmp/results"
ENV KUBECONFIG=""
CMD [ "/bin/bash", "-c", "/run_e2e.sh" ]

View File

@ -0,0 +1,62 @@
# Copyright 2016 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.
# Build the conformance image.
#
# Usage:
# [ARCH=amd64] [REGISTRY="staging-k8s.gcr.io"] make (build|push) VERSION={some_released_version_of_kubernetes}
REGISTRY?=staging-k8s.gcr.io
ARCH?=amd64
OUT_DIR?=_output
GINKGO_BIN?=$(shell pwd)/../../../$(OUT_DIR)/dockerized/bin/linux/$(ARCH)/ginkgo
KUBECTL_BIN?=$(shell pwd)/../../../$(OUT_DIR)/dockerized/bin/linux/$(ARCH)/kubectl
E2E_TEST_BIN?=$(shell pwd)/../../../$(OUT_DIR)/dockerized/bin/linux/$(ARCH)/e2e.test
CLUSTER_DIR?=$(shell pwd)/../../../cluster/
BASEIMAGE=k8s.gcr.io/debian-hyperkube-base-$(ARCH):0.12.0
TEMP_DIR:=$(shell mktemp -d -t conformanceXXXXXX)
all: build
build:
ifndef VERSION
$(error VERSION is undefined)
endif
cp -r ./* ${TEMP_DIR}
cp ${GINKGO_BIN} ${TEMP_DIR}
cp ${KUBECTL_BIN} ${TEMP_DIR}
cp ${E2E_TEST_BIN} ${TEMP_DIR}
cp -r ${CLUSTER_DIR} ${TEMP_DIR}/cluster
chmod a+rx ${TEMP_DIR}/ginkgo
chmod a+rx ${TEMP_DIR}/kubectl
chmod a+rx ${TEMP_DIR}/e2e.test
cd ${TEMP_DIR} && sed -i.back "s|BASEIMAGE|${BASEIMAGE}|g" Dockerfile
docker build --pull -t ${REGISTRY}/conformance-${ARCH}:${VERSION} ${TEMP_DIR}
rm -rf "${TEMP_DIR}"
push: build
docker push ${REGISTRY}/conformance-${ARCH}:${VERSION}
ifeq ($(ARCH),amd64)
docker rmi ${REGISTRY}/conformance:${VERSION} 2>/dev/null || true
docker tag ${REGISTRY}/conformance-${ARCH}:${VERSION} ${REGISTRY}/conformance:${VERSION}
docker push ${REGISTRY}/conformance:${VERSION}
endif
.PHONY: build push all

View File

@ -0,0 +1,12 @@
reviewers:
- timothysc
- dims
- ixdy
- spiffxp
approvers:
- timothysc
- dims
- ixdy
- spiffxp
labels:
- sig/release

View File

@ -0,0 +1,68 @@
### conformance
`conformance` is a standalone container to launch Kubernetes end-to-end tests, for the purposes of conformance testing.
`conformance` is built for multiple architectures and _the image is pushed automatically on every release._
#### How to release by hand
```console
# First, build the binaries
$ build/run.sh make cross
# Build for linux/amd64 (default)
# export REGISTRY=$HOST/$ORG to switch from staging-k8s.gcr.io
$ make push VERSION={target_version} ARCH=amd64
# ---> staging-k8s.gcr.io/conformance-amd64:VERSION
# ---> staging-k8s.gcr.io/conformance:VERSION (image with backwards-compatible naming)
$ make push VERSION={target_version} ARCH=arm
# ---> staging-k8s.gcr.io/conformance-arm:VERSION
$ make push VERSION={target_version} ARCH=arm64
# ---> staging-k8s.gcr.io/conformance-arm64:VERSION
$ make push VERSION={target_version} ARCH=ppc64le
# ---> staging-k8s.gcr.io/conformance-ppc64le:VERSION
$ make push VERSION={target_version} ARCH=s390x
# ---> staging-k8s.gcr.io/conformance-s390x:VERSION
```
If you don't want to push the images, run `make` or `make build` instead
#### How to setup RBAC needed
```
kubectl create clusterrolebinding add-on-cluster-admin --clusterrole=cluster-admin --serviceaccount=default:default
```
#### How to run a single test
```
apiVersion: v1
kind: Pod
metadata:
name: e2e-producer-consumer-test
spec:
containers:
- name: conformance-container
image: gcr.io/heptio-images/kube-conformance:latest
image: staging-k8s.gcr.io/conformance-amd64:v1.12.1
imagePullPolicy: IfNotPresent
env:
- name: E2E_FOCUS
value: "Pods should be submitted and removed"
volumeMounts:
- name: output-volume
mountPath: /tmp/results
volumes:
- name: output-volume
hostPath:
path: /tmp/results
restartPolicy: Never
```
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/cluster/images/conformance/README.md?pixel)]()

View File

@ -0,0 +1,57 @@
#!/bin/bash
# Copyright 2018 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.
set -o errexit
set -o nounset
set -o pipefail
# Shutdown the tests gracefully then save the results
shutdown () {
E2E_SUITE_PID=$(pgrep e2e.test)
echo "sending TERM to ${E2E_SUITE_PID}"
kill -s TERM "${E2E_SUITE_PID}"
# Kind of a hack to wait for this pid to finish.
# Since it's not a child of this shell we cannot use wait.
tail --pid ${E2E_SUITE_PID} -f /dev/null
saveResults
}
saveResults() {
cd "${RESULTS_DIR}" || exit
tar -czf e2e.tar.gz ./*
# mark the done file as a termination notice.
echo -n "${RESULTS_DIR}/e2e.tar.gz" > "${RESULTS_DIR}/done"
}
# We get the TERM from kubernetes and handle it gracefully
trap shutdown TERM
ginkgo_args=(
"--focus=${E2E_FOCUS}"
"--skip=${E2E_SKIP}"
"--noColor=true"
)
case ${E2E_PARALLEL} in
'y'|'Y') ginkgo_args+=("--nodes=25") ;;
[1-9]|[1-9][0-9]*) ginkgo_args+=("--nodes=${E2E_PARALLEL}") ;;
esac
echo "/usr/local/bin/ginkgo ${ginkgo_args[@]} /usr/local/bin/e2e.test -- --disable-log-dump --repo-root=/kubernetes --provider=\"${E2E_PROVIDER}\" --report-dir=\"${RESULTS_DIR}\" --kubeconfig=\"${KUBECONFIG}\""
/usr/local/bin/ginkgo "${ginkgo_args[@]}" /usr/local/bin/e2e.test -- --disable-log-dump --repo-root=/kubernetes --provider="${E2E_PROVIDER}" --report-dir="${RESULTS_DIR}" --kubeconfig="${KUBECONFIG}" | tee ${RESULTS_DIR}/e2e.log &
# $! is the pid of tee, not ginkgo
wait $(pgrep ginkgo)
saveResults

View File

@ -14,13 +14,13 @@
.PHONY: build push
ETCD_VERSION = 3.2.18
ETCD_VERSION = 3.2.24
# Image should be pulled from k8s.gcr.io, which will auto-detect
# region (us, eu, asia, ...) and pull from the closest.
REGISTRY = k8s.gcr.io
# Images should be pushed to staging-k8s.gcr.io.
PUSH_REGISTRY = staging-k8s.gcr.io
TAG = 3.2.18.0
TAG = 3.2.24.0
clean:
rm -rf etcdctl etcd-v$(ETCD_VERSION)-linux-amd64 etcd-v$(ETCD_VERSION)-linux-amd64.tar.gz

View File

@ -17,12 +17,12 @@ go_library(
importpath = "k8s.io/kubernetes/cluster/images/etcd-version-monitor",
deps = [
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/prometheus/client_golang/prometheus:go_default_library",
"//vendor/github.com/prometheus/client_golang/prometheus/promhttp:go_default_library",
"//vendor/github.com/prometheus/client_model/go:go_default_library",
"//vendor/github.com/prometheus/common/expfmt:go_default_library",
"//vendor/github.com/spf13/pflag:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],
)

View File

@ -25,12 +25,12 @@ import (
"time"
"github.com/gogo/protobuf/proto"
"github.com/golang/glog"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
dto "github.com/prometheus/client_model/go"
"github.com/prometheus/common/expfmt"
"github.com/spf13/pflag"
"k8s.io/klog"
)
// Initialize the prometheus instrumentation and client related flags.
@ -245,7 +245,7 @@ func getVersionPeriodically(stopCh <-chan struct{}) {
lastSeenBinaryVersion := ""
for {
if err := getVersion(&lastSeenBinaryVersion); err != nil {
glog.Errorf("Failed to fetch etcd version: %v", err)
klog.Errorf("Failed to fetch etcd version: %v", err)
}
select {
case <-stopCh:
@ -399,7 +399,7 @@ func main() {
go getVersionPeriodically(stopCh)
// Serve our metrics on listenAddress/metricsPath.
glog.Infof("Listening on: %v", listenAddress)
klog.Infof("Listening on: %v", listenAddress)
http.Handle(metricsPath, promhttp.HandlerFor(gatherer, promhttp.HandlerOpts{}))
glog.Errorf("Stopped listening/serving metrics: %v", http.ListenAndServe(listenAddress, nil))
klog.Errorf("Stopped listening/serving metrics: %v", http.ListenAndServe(listenAddress, nil))
}

View File

@ -15,7 +15,7 @@
# Build the etcd image
#
# Usage:
# [BUNDLED_ETCD_VERSIONS=2.2.1 2.3.7 3.0.17 3.1.12 3.2.18] [REGISTRY=k8s.gcr.io] [ARCH=amd64] [BASEIMAGE=busybox] make (build|push)
# [BUNDLED_ETCD_VERSIONS=2.2.1 2.3.7 3.0.17 3.1.12 3.2.24] [REGISTRY=k8s.gcr.io] [ARCH=amd64] [BASEIMAGE=busybox] make (build|push)
#
# The image contains different etcd versions to simplify
# upgrades. Thus be careful when removing any versions from here.
@ -26,25 +26,31 @@
# Except from etcd-$(version) and etcdctl-$(version) binaries, we also
# need etcd and etcdctl binaries for backward compatibility reasons.
# That binary will be set to the last version from $(BUNDLED_ETCD_VERSIONS).
BUNDLED_ETCD_VERSIONS?=2.2.1 2.3.7 3.0.17 3.1.12 3.2.18
BUNDLED_ETCD_VERSIONS?=2.2.1 2.3.7 3.0.17 3.1.12 3.2.24
# LATEST_ETCD_VERSION identifies the most recent etcd version available.
LATEST_ETCD_VERSION?=3.2.18
LATEST_ETCD_VERSION?=3.2.24
# REVISION provides a version number fo this image and all it's bundled
# artifacts. It should start at zero for each LATEST_ETCD_VERSION and increment
# for each revision of this image at that etcd version.
REVISION?=0
REVISION?=1
# IMAGE_TAG Uniquely identifies k8s.gcr.io/etcd docker image with a tag of the form "<etcd-version>-<revision>".
IMAGE_TAG=$(LATEST_ETCD_VERSION)-$(REVISION)
ARCH?=amd64
ALL_ARCH = amd64 arm arm64 ppc64le s390x
# Image should be pulled from k8s.gcr.io, which will auto-detect
# region (us, eu, asia, ...) and pull from the closest.
REGISTRY?=k8s.gcr.io
# Images should be pushed to staging-k8s.gcr.io.
PUSH_REGISTRY?=staging-k8s.gcr.io
MANIFEST_IMAGE := $(PUSH_REGISTRY)/etcd
# This option is for running docker manifest command
export DOCKER_CLI_EXPERIMENTAL := enabled
# golang version should match the golang version from https://github.com/coreos/etcd/releases for the current ETCD_VERSION.
GOLANG_VERSION?=1.8.7
GOARM=7
@ -118,14 +124,25 @@ endif
docker build --pull -t $(REGISTRY)/etcd-$(ARCH):$(IMAGE_TAG) $(TEMP_DIR)
push: build
docker tag $(REGISTRY)/etcd-$(ARCH):$(IMAGE_TAG) $(PUSH_REGISTRY)/etcd-$(ARCH):$(IMAGE_TAG)
docker push $(PUSH_REGISTRY)/etcd-$(ARCH):$(IMAGE_TAG)
docker tag $(REGISTRY)/etcd-$(ARCH):$(IMAGE_TAG) $(MANIFEST_IMAGE)-$(ARCH):$(IMAGE_TAG)
docker push $(MANIFEST_IMAGE)-$(ARCH):$(IMAGE_TAG)
ifeq ($(ARCH),amd64)
# Backward compatibility. TODO: deprecate this image tag
docker tag $(REGISTRY)/etcd-$(ARCH):$(IMAGE_TAG) $(PUSH_REGISTRY)/etcd:$(IMAGE_TAG)
docker push $(PUSH_REGISTRY)/etcd:$(IMAGE_TAG)
endif
sub-build-%:
$(MAKE) ARCH=$* build
all-build: $(addprefix sub-build-,$(ALL_ARCH))
sub-push-image-%:
$(MAKE) ARCH=$* push
all-push-images: $(addprefix sub-push-image-,$(ALL_ARCH))
all-push: all-push-images push-manifest
push-manifest:
docker manifest create --amend $(MANIFEST_IMAGE):$(IMAGE_TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(MANIFEST_IMAGE)\-&:$(IMAGE_TAG)~g")
@for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${MANIFEST_IMAGE}:${IMAGE_TAG} ${MANIFEST_IMAGE}-$${arch}:${IMAGE_TAG}; done
docker manifest push --purge ${MANIFEST_IMAGE}:${IMAGE_TAG}
unit-test:
docker run --interactive -v $(shell pwd)/../../../:/go/src/k8s.io/kubernetes -e GOARCH=$(ARCH) golang:$(GOLANG_VERSION) \
@ -146,5 +163,5 @@ integration-test:
integration-build-test: build-integration-test-image integration-test
test: unit-test integration-build-test
all: build test
.PHONY: build push unit-test build-integration-test-image integration-test integration-build-test test
all: all-build test
.PHONY: build push push-manifest all-push all-push-images all-build unit-test build-integration-test-image integration-test integration-build-test test

7
vendor/k8s.io/kubernetes/cluster/images/etcd/OWNERS generated vendored Normal file
View File

@ -0,0 +1,7 @@
reviewers:
- jpbetz
- wenjiaswe
approvers:
- jpbetz
labels:
- sig/api-machinery

View File

@ -26,7 +26,7 @@ server.
`migrate` writes a `version.txt` file to track the "current" version
of etcd that was used to persist data to disk. A "target" version may also be provided
by the `TARGET_STORAGE` (e.g. "etcd3") and `TARGET_VERSION` (e.g. "3.2.11" )
by the `TARGET_STORAGE` (e.g. "etcd3") and `TARGET_VERSION` (e.g. "3.2.24" )
environment variables. If the persisted version differs from the target version,
`migrate-if-needed.sh` will migrate the data from the current to the target
version.
@ -62,22 +62,14 @@ $ make build test
Last, build and push the docker images for all supported architectures.
```console
# Build for linux/amd64 (default)
$ make push ARCH=amd64
# ---> staging-k8s.gcr.io/etcd-amd64:TAG
# ---> staging-k8s.gcr.io/etcd:TAG
# Build images for all the architecture and push the manifest image as well
$ make all-push
$ make push ARCH=arm
# ---> staging-k8s.gcr.io/etcd-arm:TAG
# Build images for all the architecture
$ make all-build
$ make push ARCH=arm64
# ---> staging-k8s.gcr.io/etcd-arm64:TAG
$ make push ARCH=ppc64le
# ---> staging-k8s.gcr.io/etcd-ppc64le:TAG
$ make push ARCH=s390x
# ---> staging-k8s.gcr.io/etcd-s390x:TAG
# Build image for target architecture(default=amd64)
$ make build ARCH=ppc64le
```
If you don't want to push the images, run `make` or `make build` instead

View File

@ -18,7 +18,7 @@
# This script performs etcd upgrade based on the following environmental
# variables:
# TARGET_STORAGE - API of etcd to be used (supported: 'etcd2', 'etcd3')
# TARGET_VERSION - etcd release to be used (supported: '2.2.1', '2.3.7', '3.0.17', '3.1.12', '3.2.18')
# TARGET_VERSION - etcd release to be used (supported: '2.2.1', '2.3.7', '3.0.17', '3.1.12', '3.2.24')
# DATA_DIRECTORY - directory with etcd data
#
# The current etcd version and storage format is detected based on the
@ -29,7 +29,7 @@
# - 2.2.1/etcd2 -> 2.3.7/etcd2
# - 2.3.7/etcd2 -> 3.0.17/etcd2
# - 3.0.17/etcd3 -> 3.1.12/etcd3
# - 3.1.12/etcd3 -> 3.2.18/etcd3
# - 3.1.12/etcd3 -> 3.2.24/etcd3
#
# NOTE: The releases supported in this script has to match release binaries
# present in the etcd image (to make this script work correctly).
@ -42,7 +42,7 @@ set -o nounset
# NOTE: BUNDLED_VERSION has to match release binaries present in the
# etcd image (to make this script work correctly).
BUNDLED_VERSIONS="2.2.1, 2.3.7, 3.0.17, 3.1.12, 3.2.18"
BUNDLED_VERSIONS="2.2.1, 2.3.7, 3.0.17, 3.1.12, 3.2.24"
ETCD_NAME="${ETCD_NAME:-etcd-$(hostname)}"
if [ -z "${DATA_DIRECTORY:-}" ]; then

View File

@ -42,8 +42,8 @@ go_library(
"//vendor/github.com/coreos/etcd/wal:go_default_library",
"//vendor/github.com/coreos/etcd/wal/walpb:go_default_library",
"//vendor/github.com/coreos/go-semver/semver:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/spf13/cobra:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],
)

View File

@ -25,7 +25,7 @@ import (
"path/filepath"
"strings"
"github.com/golang/glog"
"k8s.io/klog"
)
// DataDirectory provides utilities for initializing and backing up an
@ -45,7 +45,7 @@ func OpenOrCreateDataDirectory(path string) (*DataDirectory, error) {
return nil, err
}
if !exists {
glog.Infof("data directory '%s' does not exist, creating it", path)
klog.Infof("data directory '%s' does not exist, creating it", path)
err := os.MkdirAll(path, 0777)
if err != nil {
return nil, fmt.Errorf("failed to create data directory %s: %v", path, err)
@ -67,7 +67,7 @@ func (d *DataDirectory) Initialize(target *EtcdVersionPair) error {
return err
}
if isEmpty {
glog.Infof("data directory '%s' is empty, writing target version '%s' to version.txt", d.path, target)
klog.Infof("data directory '%s' is empty, writing target version '%s' to version.txt", d.path, target)
err = d.versionFile.Write(target)
if err != nil {
return fmt.Errorf("failed to write version.txt to '%s': %v", d.path, err)

View File

@ -39,7 +39,7 @@ func TestExistingDataDirWithVersionFile(t *testing.T) {
t.Fatalf("Failed to check if data dir is empty: %v", err)
}
if isEmpty {
t.Errorf("Data directory is non-empty")
t.Errorf("Expected non-empty data directory to exist")
}
exists, err := d.versionFile.Exists()
if err != nil {
@ -97,7 +97,7 @@ func TestNonexistingDataDir(t *testing.T) {
t.Fatalf("Failed to check if data dir is empty: %v", err)
}
if !isEmpty {
t.Errorf("Data directory is empty")
t.Errorf("Expected empty data directory to exist")
}
err = d.Initialize(targetVersion)
if err != nil {
@ -115,7 +115,7 @@ func TestNonexistingDataDir(t *testing.T) {
t.Fatalf("Failed to check if data dir is empty: %v", err)
}
if isEmpty {
t.Errorf("Data directory is non-empty")
t.Errorf("Expected non-empty data directory to exist after Initialize()")
}
vp, err := d.versionFile.Read()
if err != nil {
@ -145,7 +145,7 @@ func TestBackup(t *testing.T) {
t.Fatal(err)
}
if isEmpty {
t.Errorf("Expected non-empty backup directory afer Backup()")
t.Errorf("Expected non-empty backup directory to exist after Backup()")
}
}

View File

@ -323,7 +323,7 @@ func generateSelfSignedCertKey(host string, alternateIPs []net.IP, alternateDNS
KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth, x509.ExtKeyUsageClientAuth},
BasicConstraintsValid: true,
IsCA: true,
IsCA: true,
}
if ip := net.ParseIP(host); ip != nil {

View File

@ -21,8 +21,8 @@ import (
"os"
"path/filepath"
"github.com/golang/glog"
"github.com/spf13/cobra"
"k8s.io/klog"
)
const (
@ -85,7 +85,7 @@ func runMigrate() {
if opts.name == "" {
hostname, err := os.Hostname()
if err != nil {
glog.Errorf("Error while getting hostname to supply default --name: %v", err)
klog.Errorf("Error while getting hostname to supply default --name: %v", err)
os.Exit(1)
}
opts.name = fmt.Sprintf("etcd-%s", hostname)
@ -98,29 +98,29 @@ func runMigrate() {
opts.initialCluster = fmt.Sprintf("%s=http://localhost:2380", opts.name)
}
if opts.targetStorage == "" {
glog.Errorf("--target-storage is required")
klog.Errorf("--target-storage is required")
os.Exit(1)
}
if opts.targetVersion == "" {
glog.Errorf("--target-version is required")
klog.Errorf("--target-version is required")
os.Exit(1)
}
if opts.dataDir == "" {
glog.Errorf("--data-dir is required")
klog.Errorf("--data-dir is required")
os.Exit(1)
}
if opts.bundledVersionString == "" {
glog.Errorf("--bundled-versions is required")
klog.Errorf("--bundled-versions is required")
os.Exit(1)
}
bundledVersions, err := ParseSupportedVersions(opts.bundledVersionString)
if err != nil {
glog.Errorf("Failed to parse --supported-versions: %v", err)
klog.Errorf("Failed to parse --supported-versions: %v", err)
}
err = validateBundledVersions(bundledVersions, opts.binDir)
if err != nil {
glog.Errorf("Failed to validate that 'etcd-<version>' and 'etcdctl-<version>' binaries exist in --bin-dir '%s' for all --bundled-verions '%s': %v",
klog.Errorf("Failed to validate that 'etcd-<version>' and 'etcdctl-<version>' binaries exist in --bin-dir '%s' for all --bundled-verions '%s': %v",
opts.binDir, opts.bundledVersionString, err)
os.Exit(1)
}
@ -139,7 +139,7 @@ func migrate(name string, port uint64, peerListenUrls string, peerAdvertiseUrls
dataDir, err := OpenOrCreateDataDirectory(dataDirPath)
if err != nil {
glog.Errorf("Error opening or creating data directory %s: %v", dataDirPath, err)
klog.Errorf("Error opening or creating data directory %s: %v", dataDirPath, err)
os.Exit(1)
}
@ -158,7 +158,7 @@ func migrate(name string, port uint64, peerListenUrls string, peerAdvertiseUrls
}
client, err := NewEtcdMigrateClient(cfg)
if err != nil {
glog.Errorf("Migration failed: %v", err)
klog.Errorf("Migration failed: %v", err)
os.Exit(1)
}
defer client.Close()
@ -167,7 +167,7 @@ func migrate(name string, port uint64, peerListenUrls string, peerAdvertiseUrls
err = migrator.MigrateIfNeeded(target)
if err != nil {
glog.Errorf("Migration failed: %v", err)
klog.Errorf("Migration failed: %v", err)
os.Exit(1)
}
}

View File

@ -29,7 +29,7 @@ import (
clientv2 "github.com/coreos/etcd/client"
"github.com/coreos/etcd/clientv3"
"github.com/golang/glog"
"k8s.io/klog"
)
// CombinedEtcdClient provides an implementation of EtcdMigrateClient using a combination of the etcd v2 client, v3 client
@ -202,13 +202,13 @@ func (e *CombinedEtcdClient) AttachLease(leaseDuration time.Duration) error {
if err != nil {
return fmt.Errorf("Error while creating lease: %v", err)
}
glog.Infof("Lease with TTL: %v created", lease.TTL)
klog.Infof("Lease with TTL: %v created", lease.TTL)
glog.Infof("Attaching lease to %d entries", len(objectsResp.Kvs))
klog.Infof("Attaching lease to %d entries", len(objectsResp.Kvs))
for _, kv := range objectsResp.Kvs {
putResp, err := v3client.KV.Put(ctx, string(kv.Key), string(kv.Value), clientv3.WithLease(lease.ID), clientv3.WithPrevKV())
if err != nil {
glog.Errorf("Error while attaching lease to: %s", string(kv.Key))
klog.Errorf("Error while attaching lease to: %s", string(kv.Key))
}
if bytes.Compare(putResp.PrevKv.Value, kv.Value) != 0 {
return fmt.Errorf("concurrent access to key detected when setting lease on %s, expected previous value of %s but got %s",

View File

@ -23,7 +23,7 @@ import (
"strings"
"time"
"github.com/golang/glog"
"k8s.io/klog"
)
// EtcdMigrateServer manages starting and stopping a versioned etcd server binary.
@ -75,10 +75,10 @@ func (r *EtcdMigrateServer) Start(version *EtcdVersion) error {
case <-interval.C:
err := r.client.SetEtcdVersionKeyValue(version)
if err != nil {
glog.Infof("Still waiting for etcd to start, current error: %v", err)
klog.Infof("Still waiting for etcd to start, current error: %v", err)
// keep waiting
} else {
glog.Infof("Etcd on port %d is up.", r.cfg.port)
klog.Infof("Etcd on port %d is up.", r.cfg.port)
r.cmd = etcdCmd
return nil
}
@ -114,7 +114,7 @@ func (r *EtcdMigrateServer) Stop() error {
case <-stopped:
return
case <-timedout:
glog.Infof("etcd server has not terminated gracefully after %s, killing it.", gracefulWait)
klog.Infof("etcd server has not terminated gracefully after %s, killing it.", gracefulWait)
r.cmd.Process.Kill()
return
}
@ -122,11 +122,11 @@ func (r *EtcdMigrateServer) Stop() error {
err = r.cmd.Wait()
stopped <- true
if exiterr, ok := err.(*exec.ExitError); ok {
glog.Infof("etcd server stopped (signal: %s)", exiterr.Error())
klog.Infof("etcd server stopped (signal: %s)", exiterr.Error())
// stopped
} else if err != nil {
return fmt.Errorf("error waiting for etcd to stop: %v", err)
}
glog.Infof("Stopped etcd server %s", r.cfg.name)
klog.Infof("Stopped etcd server %s", r.cfg.name)
return nil
}

View File

@ -23,7 +23,7 @@ import (
"time"
"github.com/blang/semver"
"github.com/golang/glog"
"k8s.io/klog"
)
// EtcdMigrateCfg provides all configuration required to perform etcd data upgrade/downgrade migrations.
@ -63,7 +63,7 @@ type Migrator struct {
// MigrateIfNeeded upgrades or downgrades the etcd data directory to the given target version.
func (m *Migrator) MigrateIfNeeded(target *EtcdVersionPair) error {
glog.Infof("Starting migration to %s", target)
klog.Infof("Starting migration to %s", target)
err := m.dataDirectory.Initialize(target)
if err != nil {
return fmt.Errorf("failed to initialize data directory %s: %v", m.dataDirectory.path, err)
@ -84,28 +84,28 @@ func (m *Migrator) MigrateIfNeeded(target *EtcdVersionPair) error {
}
for {
glog.Infof("Converging current version '%s' to target version '%s'", current, target)
klog.Infof("Converging current version '%s' to target version '%s'", current, target)
currentNextMinorVersion := &EtcdVersion{Version: semver.Version{Major: current.version.Major, Minor: current.version.Minor + 1}}
switch {
case current.version.MajorMinorEquals(target.version) || currentNextMinorVersion.MajorMinorEquals(target.version):
glog.Infof("current version '%s' equals or is one minor version previous of target version '%s' - migration complete", current, target)
klog.Infof("current version '%s' equals or is one minor version previous of target version '%s' - migration complete", current, target)
err = m.dataDirectory.versionFile.Write(target)
if err != nil {
return fmt.Errorf("failed to write version.txt to '%s': %v", m.dataDirectory.path, err)
}
return nil
case current.storageVersion == storageEtcd2 && target.storageVersion == storageEtcd3:
glog.Infof("upgrading from etcd2 storage to etcd3 storage")
klog.Infof("upgrading from etcd2 storage to etcd3 storage")
current, err = m.etcd2ToEtcd3Upgrade(current, target)
case current.version.Major == 3 && target.version.Major == 2:
glog.Infof("downgrading from etcd 3.x to 2.x")
klog.Infof("downgrading from etcd 3.x to 2.x")
current, err = m.rollbackToEtcd2(current, target)
case current.version.Major == target.version.Major && current.version.Minor < target.version.Minor:
stepVersion := m.cfg.supportedVersions.NextVersionPair(current)
glog.Infof("upgrading etcd from %s to %s", current, stepVersion)
klog.Infof("upgrading etcd from %s to %s", current, stepVersion)
current, err = m.minorVersionUpgrade(current, stepVersion)
case current.version.Major == 3 && target.version.Major == 3 && current.version.Minor > target.version.Minor:
glog.Infof("rolling etcd back from %s to %s", current, target)
klog.Infof("rolling etcd back from %s to %s", current, target)
current, err = m.rollbackEtcd3MinorVersion(current, target)
}
if err != nil {
@ -116,13 +116,13 @@ func (m *Migrator) MigrateIfNeeded(target *EtcdVersionPair) error {
func (m *Migrator) backupEtcd2(current *EtcdVersion) error {
backupDir := fmt.Sprintf("%s/%s", m.dataDirectory, "migration-backup")
glog.Infof("Backup etcd before starting migration")
klog.Infof("Backup etcd before starting migration")
err := os.Mkdir(backupDir, 0666)
if err != nil {
return fmt.Errorf("failed to create backup directory before starting migration: %v", err)
}
m.client.Backup(current, backupDir)
glog.Infof("Backup done in %s", backupDir)
klog.Infof("Backup done in %s", backupDir)
return nil
}
@ -131,7 +131,7 @@ func (m *Migrator) rollbackEtcd3MinorVersion(current *EtcdVersionPair, target *E
return nil, fmt.Errorf("rollback from %s to %s not supported, only rollbacks to the previous minor version are supported", current.version, target.version)
}
glog.Infof("Performing etcd %s -> %s rollback", current.version, target.version)
klog.Infof("Performing etcd %s -> %s rollback", current.version, target.version)
err := m.dataDirectory.Backup()
if err != nil {
return nil, err
@ -145,14 +145,14 @@ func (m *Migrator) rollbackEtcd3MinorVersion(current *EtcdVersionPair, target *E
// Start current version of etcd.
runner := m.newServer()
glog.Infof("Starting etcd version %s to capture rollback snapshot.", current.version)
klog.Infof("Starting etcd version %s to capture rollback snapshot.", current.version)
err = runner.Start(current.version)
if err != nil {
glog.Fatalf("Unable to automatically downgrade etcd: starting etcd version %s to capture rollback snapshot failed: %v", current.version, err)
klog.Fatalf("Unable to automatically downgrade etcd: starting etcd version %s to capture rollback snapshot failed: %v", current.version, err)
return nil, err
}
glog.Infof("Snapshotting etcd %s to %s", current.version, snapshotFilename)
klog.Infof("Snapshotting etcd %s to %s", current.version, snapshotFilename)
err = m.client.Snapshot(current.version, snapshotFilename)
if err != nil {
return nil, err
@ -163,7 +163,7 @@ func (m *Migrator) rollbackEtcd3MinorVersion(current *EtcdVersionPair, target *E
return nil, err
}
glog.Infof("Backing up data before rolling back")
klog.Infof("Backing up data before rolling back")
backupDir := fmt.Sprintf("%s.bak", m.dataDirectory)
err = os.RemoveAll(backupDir)
if err != nil {
@ -178,7 +178,7 @@ func (m *Migrator) rollbackEtcd3MinorVersion(current *EtcdVersionPair, target *E
return nil, err
}
glog.Infof("Restoring etcd %s from %s", target.version, snapshotFilename)
klog.Infof("Restoring etcd %s from %s", target.version, snapshotFilename)
err = m.client.Restore(target.version, snapshotFilename)
if err != nil {
return nil, err
@ -195,7 +195,7 @@ func (m *Migrator) rollbackToEtcd2(current *EtcdVersionPair, target *EtcdVersion
if !(current.version.Major == 3 && current.version.Minor == 0 && target.version.Major == 2 && target.version.Minor == 2) {
return nil, fmt.Errorf("etcd3 -> etcd2 downgrade is supported only between 3.0.x and 2.2.x, got current %s target %s", current, target)
}
glog.Infof("Backup and remove all existing v2 data")
klog.Infof("Backup and remove all existing v2 data")
err := m.dataDirectory.Backup()
if err != nil {
return nil, err
@ -214,12 +214,12 @@ func (m *Migrator) etcd2ToEtcd3Upgrade(current *EtcdVersionPair, target *EtcdVer
}
runner := m.newServer()
glog.Infof("Performing etcd2 -> etcd3 migration")
klog.Infof("Performing etcd2 -> etcd3 migration")
err := m.client.Migrate(target.version)
if err != nil {
return nil, err
}
glog.Infof("Attaching leases to TTL entries")
klog.Infof("Attaching leases to TTL entries")
// Now attach lease to all keys.
// To do it, we temporarily start etcd on a random port (so that

View File

@ -42,7 +42,7 @@ import (
"github.com/coreos/etcd/wal"
"github.com/coreos/etcd/wal/walpb"
"github.com/coreos/go-semver/semver"
"github.com/golang/glog"
"k8s.io/klog"
)
const rollbackVersion = "2.2.0"
@ -50,7 +50,7 @@ const rollbackVersion = "2.2.0"
// RollbackV3ToV2 rolls back an etcd 3.0.x data directory to the 2.x.x version specified by rollbackVersion.
func RollbackV3ToV2(migrateDatadir string, ttl time.Duration) error {
dbpath := path.Join(migrateDatadir, "member", "snap", "db")
glog.Infof("Rolling db file %s back to etcd 2.x", dbpath)
klog.Infof("Rolling db file %s back to etcd 2.x", dbpath)
// etcd3 store backend. We will use it to parse v3 data files and extract information.
be := backend.NewDefaultBackend(dbpath)
@ -139,7 +139,7 @@ func RollbackV3ToV2(migrateDatadir string, ttl time.Duration) error {
v = rollbackVersion
}
if _, err := st.Set(n.Key, n.Dir, v, store.TTLOptionSet{}); err != nil {
glog.Error(err)
klog.Error(err)
}
// update nodes
@ -147,7 +147,7 @@ func RollbackV3ToV2(migrateDatadir string, ttl time.Duration) error {
if len(fields) == 4 && fields[2] == "members" {
nodeID, err := strconv.ParseUint(fields[3], 16, 64)
if err != nil {
glog.Fatalf("failed to parse member ID (%s): %v", fields[3], err)
klog.Fatalf("failed to parse member ID (%s): %v", fields[3], err)
}
nodes = append(nodes, nodeID)
}
@ -172,7 +172,7 @@ func RollbackV3ToV2(migrateDatadir string, ttl time.Duration) error {
if err := snapshotter.SaveSnap(raftSnap); err != nil {
return err
}
glog.Infof("Finished successfully")
klog.Infof("Finished successfully")
return nil
}
@ -214,7 +214,7 @@ func traverseAndDeleteEmptyDir(st store.Store, dir string) error {
}
for _, node := range e.Node.Nodes {
if !node.Dir {
glog.V(2).Infof("key: %s", node.Key[len(etcdserver.StoreKeysPrefix):])
klog.V(2).Infof("key: %s", node.Key[len(etcdserver.StoreKeysPrefix):])
} else {
err := traverseAndDeleteEmptyDir(st, node.Key)
if err != nil {
@ -314,15 +314,36 @@ func toTTLOptions(r *pb.Request) store.TTLOptionSet {
}
func applyRequest(r *pb.Request, applyV2 etcdserver.ApplierV2) {
// TODO: find a sane way to perform this cast or avoid it in the first place
reqV2 := &etcdserver.RequestV2{
ID: r.ID,
Method: r.Method,
Path: r.Path,
Val: r.Val,
Dir: r.Dir,
PrevValue: r.PrevValue,
PrevIndex: r.PrevIndex,
PrevExist: r.PrevExist,
Expiration: r.Expiration,
Wait: r.Wait,
Since: r.Since,
Recursive: r.Recursive,
Sorted: r.Sorted,
Quorum: r.Quorum,
Time: r.Time,
Stream: r.Stream,
Refresh: r.Refresh,
XXX_unrecognized: r.XXX_unrecognized,
}
toTTLOptions(r)
switch r.Method {
case "PUT":
applyV2.Put(r)
applyV2.Put(reqV2)
case "DELETE":
applyV2.Delete(r)
applyV2.Delete(reqV2)
case "POST", "QGET", "SYNC":
return
default:
glog.Fatal("unknown command")
klog.Fatal("unknown command")
}
}

View File

@ -1,31 +1,15 @@
load("@io_bazel_rules_docker//docker:docker.bzl", "docker_build", "docker_bundle")
load("@io_bazel_rules_docker//container:container.bzl", "container_bundle", "container_image")
docker_build(
container_image(
name = "hyperkube-internal",
base = "@debian-hyperkube-base-amd64//image",
files = [
"//cmd/hyperkube",
],
symlinks = {
"/%s" % path: "/hyperkube"
for path in [
"/apiserver",
"/controller-manager",
"/kubectl",
"/kubelet",
"/proxy",
"/scheduler",
"/usr/local/bin/kube-apiserver",
"/usr/local/bin/kube-controller-manager",
"/usr/local/bin/kubectl",
"/usr/local/bin/kubelet",
"/usr/local/bin/kube-proxy",
"/usr/local/bin/kube-scheduler",
]
},
stamp = True,
)
docker_bundle(
container_bundle(
name = "hyperkube",
images = {"k8s.gcr.io/hyperkube-amd64:{STABLE_DOCKER_TAG}": "hyperkube-internal"},
stamp = True,

View File

@ -14,25 +14,5 @@
FROM BASEIMAGE
# Create symlinks for each hyperkube server
# Also create symlinks to /usr/local/bin/ where the server image binaries live, so the hyperkube image may be
# used instead of k8s.gcr.io/kube-* without any modifications.
# TODO: replace manual symlink creation with --make-symlink command once
# cross-building with qemu supports go binaries. See #28702
# RUN /hyperkube --make-symlinks
RUN ln -s /hyperkube /apiserver \
&& ln -s /hyperkube /controller-manager \
&& ln -s /hyperkube /kubectl \
&& ln -s /hyperkube /kubelet \
&& ln -s /hyperkube /proxy \
&& ln -s /hyperkube /scheduler \
&& ln -s /hyperkube /aggregator \
&& ln -s /hyperkube /usr/local/bin/kube-apiserver \
&& ln -s /hyperkube /usr/local/bin/kube-controller-manager \
&& ln -s /hyperkube /usr/local/bin/kubectl \
&& ln -s /hyperkube /usr/local/bin/kubelet \
&& ln -s /hyperkube /usr/local/bin/kube-proxy \
&& ln -s /hyperkube /usr/local/bin/kube-scheduler
# Copy the hyperkube binary
COPY hyperkube /hyperkube

View File

@ -22,7 +22,7 @@ ARCH?=amd64
OUT_DIR?=_output
HYPERKUBE_BIN?=$(shell pwd)/../../../$(OUT_DIR)/dockerized/bin/linux/$(ARCH)/hyperkube
BASEIMAGE=k8s.gcr.io/debian-hyperkube-base-$(ARCH):0.10
BASEIMAGE=k8s.gcr.io/debian-hyperkube-base-$(ARCH):0.12.0
TEMP_DIR:=$(shell mktemp -d -t hyperkubeXXXXXX)
all: build
@ -39,8 +39,6 @@ endif
cd ${TEMP_DIR} && sed -i.back "s|BASEIMAGE|${BASEIMAGE}|g" Dockerfile
# Register /usr/bin/qemu-ARCH-static as the handler for non-x86 binaries in the kernel
docker run --rm --privileged multiarch/qemu-user-static:register --reset
docker build --pull -t ${REGISTRY}/hyperkube-${ARCH}:${VERSION} ${TEMP_DIR}
rm -rf "${TEMP_DIR}"

View File

@ -6,3 +6,5 @@ approvers:
- ixdy
- luxas
- mikedanese
labels:
- sig/release

View File

@ -1,16 +1,18 @@
package(default_visibility = ["//visibility:public"])
load("@io_bazel_rules_docker//docker:docker.bzl", "docker_build", "docker_push")
load("@io_bazel_rules_docker//container:container.bzl", "container_image", "container_push")
docker_build(
container_image(
name = "image",
base = "@official_busybox//image",
entrypoint = ["/kubemark"],
files = ["//cmd/kubemark"],
stamp = True,
)
docker_push(
container_push(
name = "push",
format = "Docker",
image = ":image",
registry = "$(REGISTRY)",
repository = "kubemark",