Skip to content

Commit

Permalink
Introduce common makefile targets
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Mohr <[email protected]>
  • Loading branch information
rmohr committed Jan 4, 2018
1 parent 6d6c548 commit 9f2703b
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 193 deletions.
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,18 @@ check-bash:
release-announce: .release-functest
./hack/release-announce.sh $(RELREF) $(PREREF)

.PHONY: build fmt test clean distclean checksync sync docker manifests vet publish vagrant-sync-config vagrant-sync-build vagrant-deploy functest release-announce fmt-bash
cluster-up:
./cluster/up.sh

cluster-down:
./cluster/down.sh

cluster-build:
./cluster/build.sh

cluster-deploy:
./cluster/deploy.sh

cluster-sync: cluster-build cluster-deploy

.PHONY: build fmt test clean distclean checksync sync docker manifests vet publish functest release-announce fmt-bash cluster-up cluster-down cluster-deploy cluster-sync
10 changes: 5 additions & 5 deletions automation/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ curl -LO https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSI
export VAGRANT_DOTFILE_PATH="${VAGRANT_DOTFILE_PATH:-$WORKSPACE/.vagrant}"

# Make sure that the VM is properly shut down on exit
trap '{ cluster/down.sh; }' EXIT
trap '{ make cluster-down; }' EXIT

set +e

# TODO handle complete workspace removal on CI
cluster/up.sh
make cluster-up
if [ $? -ne 0 ]; then
vagrant destroy
set -e
cluster/up.sh
make cluster-up
fi
set -e

Expand Down Expand Up @@ -133,9 +133,9 @@ for i in ${namespaces[@]}; do
done

if [ -z "$TARGET" ] || [ "$TARGET" = "vagrant-dev" ]; then
cluster/sync.sh
make cluster-sync
elif [ "$TARGET" = "vagrant-release" ]; then
cluster/sync.sh
make cluster-sync
fi

# Wait until kubevirt pods are running
Expand Down
1 change: 0 additions & 1 deletion cluster/sync.sh → cluster/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ PROVIDER=${PROVIDER:-vagrant}
source cluster/$PROVIDER/provider.sh

build
cluster/deploy.sh
8 changes: 4 additions & 4 deletions cluster/vagrant/setup_kubernetes_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ echo 'Trying to register myself...'
# Skipping preflight checks because of https://github.com/kubernetes/kubeadm/issues/6
kubeadm join --token abcdef.1234567890123456 $ADVERTISED_MASTER_IP:6443 --ignore-preflight-errors=all --discovery-token-unsafe-skip-ca-verification=true
while [ $? -ne 0 ]; do
sleep 30
echo 'Trying to register myself...'
# Skipping preflight checks because of https://github.com/kubernetes/kubeadm/issues/6
kubeadm join --token abcdef.1234567890123456 $ADVERTISED_MASTER_IP:6443 --ignore-preflight-errors=all --discovery-token-unsafe-skip-ca-verification=true
sleep 30
echo 'Trying to register myself...'
# Skipping preflight checks because of https://github.com/kubernetes/kubeadm/issues/6
kubeadm join --token abcdef.1234567890123456 $ADVERTISED_MASTER_IP:6443 --ignore-preflight-errors=all --discovery-token-unsafe-skip-ca-verification=true
done
90 changes: 0 additions & 90 deletions cluster/verify-qemu-kube

This file was deleted.

62 changes: 0 additions & 62 deletions cluster/vm-isolation-check.sh
Original file line number Diff line number Diff line change
@@ -1,62 +0,0 @@
#!/bin/bash
#
# This file is part of the KubeVirt project
#
# 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.
#
# Copyright 2017 Red Hat, Inc.
#

source hack/config.sh
usage() {
echo "Usage: ./cluster/vm-isolation-check.sh [-vm <VM>]"
}

VM_NAME=testvm

while [[ $# -gt 0 ]]; do
key="$1"

case $key in
-vm)
VM_NAME="$2"
shift
;;
-help)
usage
exit 0
;;

*)
usage
exit 1
;;
esac
shift
done

JQ_PRESENT=$(which jq >/dev/null 2>&1 && echo 1 || echo 0)
if [ "$JQ_PRESENT" == "0" ]; then
echo "Missing required system dependency: jq"
exit 1
fi

NODE=$(cluster/kubectl.sh get pods -o json -l kubevirt.io/domain=${VM_NAME} | jq '.items[].spec.nodeName' -r)

