Skip to content
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

Fix libvirt coreos cluster #19001

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,6 @@ doc_tmp/
# Config directories created by gcloud and gsutil on Jenkins
/.config/gcloud/
/.gsutil/

# CoreOS stuff
cluster/libvirt-coreos/coreos_*.img
31 changes: 31 additions & 0 deletions cluster/libvirt-coreos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Kubernetes CoreOS cluster

With this tutorial one creates a Kubernetes CoreOS cluster containing of one
master and three minions (workers) running on `192.168.10.1`-`192.168.10.4`.

For working correctly you need to create the directory addressed as `POOL_PATH` in
`util.sh`:
```
$ sudo mkdir /var/lib/libvirt/images/kubernetes
$ sudo chown -R $USER:$USER /var/lib/libvirt/images/kubernetes/
```

Then we follow the instructions in the main `kubernetes` directory.

For debugging set `export UTIL_SH_DEBUG=1`.
```
$ export KUBERNETES_PROVIDER=libvirt-coreos
$ make release-skip-tests
$ ./cluster/kube-up.sh
```

To bring the cluster down again, execute:
```
$ ./cluster/kube-down.sh
```

Have fun!



[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/cluster/libvirt-coreos/README.md?pixel)]()
17 changes: 10 additions & 7 deletions cluster/libvirt-coreos/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

# A library of helper functions that each provider hosting Kubernetes must implement to use cluster/kube-*.sh scripts.

[ ! -z ${UTIL_SH_DEBUG+x} ] && set -x

KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
readonly ROOT=$(dirname "${BASH_SOURCE}")
source "$ROOT/${KUBE_CONFIG_FILE:-"config-default.sh"}"
Expand All @@ -25,7 +27,9 @@ export LIBVIRT_DEFAULT_URI=qemu:///system
export SERVICE_ACCOUNT_LOOKUP=${SERVICE_ACCOUNT_LOOKUP:-false}
export ADMISSION_CONTROL=${ADMISSION_CONTROL:-NamespaceLifecycle,LimitRanger,ServiceAccount,ResourceQuota}
readonly POOL=kubernetes
readonly POOL_PATH="$(cd $ROOT && pwd)/libvirt_storage_pool"
readonly POOL_PATH=/var/lib/libvirt/images/kubernetes

[ ! -d "${POOL_PATH}" ] && (echo "$POOL_PATH" does not exist ; exit 1 )

# join <delim> <list...>
# Concatenates the list elements with the delimiter passed as first parameter
Expand Down Expand Up @@ -130,12 +134,11 @@ function initialize-pool {
if [[ "$ROOT/coreos_production_qemu_image.img.bz2" -nt "$POOL_PATH/coreos_base.img" ]]; then
bunzip2 -f -k "$ROOT/coreos_production_qemu_image.img.bz2"
virsh vol-delete coreos_base.img --pool $POOL 2> /dev/null || true
mv "$ROOT/coreos_production_qemu_image.img" "$POOL_PATH/coreos_base.img"
fi
# if ! virsh vol-list $POOL | grep -q coreos_base.img; then
# virsh vol-create-as $POOL coreos_base.img 10G --format qcow2
# virsh vol-upload coreos_base.img "$ROOT/coreos_production_qemu_image.img" --pool $POOL
# fi
if ! virsh vol-list $POOL | grep -q coreos_base.img; then
virsh vol-create-as $POOL coreos_base.img 10G --format qcow2
virsh vol-upload coreos_base.img "$ROOT/coreos_production_qemu_image.img" --pool $POOL
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I remember, virsh vol-upload was much slower than the mv.
If it is still the case, why not keeping the faster mv ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mv does not work everywhere.

The old version mixed file transfers and libvirt storage/volume commands, which might work on some machines, but not everywhere.

The image update is done only once iff a new version is uploaded.

If this is crucial to someone, pure file transfer method could be provided, but I would stay away from this approach.

Does this help?

fi

mkdir -p "$POOL_PATH/kubernetes"
kube-push-internal
Expand Down Expand Up @@ -202,7 +205,7 @@ function kube-up {
set_service_accounts
initialize-network

readonly ssh_keys="$(cat ~/.ssh/id_*.pub | sed 's/^/ - /')"
readonly ssh_keys="$(cat ~/.ssh/*.pub | sed 's/^/ - /')"
readonly kubernetes_dir="$POOL_PATH/kubernetes"

local i
Expand Down