Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
89e4dd5d
Commit
89e4dd5d
authored
Oct 12, 2016
by
Kubernetes Submit Queue
Committed by
GitHub
Oct 12, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #34438 from wojtek-t/small_fixed_for_migrations
Automatic merge from submit-queue Minor fixes to migrate-if-needed script Ref #22448 #20504 @lavalamp
parents
b65a07b2
ff1f002f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
17 deletions
+25
-17
Dockerfile
cluster/images/etcd/Dockerfile
+2
-2
Makefile
cluster/images/etcd/Makefile
+7
-3
migrate-if-needed.sh
cluster/images/etcd/migrate-if-needed.sh
+16
-12
No files found.
cluster/images/etcd/Dockerfile
View file @
89e4dd5d
...
...
@@ -13,8 +13,8 @@
# limitations under the License.
FROM
BASEIMAGE
MAINTAINER
Dawn Chen <dawnchen
@google.com>
MAINTAINER
Wojciech Tyczynski <wojtekt
@google.com>
EXPOSE
2379 2380 4001 7001
COPY
etcd* etcdctl* /usr/local/bin/
COPY
migrate-if-needed.sh attachlease /usr/local/bin/
COPY
migrate-if-needed.sh attachlease
rollback
/usr/local/bin/
cluster/images/etcd/Makefile
View file @
89e4dd5d
...
...
@@ -15,7 +15,7 @@
# Build the etcd image
#
# Usage:
# [TAGS=2.2.1 2.3.7 3.0.1
0
] [REGISTRY=gcr.io/google_containers] [ARCH=amd64] [BASEIMAGE=busybox] make (build|push)
# [TAGS=2.2.1 2.3.7 3.0.1
2
] [REGISTRY=gcr.io/google_containers] [ARCH=amd64] [BASEIMAGE=busybox] make (build|push)
# The image contains different etcd versions to simplify
# upgrades. Thus be careful when removing any tag from here.
...
...
@@ -26,8 +26,8 @@
# Except from etcd-$(tag) and etcdctl-$(tag) binaries, we also
# need etcd and etcdctl binaries for backward compatibility reasons.
# That binary will be set to the last tag from $(TAGS).
TAGS
?=
2.2.1 2.3.7 3.0.1
0
REGISTRY_TAG
?=
3.0.1
0
TAGS
?=
2.2.1 2.3.7 3.0.1
2
REGISTRY_TAG
?=
3.0.1
2
ARCH
?=
amd64
REGISTRY
?=
gcr.io/google_containers
GOLANG_VERSION
?=
1.6.3
...
...
@@ -55,6 +55,10 @@ build:
# Compile attachlease
docker run -it -v $(shell pwd)/../../../
:
/go/src/k8s.io/kubernetes -v $(TEMP_DIR):/build -e GOARCH=$(ARCH) golang:$(GOLANG_VERSION)
\
/bin/bash -c "CGO_ENABLED=0 go build -o /build/attachlease k8s.io/kubernetes/cluster/images/etcd/attachlease"
# Compile rollback
docker run
-it
-v
$(
shell
pwd
)
/../../../:/go/src/k8s.io/kubernetes
-v
$(TEMP_DIR)
:/build
-e
GOARCH
=
$(ARCH)
golang:
$(GOLANG_VERSION)
\
/bin/bash
-c
"CGO_ENABLED=0 go build -o /build/rollback k8s.io/kubernetes/cluster/images/etcd/rollback"
ifeq
($(ARCH),amd64)
...
...
cluster/images/etcd/migrate-if-needed.sh
View file @
89e4dd5d
...
...
@@ -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.1
0
')
# TARGET_VERSION - etcd release to be used (supported: '2.2.1', '2.3.7', '3.0.1
2
')
# DATA_DIRECTORY - directory with etcd data
#
# The current etcd version and storage format is detected based on the
...
...
@@ -27,8 +27,8 @@
#
# The update workflow support the following upgrade steps:
# - 2.2.1/etcd2 -> 2.3.7/etcd2
# - 2.3.7/etcd2 -> 3.0.1
0
/etcd2
# - 3.0.1
0/etcd2 -> 3.0.10
/etcd3
# - 2.3.7/etcd2 -> 3.0.1
2
/etcd2
# - 3.0.1
2/etcd2 -> 3.0.12
/etcd3
#
# NOTE: The releases supported in this script has to match release binaries
# present in the etcd image (to make this script work correctly).
...
...
@@ -59,7 +59,7 @@ fi
# NOTE: SUPPORTED_VERSION has to match release binaries present in the
# etcd image (to make this script work correctly).
SUPPORTED_VERSIONS
=(
"2.2.1"
"2.3.7"
"3.0.1
0
"
)
SUPPORTED_VERSIONS
=(
"2.2.1"
"2.3.7"
"3.0.1
2
"
)
VERSION_FILE
=
"version.txt"
CURRENT_STORAGE
=
"etcd2"
...
...
@@ -73,6 +73,18 @@ if [ -e "${DATA_DIRECTORY}/${VERSION_FILE}" ]; then
CURRENT_STORAGE
=
"
$(
echo
$VERSION_CONTENTS
|
cut
-d
'/'
-f
2
)
"
fi
# If there is no data in DATA_DIRECTORY, this means that we are
# starting etcd from scratch. In that case, we don't need to do
# any migration.
if
[
!
-d
"
${
DATA_DIRECTORY
}
"
]
;
then
mkdir
-p
"
${
DATA_DIRECTORY
}
"
fi
if
[
-z
"
$(
ls
-A
${
DATA_DIRECTORY
})
"
]
;
then
echo
"
${
DATA_DIRECTORY
}
is empty - skipping migration"
echo
"
${
TARGET_VERSION
}
/
${
TARGET_STORAGE
}
"
>
"
${
DATA_DIRECTORY
}
/
${
VERSION_FILE
}
"
exit
0
fi
# Starts 'etcd' version ${START_VERSION} and writes to it:
# 'etcd_version' -> "${START_VERSION}"
# Successful write confirms that etcd is up and running.
...
...
@@ -138,8 +150,6 @@ for step in "${SUPPORTED_VERSIONS[@]}"; do
if
[
"
${
CURRENT_VERSION
:0:2
}
"
==
"3."
-a
"
${
CURRENT_STORAGE
}
"
==
"etcd2"
-a
"
${
TARGET_STORAGE
}
"
==
"etcd3"
]
;
then
# If it is the first 3.x release in the list and we are migrating
# also from 'etcd2' to 'etcd3', do the migration now.
if
[
-d
"
${
DATA_DIRECTORY
}
"
]
;
then
if
[
"
$(
ls
-A
${
DATA_DIRECTORY
})
"
]
;
then
echo
"Performing etcd2 -> etcd3 migration"
START_VERSION
=
"
${
step
}
"
START_STORAGE
=
"etcd3"
...
...
@@ -160,8 +170,6 @@ for step in "${SUPPORTED_VERSIONS[@]}"; do
--lease-duration
1h
# Kill etcd and wait until this is down.
stop_etcd
fi
fi
CURRENT_STORAGE
=
"etcd3"
echo
"
${
CURRENT_VERSION
}
/
${
CURRENT_STORAGE
}
"
>
"
${
DATA_DIRECTORY
}
/
${
VERSION_FILE
}
"
fi
...
...
@@ -178,16 +186,12 @@ if [ "${CURRENT_STORAGE}" == "etcd3" -a "${TARGET_STORAGE}" == "etcd2" ]; then
echo
"etcd3 -> etcd2 downgrade is supported only between 3.0.x and 2.3.7"
return
0
fi
if
[
-d
"
${
DATA_DIRECTORY
}
"
]
;
then
if
[
"
$(
ls
-A
${
DATA_DIRECTORY
})
"
]
;
then
echo
"Performing etcd3 -> etcd2 rollback"
${
ROLLBACK
}
--data-dir
"
${
DATA_DIRECTORY
}
"
if
[
"
$?
"
-ne
"0"
]
;
then
echo
"Rollback to etcd2 failed"
exit
1
fi
fi
fi
CURRENT_STORAGE
=
"etcd2"
CURRENT_VERSION
=
"2.3.7"
echo
"
${
CURRENT_VERSION
}
/
${
CURRENT_STORAGE
}
"
>
"
${
DATA_DIRECTORY
}
/
${
VERSION_FILE
}
"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment