diff --git a/.gitignore b/.gitignore index c87039d1cb02..2fe19899e107 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,9 @@ bin/* .vagrant cluster/vagrant-kubernetes/.kubeconfig cluster/vagrant-kubernetes/.kubectl +cluster/k8s-1.9.3/.kubeconfig +cluster/k8s-1.9.3/.kubectl +hack/config-provider-k8s-1.9.3.sh cluster/vagrant-openshift/.kubeconfig cluster/vagrant-openshift/.oc cluster/.console.vv diff --git a/cluster/k8s-1.9.3/provider.sh b/cluster/k8s-1.9.3/provider.sh new file mode 100644 index 000000000000..bb6a5ea3ef72 --- /dev/null +++ b/cluster/k8s-1.9.3/provider.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +function _main_ip() { + echo 127.0.0.1 +} + +function up() { + VAGRANT_NUM_NODES=${VAGRANT_NUM_NODES-0} + # Add one, 0 here means no node at all, but in the kubevirt repo it means master-only + VAGRANT_NUM_NODES=$((VAGRANT_NUM_NODES+1)) + docker run --privileged --rm -v /var/run/docker.sock:/var/run/docker.sock rmohr/cli:latest run --nodes ${VAGRANT_NUM_NODES} --tls-port 8443 --ssh-port 2201 --background --registry-port 5000 --base rmohr/kubeadm-1.9.3 + docker run --privileged --rm -v /var/run/docker.sock:/var/run/docker.sock rmohr/cli:latest ssh node01 sudo chown vagrant:vagrant /etc/kubernetes/admin.conf + + OPTIONS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ${KUBEVIRT_PATH}cluster/k8s-1.9.3/vagrant.key -P 2201" + + # Copy k8s config and kubectl + scp ${OPTIONS} vagrant@127.0.0.1:/usr/bin/kubectl ${KUBEVIRT_PATH}cluster/k8s-1.9.3/.kubectl + chmod u+x cluster/vagrant-kubernetes/.kubectl + scp ${OPTIONS} vagrant@127.0.0.1:/etc/kubernetes/admin.conf ${KUBEVIRT_PATH}cluster/k8s-1.9.3/.kubeconfig + + # Set server and disable tls check + export KUBECONFIG=${KUBEVIRT_PATH}cluster/k8s-1.9.3/.kubeconfig + ${KUBEVIRT_PATH}cluster/k8s-1.9.3/.kubectl config set-cluster kubernetes --server=https://127.0.0.1:8443 + ${KUBEVIRT_PATH}cluster/k8s-1.9.3/.kubectl config set-cluster kubernetes --insecure-skip-tls-verify=true + + # Make sure that local config is correct + prepare_config +} + +function prepare_config() { + BASE_PATH=${KUBEVIRT_PATH:-$PWD} + cat >hack/config-provider-k8s-1.9.3.sh <${CMD_OUT_DIR}/${BIN_NAME}/Dockerfile + cat $arg/Dockerfile | sed -e "s#kubevirt/registry-disk-v1alpha#${docker_prefix}/registry-disk-v1alpha\:${docker_tag}#g" >${CMD_OUT_DIR}/${BIN_NAME}/Dockerfile ( cd ${CMD_OUT_DIR}/${BIN_NAME}/ docker $target -t ${docker_prefix}/${BIN_NAME}:${docker_tag} . diff --git a/hack/build-manifests.sh b/hack/build-manifests.sh index 71458a810835..b92aef48fe59 100755 --- a/hack/build-manifests.sh +++ b/hack/build-manifests.sh @@ -19,8 +19,10 @@ set -e -source hack/config.sh source hack/common.sh +source hack/config.sh + +manifest_docker_prefix=${manifest_docker_prefix-${docker_prefix}} args=$(cd ${KUBEVIRT_DIR}/manifests && find * -type f -name "*.yaml.in") @@ -30,8 +32,7 @@ for arg in $args; do final_out_dir=$(dirname ${MANIFESTS_OUT_DIR}/${arg}) mkdir -p ${final_out_dir} manifest=$(basename -s .in ${arg}) - sed -e "s/{{ master_ip }}/$master_ip/g" \ - -e "s/{{ docker_tag }}/$docker_tag/g" \ - -e "s/{{ docker_prefix }}/$docker_prefix/g" \ + sed -e "s#{{ docker_tag }}#${docker_tag}#g" \ + -e "s#{{ docker_prefix }}#${manifest_docker_prefix}#g" \ ${KUBEVIRT_DIR}/manifests/$arg >${final_out_dir}/${manifest} done diff --git a/hack/config.sh b/hack/config.sh index 5914f075ff34..839f6a711fe3 100644 --- a/hack/config.sh +++ b/hack/config.sh @@ -1,5 +1,5 @@ unset binaries docker_images docker_prefix docker_tag manifest_templates \ - master_ip network_provider kubeconfig + master_ip network_provider kubeconfig manifest_docker_prefix PROVIDER=${PROVIDER:-vagrant-kubernetes}