-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add doc for development with Alicloud #8275
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Development process for Alicloud | ||
|
||
This document contains details about ongoing effort for Alicloud support in | ||
kops. Alicloud support in kops is an experimental feature, under | ||
`KOPS_FEATURE_FLAGS=AlphaAllowALI` feature flag and is not production ready yet. | ||
|
||
# Current status | ||
|
||
Please refer to this | ||
[issue](https://github.com/kubernetes/kops/issues/4127#issuecomment-534536277) | ||
for the to-do list. | ||
|
||
In order to get Alicloud support out of alpha. At least, these two | ||
PRs([#7849|https://github.com/kubernetes/kops/pull/7849] and | ||
[#8016|https://github.com/kubernetes/kops/pull/8016]) need to be merged. | ||
|
||
NOTE: The following instructions don't work for `master` branch. If you start | ||
developing with Alicloud, you will need to cherry-pick these two PRs onto your own develop branch first after you clone | ||
`master` branch. | ||
|
||
# Mirror docker images to Alicloud container registry | ||
|
||
The required images are listed in `hack/alicloud/required-images.txt`. Before | ||
you run `./hack/alicloud/mirror.sh`*, you need to: | ||
|
||
1. Install `docker` on your laptop | ||
2. Create a namespace in Alicloud container registry(eg: `kops-mirror`) in the | ||
web console. | ||
2. run dev-build-alicloud.sh | ||
|
||
|
||
You can use the example command as below to quickly starting developing nodeup | ||
and kops. | ||
|
||
```sh | ||
export KOPS_VERSION=1.15.0-alpha.1 | ||
export CLUSTER_NAME=dev-1.k8s.local | ||
export KOPS_STATE_STORE=oss://kops-state-bucket | ||
export NODEUP_BUCKET=k8s-assets-bucket | ||
export IMAGE=m-xxxxxxxxxx | ||
export ALICLOUD_REGION=cn-shanghai | ||
export ALIYUN_ACCESS_KEY_ID=xxxxxx | ||
export ALIYUN_ACCESS_KEY_SECRET=xxxxxxxxxxxxxxx | ||
export OSS_REGION=oss-cn-shanghai | ||
export KOPS_FEATURE_FLAGS="AlphaAllowALI" | ||
export NODEUP_URL=https://${NODEUP_BUCKET}.${OSS_REGION}.aliyuncs.com/kops/${KOPS_VERSION}/linux/amd64/nodeup | ||
export KOPS_BASE_URL=https://${NODEUP_BUCKET}.${OSS_REGION}.aliyuncs.com/kops/${KOPS_VERSION}/ | ||
export KOPS_CREATE=no | ||
|
||
# cd [kops_dir] | ||
./hack/alicloud/dev-build.sh | ||
``` | ||
|
||
# Ref | ||
|
||
- The script `hack/alicloud/mirror.sh` is partially copied from | ||
https://github.com/nwcdlabs/kops-cn/blob/master/mirror/mirror-images.sh, | ||
thanks to [Pahud Hsieh](https://github.com/pahud). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2019 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. | ||
|
||
|
||
############################################################################### | ||
# | ||
# dev-build-alicloud.sh | ||
# | ||
# Convenience script for developing kops AND nodeup on Alicloud. | ||
# | ||
# This script (by design) will handle building a full kops cluster in Alicloud, | ||
# with a custom version of the nodeup, protokube and dnscontroller. | ||
# | ||
# This script and Makefile uses aliyun client | ||
# https://github.com/aliyun/aliyun-cli | ||
# and make sure you `aliyun configure` | ||
# | ||
# # Example usage | ||
# | ||
# KOPS_STATE_STORE="oss://my-dev-oss-state" \ | ||
# CLUSTER_NAME="fullcluster.name.k8s.local" \ | ||
# NODEUP_BUCKET="oss-devel-bucket-name-store-nodeup" \ | ||
# IMAGE="m-xxxxxxxxxxxxxxxxxxxxxxx" \ | ||
# ./hack/alicloud/dev-build.sh | ||
# | ||
# # TLDR; | ||
# 1. create oss buckets - state store and nodeup bucket | ||
# 2. set zones appropriately, you need 3 zones in a region for HA | ||
# 3. run script | ||
# 4. use ssh-agent and ssh -A | ||
# 5. your pem will be the access token | ||
# | ||
# # For more details see: | ||
# | ||
# https://github.com/kubernetes/kops/blob/master/docs/development/alicloud.md | ||
# | ||
############################################################################### | ||
|
||
KOPS_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
# | ||
# Check that required binaries are installed | ||
# | ||
command -v make >/dev/null 2>&1 || { echo >&2 "I require make but it's not installed. Aborting."; exit 1; } | ||
command -v go >/dev/null 2>&1 || { echo >&2 "I require go but it's not installed. Aborting."; exit 1; } | ||
command -v docker >/dev/null 2>&1 || { echo >&2 "I require docker but it's not installed. Aborting."; exit 1; } | ||
command -v aliyun >/dev/null 2>&1 || { echo >&2 "I require aliyun cli but it's not installed. Aborting."; exit 1; } | ||
|
||
# | ||
# Check that expected vars are set | ||
# | ||
[ -z "$KOPS_STATE_STORE" ] && echo "Need to set KOPS_STATE_STORE" && exit 1; | ||
[ -z "$CLUSTER_NAME" ] && echo "Need to set CLUSTER_NAME" && exit 1; | ||
[ -z "$NODEUP_BUCKET" ] && echo "Need to set NODEUP_BUCKET" && exit 1; | ||
[ -z "$IMAGE" ] && echo "Need to set IMAGE or use the image listed here https://github.com/kubernetes/kops/blob/master/channels/stable" && exit 1; | ||
|
||
# Cluster config | ||
KUBERNETES_VERSION=1.14.10 | ||
NODE_COUNT=${NODE_COUNT:-3} | ||
NODE_ZONES=${NODE_ZONES:-"cn-shanghai-e,cn-shanghai-f,cn-shanghai-g"} | ||
NODE_SIZE=${NODE_SIZE:-ecs.g6.large} | ||
MASTER_ZONES=${MASTER_ZONES:-"cn-shanghai-e,cn-shanghai-f,cn-shanghai-g"} | ||
MASTER_SIZE=${MASTER_SIZE:-ecs.g6.large} | ||
KOPS_CREATE=${KOPS_CREATE:-yes} | ||
|
||
# NETWORK | ||
TOPOLOGY=${TOPOLOGY:-private} | ||
NETWORKING=${NETWORKING:-flannel} | ||
|
||
# How verbose go logging is | ||
VERBOSITY=${VERBOSITY:-10} | ||
|
||
cd $KOPS_DIRECTORY/.. | ||
|
||
GIT_VER=git-$(git describe --always) | ||
[ -z "$GIT_VER" ] && echo "we do not have GIT_VER something is very wrong" && exit 1; | ||
|
||
echo ========== | ||
echo "Starting build" | ||
|
||
# removing CI=1 because it forces a new upload every time | ||
# export CI=1 | ||
make && OSS_BUCKET=oss://${NODEUP_BUCKET} make oss-upload | ||
if [[ $? -ne 0 ]]; then | ||
exit 1 | ||
fi | ||
|
||
# removing make test since it relies on the files in the bucket | ||
# && make test | ||
|
||
KOPS_VERSION=$(kops version --short) | ||
KOPS_BASE_URL="https://${NODEUP_BUCKET}.${OSS_REGION}.aliyuncs.com/kops/${KOPS_VERSION}/" | ||
|
||
echo "KOPS_BASE_URL=${KOPS_BASE_URL}" | ||
echo "NODEUP_URL=${KOPS_BASE_URL}linux/amd64/nodeup" | ||
|
||
echo ========== | ||
echo "Deleting cluster ${CLUSTER_NAME}..." | ||
|
||
kops delete cluster \ | ||
--name $CLUSTER_NAME \ | ||
--state $KOPS_STATE_STORE \ | ||
-v $VERBOSITY \ | ||
--yes | ||
|
||
echo ========== | ||
echo "Creating cluster ${CLUSTER_NAME}..." | ||
|
||
kops_command="export NODEUP_URL=${KOPS_BASE_URL}linux/amd64/nodeup; export KOPS_BASE_URL=${KOPS_BASE_URL}; kops create cluster --cloud=alicloud --name $CLUSTER_NAME --state $KOPS_STATE_STORE --node-count $NODE_COUNT --zones $NODE_ZONES --master-zones $MASTER_ZONES --node-size $NODE_SIZE --master-size $MASTER_SIZE -v $VERBOSITY --image $IMAGE --channel alpha --topology $TOPOLOGY --networking $NETWORKING --kubernetes-version $KUBERNETES_VERSION" | ||
|
||
# bastion is not supported in Alicloud yet | ||
# if [[ $TOPOLOGY == "private" ]]; then | ||
# kops_command+=" --bastion='true'" | ||
# fi | ||
|
||
if [ -n "${KOPS_FEATURE_FLAGS+x}" ]; then | ||
kops_command="export KOPS_FEATURE_FLAGS=${KOPS_FEATURE_FLAGS}; $kops_command" | ||
echo $kops_command | ||
fi | ||
|
||
if [[ $KOPS_CREATE == "yes" ]]; then | ||
kops_command="$kops_command --yes" | ||
fi | ||
|
||
eval $kops_command | ||
|
||
echo ========== | ||
echo "Your k8s cluster ${CLUSTER_NAME}, awaits your bidding." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2019 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. | ||
|
||
IMAGES_FILE='hack/alicloud/required-images.txt' | ||
repos=$(grep -v ^# $IMAGES_FILE | cut -d: -f1 | sort -u) | ||
|
||
ACR_DN='registry.cn-shanghai.aliyuncs.com/bkcn' | ||
|
||
function need_trim() { | ||
s=$1 | ||
for i in $NO_TRIM | ||
do | ||
if [ "${s/$i/}" == "$s" ]; then | ||
continue | ||
else | ||
return 1 | ||
fi | ||
done | ||
return 0 | ||
} | ||
|
||
function pull_and_push(){ | ||
origimg="$1" | ||
if need_trim $origimg; then | ||
echo "$origimg needs triming" | ||
# strip off the prefix | ||
img=${origimg/gcr.io\/google_containers\//} | ||
img=${img/k8s.gcr.io\//} | ||
target_img="$ACR_DN/${img//\//-}" | ||
else | ||
echo "$origimg does not need triming" | ||
target_img="$ACR_DN/$origimg" | ||
fi | ||
|
||
docker pull $origimg | ||
echo "tagging $origimg to $target_img" | ||
docker tag $origimg $target_img | ||
echo "[PUSH] remote image not exists or digests not match, pushing $target_img" | ||
docker push $target_img | ||
} | ||
|
||
for r in ${repos[@]} | ||
do | ||
if need_trim $r; then | ||
# strip off the prefix | ||
r=${r/gcr.io\/google_containers\//} | ||
r=${r/k8s.gcr.io\//} | ||
r=${r//\//-} | ||
fi | ||
done | ||
|
||
images=$(grep -v ^# $IMAGES_FILE) | ||
for i in ${images[@]} | ||
do | ||
pull_and_push $i | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Kops | ||
kope/dns-controller:1.15.0-beta.1 | ||
kope/kops-controller:1.15.0-alpha.1 | ||
|
||
# Kubernetes 1.16.4 | ||
gcr.io/google_containers/kube-apiserver:v1.16.4 | ||
gcr.io/google_containers/kube-scheduler:v1.16.4 | ||
gcr.io/google_containers/kube-proxy:v1.16.4 | ||
gcr.io/google_containers/kube-controller-manager:v1.16.4 | ||
|
||
# Kubernetes 1.14.10 | ||
gcr.io/google_containers/kube-apiserver:v1.14.10 | ||
gcr.io/google_containers/kube-scheduler:v1.14.10 | ||
gcr.io/google_containers/kube-proxy:v1.14.10 | ||
gcr.io/google_containers/kube-controller-manager:v1.14.10 | ||
|
||
# Network | ||
quay.io/coreos/flannel:v0.11.0-amd64 | ||
|
||
# Alibaba cloud controller manager | ||
bittopaz/alicloud-ccm-amd64:v1.9.3.164 | ||
|
||
# Other | ||
gcr.io/google_containers/pause-amd64:3.0 | ||
|
||
k8s.gcr.io/cluster-proportional-autoscaler-amd64:1.4.0 | ||
k8s.gcr.io/k8s-dns-sidecar-amd64:1.14.13 | ||
k8s.gcr.io/k8s-dns-kube-dns-amd64:1.14.13 | ||
k8s.gcr.io/k8s-dns-dnsmasq-nanny-amd64:1.14.13 | ||
k8s.gcr.io/etcd:3.3.10 | ||
k8s.gcr.io/coredns:1.3.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering how we'll keep these tags up to date. Perhaps
mirror.sh
could take a k8s version parameter? It could be used with these gcr.io/google_containers but the remaining images might be more tricky.Perhaps a notice that says this list isn't necessarily up to date and the user is responsible for determining all image tags they need