if [ -z $NODE ]; then
echo "Could not detect the VM."
exit 1
fi
echo "Found VM running on node '$NODE'"
# Verify that the VM is running and in the right cgroups and namespaces
vagrant ssh $NODE -c "sudo /vagrant/cluster/verify-qemu-kube ${VM_NAME}"
22 changes: 12 additions & 10 deletions docs/env-providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

All following providers allow a common workflow:

* `cluster/up.sh` to create the environment
* `cluster/down.sh` to stop the environment
* `cluster/sync.sh` to build the code and deploy it
* `cluster/deploy.sh` to (re)deploy the code (no provider support needed)
* `make functests` to run the functional tests against a KubeVirt
* `make cluster-up` to create the environment
* `make cluster-down` to stop the environment
* `make cluster-build` to build
* `make cluster-deploy` to (re)deploy the code (no provider support needed)
* `make cluster-sync` to build and (re)deploy the code
* `make functests` to run the functional tests against KubeVirt
* `cluster/kubectl.sh` to talk to the k8s installation

It is recommended to export the `PROVIDER` vagirable as part of your .bashrc.

It is recommended to export the `PROVIDER` vagirable as part of your `.bashrc`
file.
## Vagrant

Allows provisioning k8s cluster based on kubeadm. Supports an arbitrary amount
Expand All @@ -26,7 +27,7 @@ Usage:
```bash
export PROVIDER=vagrant # choose this provider
export VAGRANT_NUM_NODES=2 # master + two nodes
cluser/up.sh
make cluster-up
```

## Local
Expand All @@ -42,11 +43,12 @@ Usage:

```bash
export PROVIDER=local # choose this provider
cluser/up.sh
make cluster-up
```

## New Providers

* Create a `cluster/$POVIDER` directory
* Create a `cluster/$PROVIDER/provider.sh` files
* This file should containe the functions `up`, `build`, `down` and `_kubectl`
* This file has to contain the functions `up`, `build`, `down` and `_kubectl`
* Have a look at `cluster/vagrant/provider.sh` for a reference implementation
14 changes: 4 additions & 10 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,17 @@ Vagrant environment:

```bash
# Building and deploying kubevirt in Vagrant
cluster/up.sh
cluster/deploy.sh
make cluster-up
make cluster-sync
```

This will create a VM called `master` which acts as Kubernetes master and then
deploy Kubevirt there. To create one or more nodes which will register
themselves on master, you can use the `VAGRANT_NUM_NODES` environment variable.
This would create a master and two nodes:
This would create a master and one node:

```bash
VAGRANT_NUM_NODES=2 vagrant up
VAGRANT_NUM_NODES=1 vagrant up
```

If you decide to use separate nodes, pass `VAGRANT_NUM_NODES` variable to all
Expand Down Expand Up @@ -208,12 +208,6 @@ Finally start a VM called `testvm`:
This will start a VM on master or one of the running nodes with a macvtap and a
tap networking device attached.

Basic verification is possible by running

```bash
bash cluster/vm-isolation-check.sh
```

#### Example

```bash
Expand Down
2 changes: 1 addition & 1 deletion hack/bootstrap-ginkgo.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Find every folder containing tests
for dir in `find pkg/ -type f -name '*_test.go' -printf '%h\n' | sort -u`; do
for dir in $(find pkg/ -type f -name '*_test.go' -printf '%h\n' | sort -u); do
# If there is no file ending with _suite_test.go, bootstrap ginkgo
SUITE_FILE=$(find $dir -maxdepth 1 -type f -name '*_suite_test.go')
if [ -z "$SUITE_FILE" ]; then
Expand Down
18 changes: 9 additions & 9 deletions images/libvirt-kubevirt/libvirtd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ mkdir /dev.container && {
mount --rbind /dev /dev.container
mount --rbind /host-dev /dev

# Keep some devices from the containerinal /dev
keep() { mount --rbind /dev.container/$1 /dev/$1 ; }
keep shm || :
keep mqueue
# Keep ptmx/pts for pty creation
keep pts
mount --rbind /dev/pts/ptmx /dev/ptmx
# Use the container /dev/kvm if available
[[ -e /dev.container/kvm ]] && keep kvm
# Keep some devices from the containerinal /dev
keep() { mount --rbind /dev.container/$1 /dev/$1; }
keep shm || :
keep mqueue
# Keep ptmx/pts for pty creation
keep pts
mount --rbind /dev/pts/ptmx /dev/ptmx
# Use the container /dev/kvm if available
[[ -e /dev.container/kvm ]] && keep kvm
}

mkdir /sys.net.container && {
Expand Down

0 comments on commit 9f2703b

Please sign in to comment.