Skip to content

Commit

Permalink
Merge branch 'tkestack:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
GaoXiaodong committed Aug 12, 2021
2 parents 4da8f4b + f556820 commit b33df98
Show file tree
Hide file tree
Showing 54 changed files with 785 additions and 1,129 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ release.build:
ifeq ($(NEED_BUILD_PROVIDER),true)
cd build/docker/tools/provider-res && make all
endif
make manifest.multiarch
make push.multiarch

## release: Release tke
.PHONY: release
Expand Down
6 changes: 0 additions & 6 deletions api/openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions api/platform/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,6 @@ const (
GPUVirtual GPUType = "Virtual"
)

type ContainerRuntimeType = string

const (
Containerd ContainerRuntimeType = "containerd"
Docker ContainerRuntimeType = "docker"
)

// ClusterPhase defines the phase of cluster constructor.
type ClusterPhase string

Expand Down Expand Up @@ -391,8 +384,6 @@ type ClusterFeature struct {
// +optional
EnableCilium bool
// +optional
ContainerRuntime ContainerRuntimeType
// +optional
IPv6DualStack bool
// Upgrade control upgrade process.
// +optional
Expand Down
771 changes: 365 additions & 406 deletions api/platform/v1/generated.pb.go

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions api/platform/v1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions api/platform/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,6 @@ const (
GPUVirtual GPUType = "Virtual"
)

type ContainerRuntimeType = string

const (
Containerd ContainerRuntimeType = "containerd"
Docker ContainerRuntimeType = "docker"
)

// ClusterPhase defines the phase of cluster constructor.
type ClusterPhase string

Expand Down Expand Up @@ -398,8 +391,6 @@ type ClusterFeature struct {
IPv6DualStack bool `json:"ipv6DualStack,omitempty" protobuf:"bytes,13,opt,name=ipv6DualStack"`
// +optional
EnableCilium bool `json:"enableCilium,omitempty" protobuf:"bytes,14,opt,name=enableCilium"`
// +optional
ContainerRuntime ContainerRuntimeType `json:"containerRuntime,omitempty" protobuf:"bytes,15,opt,name=containerRuntime"`
// Upgrade control upgrade process.
// +optional
Upgrade Upgrade `json:"upgrade,omitempty" protobuf:"bytes,22,opt,name=upgrade"`
Expand Down
2 changes: 0 additions & 2 deletions api/platform/v1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions build/docker/tools/provider-res/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@ COPY linux-arm64/conntrack-tools-*.tar.gz res/linux-arm64/
COPY linux-amd64/docker-*.tar.gz res/linux-amd64/
COPY linux-arm64/docker-*.tar.gz res/linux-arm64/

COPY linux-amd64/nerdctl-*.tar.gz res/linux-amd64/
COPY linux-arm64/nerdctl-*.tar.gz res/linux-arm64/

COPY linux-amd64/containerd-*.tar.gz res/linux-amd64/
COPY linux-arm64/containerd-*.tar.gz res/linux-arm64/

COPY linux-amd64/critools-*.tar.gz res/linux-amd64/
COPY linux-arm64/critools-*.tar.gz res/linux-arm64/

COPY linux-amd64/kubernetes-*.tar.gz res/linux-amd64/
COPY linux-arm64/kubernetes-*.tar.gz res/linux-arm64/

Expand Down
2 changes: 1 addition & 1 deletion build/docker/tools/provider-res/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations under the License.

IMAGE = provider-res
VERSION = v1.20.4-2
VERSION = v1.20.4-1
REGISTRY_PREFIX ?= tkestack

COMMON_SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
Expand Down
54 changes: 0 additions & 54 deletions build/docker/tools/provider-res/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,57 +56,6 @@ function download::docker() {
done
}

function download::containerd() {
if [ "${arch}" == "amd64" ]; then
containerd_arch=amd64
for version in ${CONTAINERD_VERSIONS}; do
wget -c "https://github.com/containerd/containerd/releases/download/v${version}/cri-containerd-cni-${version}-linux-${containerd_arch}.tar.gz" \
-O "containerd-${platform}-${version}.tar.gz"
done
elif [ "${arch}" == "arm64" ]; then
containerd_arch=arm64
for version in ${CONTAINERD_VERSIONS}; do
wget -c https://tke-release-1251707795.cos.ap-guangzhou.myqcloud.com/cri-containerd-cni-${version}-linux-{containerd_arch}.tar.gz \
-O "containerd-${platform}-${version}.tar.gz"
done
else
echo "[ERROR] Fail to get containerd ${arch} on ${platform} platform."
exit 255
fi
}

function download::nerdctl() {
if [ "${arch}" == "amd64" ]; then
nerdctl_arch=x86_64
elif [ "${arch}" == "arm64" ]; then
nerdctl_arch=arm64
else
echo "[ERROR] Fail to get nerdctl ${arch} on ${platform} platform."
exit 255
fi

for version in ${NERDCTL_VERSIONS}; do
wget -c "https://github.com/containerd/nerdctl/releases/download/v${version}/nerdctl-${version}-linux-${arch}.tar.gz" \
-O "nerdctl-${platform}-${version}.tar.gz"
done
}

function download::critools() {
if [ "${arch}" == "amd64" ]; then
critools_arch=amd64
elif [ "${arch}" == "arm64" ]; then
critools_arch=arm
else
echo "[ERROR] Fail to get critools ${arch} on ${platform} platform."
exit 255
fi

for version in ${CRITOOLS_VERSIONS}; do
wget -c "https://github.com/kubernetes-sigs/cri-tools/releases/download/${version}/crictl-${version}-linux-${critools_arch}.tar.gz" \
-O "critools-${platform}-${version}.tar.gz"
done
}

function download::kubernetes() {
for version in ${K8S_VERSIONS}; do
if [[ "${version}" =~ "tke" ]]; then
Expand Down Expand Up @@ -166,9 +115,6 @@ for os in ${OSS}; do

download::cni_plugins
download::docker
download::containerd
download::nerdctl
download::critools
download::kubernetes
download::nvidia_driver
download::nvidia_container_runtime
Expand Down
12 changes: 2 additions & 10 deletions build/docker/tools/tke-installer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,24 @@
# WARRANTIES OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

FROM alpine:3.14.0
FROM alpine:3.10

RUN echo "hosts: files dns" >> /etc/nsswitch.conf

WORKDIR /app

ENV PATH="/app/bin:$PATH"
ENV DOCKER_CLI_EXPERIMENTAL=enabled
ARG ENV_ARCH

RUN apk add --no-cache \
bash \
busybox-extras \
curl \
tcpdump \
docker \
ansible \
containerd
ansible

RUN apk --update-cache --repository http:https://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted add lrzsz
RUN wget -O nerdctl-0.10.0-linux.tar.gz https://github.com/containerd/nerdctl/releases/download/v0.10.0/nerdctl-0.10.0-linux-"$ENV_ARCH".tar.gz \
&& tar -zvxf nerdctl-0.10.0-linux.tar.gz -C /usr/local/bin/ \
&& rm -rf nerdctl-0.10.0-linux.tar.gz \
&& wget -O crictl-v1.20.0-linux.tar.gz https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.20.0/crictl-v1.20.0-linux-"$ENV_ARCH".tar.gz \
&& tar -zvxf crictl-v1.20.0-linux.tar.gz -C /usr/local/bin/ \
&& rm -rf crictl-v1.20.0-linux.tar.gz

ADD . /app

Expand Down
89 changes: 32 additions & 57 deletions build/docker/tools/tke-installer/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,18 @@ unset LD_LIBRARY_PATH
export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'

VERSION=latest
REGISTRY_VERSION=2.7.1

INSTALL_DIR=/opt/tke-installer
DATA_DIR=$INSTALL_DIR/data
REGISTRY_DIR=$INSTALL_DIR/registry
OPTIONS="--name tke-installer -d --privileged --net=host --restart=always
-v /etc/hosts:/app/hosts
-v /var/run/containerd/:/var/run/containerd/
-v /run/containerd/:/run/containerd/
-v /etc/docker:/etc/docker
-v /var/run/docker.sock:/var/run/docker.sock
-v $DATA_DIR:/app/data
-v $INSTALL_DIR/conf:/app/conf
-v registry-certs:/app/certs
-v tke-installer-bin:/app/bin
"
RegistryHTTPOptions="--name registry-http -d --net=host --restart=always -p 80:5000
-v $REGISTRY_DIR:/var/lib/registry
"
RegistryHTTPSOptions="--name registry-https -d --net=host --restart=always -p 443:443
-v $REGISTRY_DIR:/var/lib/registry
-v registry-certs:/certs
-e REGISTRY_HTTP_ADDR=0.0.0.0:443
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/server.crt
-e REGISTRY_HTTP_TLS_KEY=/certs/server.key
"

declare -A archMap=(
[x86_64]=amd64
Expand Down Expand Up @@ -93,61 +81,59 @@ function check::disk() {
echo "available disk space($path): $disk_avail GiB"
}

function ensure_containerd() {
echo "Step.2 check containerd status"
function ensure_docker() {
echo "Step.2 check docker status"

if ! [ -x "$(command -v nerdctl)" ]; then
echo "command nerdctl not find"
install_containerd
if ! [ -x "$(command -v docker)" ]; then
echo "command docker not find"
install_docker
fi
if ! systemctl is-active --quiet containerd; then
echo "containerd status is not running"
install_containerd
if ! systemctl is-active --quiet docker; then
echo "docker status is not running"
install_docker
fi
}

function install_containerd() {
echo "install containerd [in process]"
function install_docker() {
echo "install docker [in process]"

tar xvaf "res/containerd.tar.gz" -C / >/dev/null 2>&1
tar xvaf "res/nerdctl.tar.gz" -C /usr/local/bin/ >/dev/null 2>&1
tar xvaf "res/docker.tgz" -C /usr/bin --strip-components=1
cp -v res/docker.service /etc/systemd/system
mkdir -p /etc/docker
cp -v res/daemon.json /etc/docker/

systemctl daemon-reload

# becuase first start docker may be restart some times
systemctl start containerd || :
systemctl start docker || :
maxSecond=60
for i in $(seq 1 $maxSecond); do
if systemctl is-active --quiet containerd; then
if systemctl is-active --quiet docker; then
break
fi
sleep 1
done
if ((i == maxSecond)); then
echo "start containerd failed, please check containerd service."
echo "start docker failed, please check docker service."
exit 1
fi

echo "install containerd [done]"
rm -rf /etc/cni
echo "install docker [done]"
}

function load_image() {
echo "Step.3 load tke-installer image [in process]"

nerdctl load -i res/tke-installer.tar
nerdctl load -i res/registry.tar
docker load -i res/tke-installer.tgz

echo "Step.3 load tke-installer image [done]"
}

function clean_old_data() {
echo "Step.4 clean old data [in process]"

nerdctl stop tke-installer && nerdctl rm tke-installer >/dev/null 2>&1 || :
nerdctl stop registry-http && nerdctl rm registry-http >/dev/null 2>&1 || :
nerdctl stop registry-https && nerdctl rm registry-https >/dev/null 2>&1 || :
nerdctl volume rm tke-installer-bin >/dev/null 2>&1 || :
nerdctl volume rm registry-certs >/dev/null 2>&1 || :
docker rm -f tke-installer >/dev/null 2>&1 || :
docker volume prune -f >/dev/null 2>&1 || :

if [ -d "$DATA_DIR" ]; then
rm -f $DATA_DIR/tke.json >/dev/null 2>&1 || :
Expand All @@ -159,48 +145,37 @@ function clean_old_data() {

function start_installer() {
echo "Step.5 start tke-installer [in process]"
mkdir -p $DATA_DIR
mkdir -p $INSTALL_DIR/conf
nerdctl run $OPTIONS "tkestack/tke-installer-${ARCH}:$VERSION" $@

echo "Step.5 start tke-installer [done]"
}

function start_registry() {
echo "Step.6 start regisry [in process]"
docker run $OPTIONS "tkestack/tke-installer-${ARCH}:$VERSION" $@

mkdir -p $REGISTRY_DIR
nerdctl run $RegistryHTTPOptions "tkestack/registry-${ARCH}:$REGISTRY_VERSION" $@
nerdctl run $RegistryHTTPSOptions "tkestack/registry-${ARCH}:$REGISTRY_VERSION" $@
echo "Step.6 start registry [done]"
echo "Step.5 start tke-installer [done]"
}


function check_installer() {
s=10
for i in $(seq 1 $s)
do
echo "Step.7 check tke-installer status [in process]"
echo "Step.6 check tke-installer status [in process]"
url="http:https://127.0.0.1:8080/index.html"
if ! curl -sSf "$url" >/dev/null 2>&1; then
sleep 3
echo "Step.7 retries left $(($s-$i))"
echo "Step.6 retries left $(($s-$i))"
continue
else
echo "Step.7 check tke-installer status [done]"
echo "Step.6 check tke-installer status [done]"
echo "Please use your browser which can connect this machine to open $url for install TKE!"
exit 0
fi
done
echo "check installer status error"
nerdctl logs tke-installer
exit 1
docker logs tke-installer
exit 1
}

preflight
ensure_containerd
ensure_docker
load_image
clean_old_data
start_installer $@
start_registry $@
check_installer
Loading

0 comments on commit b33df98

Please sign in to comment.