mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Merge pull request #23344 from colemickens/azure-cluster
Automatic merge from submit-queue azure: azkube v0.0.5 + deploy kube-system + hack/ script for hyperkube Update the Azure bring up. Also added a script `hack/dev-push-hyperkube.sh` for fast iteration on changes. One can deploy a cluster with a given hyperkube image reference and then use this script to rapidly iterate on changes. Testing changes just requires pulling the updated hyperkube image on the boxes and then cycling kubelet/docker or restarting the node. <!-- Reviewable:start --> --- This change is [<img src="http://reviewable.k8s.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](http://reviewable.k8s.io/reviews/kubernetes/kubernetes/23344) <!-- Reviewable:end -->
This commit is contained in:
commit
c1c8537a96
@ -34,6 +34,9 @@ KUBE_CONFIG_FILE="${KUBE_CONFIG_FILE:-"${DIR}/config-default.sh"}"
|
|||||||
source "${KUBE_CONFIG_FILE}"
|
source "${KUBE_CONFIG_FILE}"
|
||||||
source "${KUBE_ROOT}/cluster/common.sh"
|
source "${KUBE_ROOT}/cluster/common.sh"
|
||||||
|
|
||||||
|
AZKUBE_VERSION="v0.0.5"
|
||||||
|
REGISTER_MASTER_KUBELET="true"
|
||||||
|
|
||||||
function verify-prereqs() {
|
function verify-prereqs() {
|
||||||
required_binaries=("docker" "jq")
|
required_binaries=("docker" "jq")
|
||||||
|
|
||||||
@ -152,41 +155,59 @@ function ensure-hyperkube() {
|
|||||||
export AZURE_HYPERKUBE_SPEC="${user_image_tag}"
|
export AZURE_HYPERKUBE_SPEC="${user_image_tag}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function azure-deploy(){
|
function deploy-kube-system() {
|
||||||
declare -a auth_params
|
kubectl create -f - <<EOF
|
||||||
declare -a docker_params
|
apiVersion: v1
|
||||||
declare -a resource_group_params
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: kube-system
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
function get-common-params() {
|
||||||
|
declare -a AZKUBE_AUTH_PARAMS
|
||||||
|
declare -a AZKUBE_DOCKER_PARAMS
|
||||||
|
declare -a AZKUBE_RESOURCE_GROUP_PARAM
|
||||||
|
|
||||||
case "${AZURE_AUTH_METHOD}" in
|
case "${AZURE_AUTH_METHOD}" in
|
||||||
"client_secret")
|
"client_secret")
|
||||||
auth_params+=("--client-id=${AZURE_CLIENT_ID}" "--client-secret=${AZURE_CLIENT_SECRET}")
|
AZKUBE_AUTH_PARAMS+=("--client-id=${AZURE_CLIENT_ID}" "--client-secret=${AZURE_CLIENT_SECRET}")
|
||||||
;;
|
;;
|
||||||
"device")
|
"device")
|
||||||
auth_params+=()
|
AZKUBE_AUTH_PARAMS=()
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
if [[ ! -z "${AZURE_HTTPS_PROXY:-}" ]]; then
|
if [[ ! -z "${AZURE_HTTPS_PROXY:-}" ]]; then
|
||||||
docker_params+=("--net=host" "--env=https_proxy=${AZURE_HTTPS_PROXY}")
|
docker_params+=("--net=host" "--env=https_proxy=${AZURE_HTTPS_PROXY}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -z "${AZURE_RESOURCE_GROUP:-}" ]]; then
|
if [[ ! -z "${AZURE_RESOURCE_GROUP_PARAM:-}" ]]; then
|
||||||
echo "Forcing use of resource group ${AZURE_RESOURCE_GROUP}"
|
echo "Forcing use of resource group ${AZURE_RESOURCE_GROUP_PARAM}"
|
||||||
resource_group_params+=("--resource-group=${AZURE_RESOURCE_GROUP}")
|
resource_group_params+=("--resource-group=${AZURE_RESOURCE_GROUP_PARAM}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
export AZKUBE_AUTH_PARAMS
|
||||||
|
export AZKUBE_DOCKER_PARAMS
|
||||||
|
export AZKUBE_RESOURCE_GROUP_PARAM
|
||||||
|
}
|
||||||
|
|
||||||
|
function azure-deploy(){
|
||||||
|
get-common-params
|
||||||
|
|
||||||
docker run -it \
|
docker run -it \
|
||||||
--user "$(id -u)" \
|
--user "$(id -u)" \
|
||||||
"${docker_params[@]:+${docker_params[@]}}" \
|
"${AZKUBE_DOCKER_PARAMS[@]:+${AZKUBE_DOCKER_PARAMS[@]}}" \
|
||||||
-v "$HOME/.azkube:/.azkube" -v "/tmp:/tmp" \
|
-v "$HOME/.azkube:/.azkube" -v "/tmp:/tmp" \
|
||||||
-v "${AZURE_OUTPUT_DIR}:/opt/azkube/${AZURE_OUTPUT_RELDIR}" \
|
-v "${AZURE_OUTPUT_DIR}:/opt/azkube/${AZURE_OUTPUT_RELDIR}" \
|
||||||
colemickens/azkube:v0.0.2 /opt/azkube/azkube deploy \
|
"colemickens/azkube:${AZKUBE_VERSION}" /opt/azkube/azkube deploy \
|
||||||
--kubernetes-hyperkube-spec="${AZURE_HYPERKUBE_SPEC}" \
|
--kubernetes-hyperkube-spec="${AZURE_HYPERKUBE_SPEC}" \
|
||||||
--deployment-name="${AZURE_DEPLOY_ID}" \
|
--deployment-name="${AZURE_DEPLOY_ID}" \
|
||||||
--location="${AZURE_LOCATION}" \
|
--location="${AZURE_LOCATION}" \
|
||||||
"${resource_group_params[@]:+${resource_group_params[@]}}" \
|
"${AZKUBE_RESOURCE_GROUP_PARAM[@]:+${AZKUBE_RESOURCE_GROUP_PARAM[@]}}" \
|
||||||
--subscription-id="${AZURE_SUBSCRIPTION_ID}" \
|
--subscription-id="${AZURE_SUBSCRIPTION_ID}" \
|
||||||
--auth-method="${AZURE_AUTH_METHOD}" "${auth_params[@]:+${auth_params[@]}}" \
|
--auth-method="${AZURE_AUTH_METHOD}" "${AZKUBE_AUTH_PARAMS[@]:+${AZKUBE_AUTH_PARAMS[@]}}" \
|
||||||
--master-size="${AZURE_MASTER_SIZE}" \
|
--master-size="${AZURE_MASTER_SIZE}" \
|
||||||
--node-size="${AZURE_NODE_SIZE}" \
|
--node-size="${AZURE_NODE_SIZE}" \
|
||||||
--node-count="${NUM_NODES}" \
|
--node-count="${NUM_NODES}" \
|
||||||
@ -226,6 +247,8 @@ function kube-up {
|
|||||||
kubectl config set-context "${AZURE_DEPLOY_ID}" --cluster="${AZURE_DEPLOY_ID}" --user="${AZURE_DEPLOY_ID}_user"
|
kubectl config set-context "${AZURE_DEPLOY_ID}" --cluster="${AZURE_DEPLOY_ID}" --user="${AZURE_DEPLOY_ID}_user"
|
||||||
kubectl config use-context "${AZURE_DEPLOY_ID}"
|
kubectl config use-context "${AZURE_DEPLOY_ID}"
|
||||||
|
|
||||||
|
deploy-kube-system
|
||||||
|
|
||||||
enddate="$(date +%s)"
|
enddate="$(date +%s)"
|
||||||
duration="$(( (startdate - enddate) ))"
|
duration="$(( (startdate - enddate) ))"
|
||||||
|
|
||||||
@ -258,11 +281,11 @@ function kube-down {
|
|||||||
docker run -it \
|
docker run -it \
|
||||||
--user "$(id -u)" \
|
--user "$(id -u)" \
|
||||||
-v "$HOME/.azkube:/.azkube" -v "/tmp:/tmp" \
|
-v "$HOME/.azkube:/.azkube" -v "/tmp:/tmp" \
|
||||||
"${docker_params[@]:+${docker_params[@]}}" \
|
"${AZKUBE_DOCKER_PARAMS[@]:+${AZKUBE_DOCKER_PARAMS[@]}}" \
|
||||||
colemickens/azkube:v0.0.2 /opt/azkube/azkube destroy \
|
"colemickens/azkube:${AZKUBE_VERSION}" /opt/azkube/azkube destroy \
|
||||||
--deployment-name="${AZURE_DEPLOY_ID}" \
|
--deployment-name="${AZURE_DEPLOY_ID}" \
|
||||||
--subscription-id="${AZURE_SUBSCRIPTION_ID}" \
|
--subscription-id="${AZURE_SUBSCRIPTION_ID}" \
|
||||||
--auth-method="${AZURE_AUTH_METHOD}" \
|
--auth-method="${AZURE_AUTH_METHOD}" "${AZKUBE_AUTH_PARAMS[@]:+${AZKUBE_AUTH_PARAMS[@]}}" \
|
||||||
"${destroy_params[@]:+${destroy_params[@]}}" \
|
"${destroy_params[@]:+${destroy_params[@]}}" \
|
||||||
"${AZURE_AZKUBE_ARGS[@]:+${AZURE_AZKUBE_ARGS[@]}}"
|
"${AZURE_AZKUBE_ARGS[@]:+${AZURE_AZKUBE_ARGS[@]}}"
|
||||||
}
|
}
|
||||||
|
49
hack/dev-push-hyperkube.sh
Executable file
49
hack/dev-push-hyperkube.sh
Executable file
@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Copyright 2014 The Kubernetes Authors All rights reserved.
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
# This script will build the hyperkube image and push it to the repository
|
||||||
|
# referred to by KUBE_DOCKER_REGISTRY and KUBE_DOCKER_OWNER. The image will
|
||||||
|
# be given a version tag with the value from KUBE_DOCKER_VERSION.
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
|
||||||
|
source "${KUBE_ROOT}/build/common.sh"
|
||||||
|
|
||||||
|
if [[ -z "${KUBE_DOCKER_REGISTRY:-}" ]]; then
|
||||||
|
echo "KUBE_DOCKER_REGISTRY must be set"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
if [[ -z "${KUBE_DOCKER_OWNER:-}" ]]; then
|
||||||
|
echo "KUBE_DOCKER_OWNER must be set"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
if [[ -z "${KUBE_DOCKER_VERSION:-}" ]]; then
|
||||||
|
echo "KUBE_DOCKER_VERSION must be set"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
kube::build::verify_prereqs
|
||||||
|
kube::build::build_image
|
||||||
|
kube::build::run_build_command hack/build-go.sh cmd/hyperkube
|
||||||
|
|
||||||
|
REGISTRY="${KUBE_DOCKER_REGISTRY}/${KUBE_DOCKER_OWNER}" \
|
||||||
|
VERSION="${KUBE_DOCKER_VERSION}" \
|
||||||
|
make -C "${KUBE_ROOT}/cluster/images/hyperkube" build
|
||||||
|
|
||||||
|
docker push "${KUBE_DOCKER_REGISTRY}/${KUBE_DOCKER_OWNER}/hyperkube-amd64:${KUBE_DOCKER_VERSION}"
|
Loading…
Reference in New Issue
Block a user