mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 06:54:01 +00:00
Adding automatic OS image download for Openstack provider.
This makes it so that we download the OS image automatically. Also contains other usability improvements: - kubectl context created with heat stack name - Bumped default minions to 3
This commit is contained in:
parent
5ae161e086
commit
2ffc86bc1d
@ -25,9 +25,9 @@ KUBERNETES_KEYPAIR_NAME=${KUBERNETES_KEYPAIR_NAME:-kubernetes_keypair}
|
||||
# Kubernetes release tar file
|
||||
KUBERNETES_RELEASE_TAR=${KUBERNETES_RELEASE_TAR:-kubernetes-server-linux-amd64.tar.gz}
|
||||
|
||||
NUMBER_OF_MINIONS=${NUMBER_OF_MINIONS-1}
|
||||
NUMBER_OF_MINIONS=${NUMBER_OF_MINIONS-3}
|
||||
|
||||
MAX_NUMBER_OF_MINIONS=${MAX_NUMBER_OF_MINIONS:-1}
|
||||
MAX_NUMBER_OF_MINIONS=${MAX_NUMBER_OF_MINIONS:-3}
|
||||
|
||||
MASTER_FLAVOR=${MASTER_FLAVOR:-m1.small}
|
||||
|
||||
@ -41,6 +41,9 @@ SWIFT_SERVER_URL=${SWIFT_SERVER_URL:-http://192.168.123.100:8080}
|
||||
# If 'true' then new image will be created from file config-image.sh
|
||||
CREATE_IMAGE=${CREATE_IMAGE:-true} # use "true" for devstack
|
||||
|
||||
# Flag indicates if image should be downloaded
|
||||
DOWNLOAD_IMAGE=${DOWNLOAD_IMAGE:-true}
|
||||
|
||||
# Image id which will be used for kubernetes stack
|
||||
IMAGE_ID=${IMAGE_ID:-f0f394b1-5546-4b68-b2bc-8abe8a7e6b8b}
|
||||
|
||||
|
@ -17,16 +17,19 @@
|
||||
## Contains configuration values for new image. It is skip when CREATE_IMAGE=false
|
||||
|
||||
# Image name which will be displayed in OpenStack
|
||||
OPENSTACK_IMAGE_NAME="CentOS7"
|
||||
OPENSTACK_IMAGE_NAME=${OPENSTACK_IMAGE_NAME:-CentOS7}
|
||||
|
||||
# Downloaded image name for Openstack project
|
||||
IMAGE_FILE="CentOS-7-x86_64-GenericCloud-1510.qcow2"
|
||||
IMAGE_FILE=${IMAGE_FILE:-CentOS-7-x86_64-GenericCloud-1510.qcow2}
|
||||
|
||||
# Absolute path where image file is stored.
|
||||
IMAGE_PATH="/home/openstack/openstack_temp"
|
||||
IMAGE_PATH=${IMAGE_PATH:-~/Downloads/openstack}
|
||||
|
||||
# The URL basepath for downloading the image
|
||||
IMAGE_URL_PATH=${IMAGE_URL_PATH:-http://cloud.centos.org/centos/7/images}
|
||||
|
||||
# The disk format of the image. Acceptable formats are ami, ari, aki, vhd, vmdk, raw, qcow2, vdi, and iso.
|
||||
IMAGE_FORMAT="qcow2"
|
||||
IMAGE_FORMAT=${IMAGE_FORMAT:-qcow2}
|
||||
|
||||
# The container format of the image. Acceptable formats are ami, ari, aki, bare, docker, and ovf.
|
||||
CONTAINER_FORMAT="bare"
|
||||
CONTAINER_FORMAT=${CONTAINER_FORMAT:-bare}
|
||||
|
@ -2,7 +2,7 @@ heat_template_version: 2014-10-16
|
||||
|
||||
description: >
|
||||
Kubernetes cluster with one master and one or more worker nodes
|
||||
(as specified by the number_of_minions parameter, which defaults to 2).
|
||||
(as specified by the number_of_minions parameter, which defaults to 3).
|
||||
|
||||
parameters:
|
||||
plugin_version:
|
||||
@ -44,7 +44,7 @@ parameters:
|
||||
number_of_minions:
|
||||
type: number
|
||||
description: how many kubernetes minions to spawn initially
|
||||
default: 1
|
||||
default: 3
|
||||
|
||||
max_number_of_minions:
|
||||
type: number
|
||||
|
@ -144,10 +144,14 @@ function add-keypair() {
|
||||
# IMAGE_PATH
|
||||
# OPENSTACK_IMAGE_NAME
|
||||
function create-glance-image() {
|
||||
if [ $CREATE_IMAGE = true ]; then
|
||||
if [[ ${CREATE_IMAGE} == "true" ]]; then
|
||||
local image_status=$(nova image-show ${OPENSTACK_IMAGE_NAME} | awk '$2=="id" {print $4}')
|
||||
|
||||
if [[ ! $image_status ]]; then
|
||||
if [[ "${DOWNLOAD_IMAGE}" == "true" ]]; then
|
||||
mkdir -p ${IMAGE_PATH}
|
||||
curl -L ${IMAGE_URL_PATH}/${IMAGE_FILE} -o ${IMAGE_PATH}/${IMAGE_FILE} -z ${IMAGE_PATH}/${IMAGE_FILE}
|
||||
fi
|
||||
echo "[INFO] Create image ${OPENSTACK_IMAGE_NAME}"
|
||||
glance image-create --name ${OPENSTACK_IMAGE_NAME} --disk-format ${IMAGE_FORMAT} \
|
||||
--container-format ${CONTAINER_FORMAT} --file ${IMAGE_PATH}/${IMAGE_FILE}
|
||||
@ -227,7 +231,7 @@ function run-heat-script() {
|
||||
function configure-kubectl() {
|
||||
|
||||
export KUBE_MASTER_IP=$(nova show "${STACK_NAME}"-master | awk '$3=="network" {print $6}')
|
||||
export CONTEXT="openstack"
|
||||
export CONTEXT="openstack-${STACK_NAME}"
|
||||
export KUBE_BEARER_TOKEN="TokenKubelet"
|
||||
create-kubeconfig
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user