diff --git a/.gitignore b/.gitignore deleted file mode 100644 index e265c54..0000000 --- a/.gitignore +++ /dev/null @@ -1,107 +0,0 @@ -# Misc -helm.log -berth-0.1.0.tgz - -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -env/ -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -*.egg-info/ -.installed.cfg -*.egg - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -.hypothesis/ -.testrepository/* -cover/* - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -doc/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# pyenv -.python-version - -# celery beat schedule file -celerybeat-schedule - -# SageMath parsed files -*.sage.py - -# dotenv -.env - -# virtualenv -.venv -venv/ -ENV/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ diff --git a/.zuul.yaml b/.zuul.yaml deleted file mode 100644 index 0e8882b..0000000 --- a/.zuul.yaml +++ /dev/null @@ -1,18 +0,0 @@ -# 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. - -- project: - templates: - - docs-on-readthedocs - vars: - rtd_webhook_id: '47941' - rtd_project_name: 'airship-berth' diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 9c91699..0000000 --- a/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM ubuntu:16.04 - -LABEL org.opencontainers.image.authors='airship-discuss@lists.airshipit.org, irc://#airshipit@freenode' -LABEL org.opencontainers.image.url='https://airshipit.org' -LABEL org.opencontainers.image.documentation='https://airship-berth.readthedocs.org' -LABEL org.opencontainers.image.source='https://git.openstack.org/openstack/airship-berth' -LABEL org.opencontainers.image.vendor='The Airship Authors' -LABEL org.opencontainers.image.licenses='Apache-2.0' - -RUN apt-get update && apt-get install -y qemu-kvm dnsmasq bridge-utils mkisofs curl jq wget iptables -RUN apt-get clean -RUN rm -f /var/lib/apt/lists/* || true - -ENTRYPOINT ["/bin/sleep", "infinity"] - -VOLUME "/image" -EXPOSE 22 -CMD [] diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 8dada3e..0000000 --- a/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - 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. diff --git a/Makefile b/Makefile deleted file mode 100644 index 20ddde0..0000000 --- a/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# This Makefile is used during development and can usually be ignored -# by most people. - -default: - @echo Useful valid targets are test-validate, test-install, test-uninstall - -all: test-validate test-install test-uninstall - -test-validate: - @echo =========================================================================== - python validate.py examples/* - @echo =========================================================================== - - -test-install: build - @echo - -helm delete --purge berth - @echo - helm install --name=berth --debug ./berth - helm upgrade --debug berth ./berth \ - --values examples/cirros-test.yaml \ - --values examples/demo-ub14-apache.yaml \ - --values examples/ub16-smp-test.yaml - @sleep 5 # give k8s a chance to see the IP - @echo - kubectl get pods -o wide - -test-uninstall: - helm delete --purge berth - -build: - @echo - helm lint berth - -clean: - rm -f *~ */*~ */*/*~ berth-0.1.0.tgz - rm -rf doc/build - -.PHONY: docs -docs: clean build_docs - -.PHONY: build_docs -build_docs: - tox -e docs - -.PHONY: - all default build clean test-validate test-install test-uninstall diff --git a/README.md b/README.md index baa6036..eabe031 100644 --- a/README.md +++ b/README.md @@ -1,108 +1,11 @@ -Berth is a deliberately minimalist VM runner for Kubernetes. +This project is no longer maintained. -Find more documentation for Berth on -`Read the Docs `_. +The contents of this repository are still available in the Git +source code management system. To see the contents of this +repository before it reached its end of life, please check out the +previous commit with "git checkout HEAD^1". -## TL;DR Installation Guide +For any further questions, please email +airship-discuss@lists.openstack.org or join #airshipit on +Freenode. -Install the bare Berth chart: -``` -# Have (recent) Helm and Kubernetes (2.5.x and 1.6.x or later) -# -helm install --name=berth ./berth -kubectl get pods -o wide -``` - -This should happen error free and be fairly quick. At this stage -install one of the examples: -``` -# helm upgrade berth ./berth --values=examples/cirros-test.yaml -``` - -You should be able to SSH to your VM at the Kubernetes IP for the -container which you can retrieve with `kubectl get all -o wide`. VNC -access is available on port 5900. - -Additional examples may be added with additional `--values` arguments. -For example: -``` -# helm upgrade berth ./berth --values=examples/cirros-test.yaml --values=examples/demo-ub14-apache.yaml -``` - -You can use a similar method to purge all VMs: -``` -# helm upgrade berth ./berth --set 'vmlist={}' - -``` - - - - -### Example - -[Quick installation / sample](https://asciinema.org/a/4VazbwsokL3zpnGPf27eyFIfe) - -### Why this? - -The requirements are very narrow right now and the existing -alternatives don't align well at present. This will likely change in -time at which point we can realign the internal implementation. - -#### Minimalist requirements -* Run VMs from inside of Kubernetes -* Work with Calico -* Have VM life-cycle match that of pods -* Have VMs benefit from Kubernetes resiliency -* Allow for persistent storage -* Allow for state injection/access from a ConfigMaps - -## Requirements: -* Helm 2.5.x -* Kubernetes 1.6.x - -This does not need to be installed as part of the OpenStack chart -collection. - -## How it works: - -At a high level, it works like this: -* Create a SNAT/DNAT enabled linux bridge. -* Assign the bridge a private IP address from a small /30 subnet - (controlled with `VM_IP` and `VM_GW`) -* Plug the VM network interface into the bridge. -* Run a dnsmasq process to allocate the VM the right name-servers, and - DNS search strings extracted from the parent container. Assign the - private IP address to the VM and have it use the bridge's IP as its - default gateway. -* Setup SNAT/DNAT on the parent container to do 1:1 mapping of all - ports, all protocols to the VM, except for TCP:5900 to allow for VNC - access (can be controlled with NO_VNC environment variable). -* At this point, VM essentially assumes Pod Assigned IP. -* Feed any meta-data or user-data down into the VM by leveraging these - ConfigMap mounts with the same name and turning them into an ISO - presented to the guest. - -The startvm.sh entry-point supports several environment variables: - -* `IMG_SOURCE` which is an http or https URL that contains a qcow2 - image. It can also be a full path to a local file baked into the - container image, e.g. "/image.qcow" -* `IMG_TARGET` the name to save the image above as in the shared - volume. - -It also supports two files, which should be mounted as ConfigMaps if -using Kubernetes at `/userdata` and `/metadata` as YAML files -containing, obviously meta-data and user-data as YAML that will be fed -to the VM as a config-drive iso. - -The "pet" version of the image, which is created using qemu-img -b to -base it on the source, is stored in a separate volume dedicated to the -VM itself, and named after the container hostname. - -There are a few other parameters you can control as an operator: - -* `VM_IP` is the IP address the VM should be allocated by DHCP. The - container will 1:1 NAT except for port 5900 for VNC access (defaults - to 192.168.254.2) -* `VM_GW` is the gateway IP address the VM should use for its default - route (defaults to 192.168.254.1) diff --git a/README.rst b/README.rst deleted file mode 100644 index 8d0ef85..0000000 --- a/README.rst +++ /dev/null @@ -1,105 +0,0 @@ -===== -Berth -===== - -Berth is a deliberately minimalist VM runner for Kubernetes. - -I'm not 100% sold on the name; before merging we could change it... - -TL;DR Installation Guide -======================== - -.. code-block:: bash - - # Make sure you have Helm 2.5.x and Kubernetes 1.6.x - # - # edit values.yaml; set class_name and ssh key - # - helm package berth - helm install --name=berth ./berth-0.1.0.tgz # ... - kubectl get pods -o wide - -You should be able to SSH to your VM at the Kubernetes IP for the -container which you can retrieve with `kubectl get all -o wide`. VNC -access is available on port 5900. - -.. code-block:: bash - - ssh -i ./you-ssh-private-key root@ip.of.vm.pod - -Example -------- - -`Quick installation / sample `_ - -Why this? ---------- - -The requirements are very narrow right now and the existing -alternatives don't align well at present. This will likely change in -time at which point we can realign the internal implementation. - -Minimalist requirements ------------------------ - -* Run VMs from inside of Kubernetes -* Work with Calico -* Have VM life-cycle match that of pods -* Have VMs benefit from Kubernetes resiliency -* Allow for persistent storage -* Allow for state injection/access from a ConfigMaps - -Requirements -============ - -* Helm 2.5.x -* Kubernetes 1.6.x - -This does not need to be installed as part of the OpenStack chart -collection. - -How it works -============ - -At a high level, it works like this: - - * Create a SNAT/DNAT enabled linux bridge. - * Assign the bridge a private IP address from a small /30 subnet - (controlled with `VM_IP` and `VM_GW`) - * Plug the VM network interface into the bridge. - * Run a dnsmasq process to allocate the VM the right name-servers, and - DNS search strings extracted from the parent container. Assign the - private IP address to the VM and have it use the bridges IP as its - default gateway. - * Setup SNAT/DNAT on the parent container to do 1:1 mapping of all - ports, all protocols to the VM, except for TCP:5900 to allow for VNC - access (can be controlled with NO_VNC environment variable). - * At this point, VM essentially assumes Pod Assigned IP. - * Feed any meta-data or user-data down into the VM by leveraging these - ConfigMap mounts with the same name and turning them into an ISO - presented to the guest. - -The startvm.sh entry-point supports several environment variables: - - * `IMG_SOURCE` which is an http or https URL that contains a qcow2 - image. It can also be a full path to a local file baked into the - container image, e.g. "/image.qcow" - * `IMG_TARGET` the name to save the image above as in the shared - volume. - -It also supports two files, which should be mounted as ConfigMaps if -using Kubernetes at `/userdata` and `/metadata` as YAML files -containing, obviously meta-data and user-data as YAML that will be fed -to the VM as a config-drive iso. - -The "pet" version of the image, which is created using qemu-img -b to -base it on the source, is stored in a separate volume dedicated to the -VM itself, and named after the container hostname. - -There are a few other parameters you can control as an operator: - - * `VM_IP` is the IP address the VM should be allocated by DHCP. The - container will 1:1 NAT except for port 5900 for VNC access (defaults - to 192.168.254.2) - * `VM_GW` is the gateway IP address the VM should use for its default - route (defaults to 192.168.254.1) diff --git a/berth/Chart.yaml b/berth/Chart.yaml deleted file mode 100644 index 90ada71..0000000 --- a/berth/Chart.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: v1 -description: Minimalist VMs on Kubernetes -name: berth -version: 0.1.0 -icon: https://upload.wikimedia.org/wikipedia/commons/6/62/Anchor_pictogram.svg diff --git a/berth/requirements.yaml b/berth/requirements.yaml deleted file mode 100644 index 32cf5dd..0000000 --- a/berth/requirements.yaml +++ /dev/null @@ -1 +0,0 @@ -dependencies: [] diff --git a/berth/templates/bin/_startvm.sh.tpl b/berth/templates/bin/_startvm.sh.tpl deleted file mode 100755 index 5c1dd25..0000000 --- a/berth/templates/bin/_startvm.sh.tpl +++ /dev/null @@ -1,290 +0,0 @@ -#!/bin/bash - -set -ex - -# FIXME; right now this doens't work, need to work out why -#set -o pipefail - -# Returns the integer representation of an IP arg, passed in ascii -# dotted-decimal notation (x.x.x.x) -atoi() { - IP=$1; IPNUM=0 - for (( i=0 ; i<4 ; ++i )); do - ((IPNUM+=${IP%%.*}*$((256**$((3-${i})))))) - IP=${IP#*.} - done - echo $IPNUM -} - -# Returns the dotted-decimal ascii form of an IP arg passed in integer -# format -itoa() { - echo -n $(($(($(($((${1}/256))/256))/256))%256)). - echo -n $(($(($((${1}/256))/256))%256)). - echo -n $(($((${1}/256))%256)). - echo $((${1}%256)) -} - -generate_cloud_drive() { - metadata=/metadata - if [ ! -f $metadata ]; then - metadata="" - fi - - userdata=/userdata - if [ ! -f $userdata ]; then - userdata="" - fi - - if [ "$metadata" == "" -a "$userdata" == "" ]; then - return - fi - - TMPDIR=`mktemp -d -t aicvm.XXXXXX` - - if [ $? -ne 0 ]; then - echo "Fail to create temporaily directory" - exit 1 - fi - - # create form of config drive - mkdir -p ${TMPDIR}/openstack/2012-08-10 - OLD_PWD=$PWD - cd ${TMPDIR}/openstack - ln -s 2012-08-10 latest - cd $OLD_PWD - - if [ -f $metadata ]; then - cp $metadata ${TMPDIR}/openstack/2012-08-10/meta_data.json - fi - if [ -f $userdata ]; then - cp $userdata ${TMPDIR}/openstack/2012-08-10/user_data - fi - - iso="cloud-drive.iso" - mkisofs -R -V config-2 -o $iso ${TMPDIR} - if [ $? -ne 0 ]; then - echo Fail to create cloud-drive ISO image for cloud-init - exit 1 - fi - echo $iso -} - -# Generate random new MAC address -hexchars="0123456789ABCDEF" -end=$( for i in {1..8} ; do echo -n ${hexchars:$(( $RANDOM % 16 )):1} ; done | sed -e 's/\(..\)/:\1/g' ) -NEWMAC=`echo 06:FE$end` - -# These two variables can be overwritten -: ${KVM_BLK_OPTS:="-drive file=\$KVM_IMAGE,if=none,id=drive-disk0,format=qcow2 \ --device virtio-blk-pci,scsi=off,drive=drive-disk0,id=virtio-disk0,bootindex=1"} -: ${KVM_RAW_BLK_OPTS:="-drive file=\$KVM_IMAGE,if=none,id=drive-disk0,format=raw \ --device virtio-blk-pci,scsi=off,drive=drive-disk0,id=virtio-disk0,bootindex=1"} -: ${KVM_NET_OPTS:="-netdev bridge,br=\$BRIDGE_IFACE,id=net0 \ --device virtio-net-pci,netdev=net0,mac=\$NEWMAC"} - -# define some valeus for the VM side of the networking but -# allow them to be overridden by the operator -: ${VM_IP:="192.168.254.2"} -: ${VM_GW:="192.168.254.1"} - -# the netmask is not definable, as we leverage -# /30 elsewhere -VM_NETMASK="255.255.255.252" - -# For debugging -if [ "$1" = "bash" ]; then - exec bash -fi - -# Pass Docker command args to kvm -KVM_ARGS=$@ - -# Create the qcow disk image on the Docker volume named /image, using -# the compressed qcow image that came with Docker image as the base. -# Docker volumes typically perform better than the file system for -# Docker images (no need for overlay fs etc.) - -if [ -e /dev/vm/root ]; then - KVM_BLK_OPTS="$KVM_RAW_BLK_OPTS" - KVM_IMAGE=/dev/vm/root -else - - if [ -e "${IMG_TARGET}" ]; then - BASE=${IMG_TARGET} - else - - if [ ! -d "/image" ]; then - echo "/image directory does not exist, failed to mount volume?" - exit 2 - fi - - if [ ! -e "/image/${IMG_TARGET}" ]; then - echo "Fetching missing image target" - curl ${IMG_SOURCE} > /image/${IMG_TARGET} - fi - - BASE=/image/${IMG_TARGET} - fi - - if [ ! -d "/image" ]; then - echo "/image directory does not exist, failed to mount volume /image?" - exit 2 - fi - - if [ -z "${HOSTNAME}" ]; then - echo "Could not find HOSTNAME var. Did you specify a HOSTNAME environment variable?" - fi - - KVM_IMAGE=/image/${HOSTNAME}.qcow2 - - if [ -e "${KVM_IMAGE}" ]; then - echo "Image ${KVM_IMAGE} already exists. Not recreating" - else - qemu-img create -f qcow2 -b ${BASE} \ - $KVM_IMAGE > /dev/null - if [[ $? -ne 0 ]]; then - echo "Failed to create qcow2 image" - exit 3 - fi - fi -fi - -VOLUMES_DIR="/volumes/" -VOLUMES_LIST=`find $VOLUMES_DIR -name "*.img" | sort -d` -extra_kvm_blk_opts="" -for volume in $VOLUMES_LIST /dev/vm/disk* ; do - if [ -e $volume ]; then - extra_kvm_blk_opts=$extra_kvm_blk_opts" -drive file=$volume,if=virtio,format=raw" - fi -done -KVM_BLK_OPTS=$KVM_BLK_OPTS$extra_kvm_blk_opts - -# Network setup: -# -# 1. Create a bridge named br0 -# 2. Remove IP from eth0, save eth0 MAC, give eth0 a random MAC - -IFACE=eth0 -BRIDGE_IFACE=br0 - -cidr2mask() { - local i mask="" - local full_octets=$(($1/8)) - local partial_octet=$(($1%8)) - - for ((i=0;i<4;i+=1)); do - if [ $i -lt $full_octets ]; then - mask+=255 - elif [ $i -eq $full_octets ]; then - mask+=$((256 - 2**(8-$partial_octet))) - else - mask+=0 - fi - test $i -lt 3 && mask+=. - done - - echo $mask -} - -setup_bridge_networking() { - - MAC=`ip addr show $IFACE | grep ether | sed -e 's/^[[:space:]]*//g' -e 's/[[:space:]]*\$//g' | cut -f2 -d ' '` - HOST_IP=`ip addr show dev $IFACE | grep "inet $IP" | awk '{print $2}' | cut -f1 -d/` - HOST_CIDR=`ip addr show dev $IFACE | grep "inet $IP" | awk '{print $2}' | cut -f2 -d/` - HOST_NETMASK=`cidr2mask $HOST_CIDR` - HOST_GATEWAY=`ip route get 8.8.8.8 | grep via | cut -f3 -d ' '` - NAMESERVER=( `grep nameserver /etc/resolv.conf | grep -v "#" | cut -f2 -d ' '` ) - NAMESERVERS=`echo ${NAMESERVER[*]} | sed "s/ /,/"` - SEARCH=( `grep -E ^search /etc/resolv.conf | grep -v "#" | cut -f2- -d ' ' | tr ' ' ','` ) - # MAC=$(ip addr show $IFACE | grep ether | sed -e 's/^[[:space:]]*//g' -e 's/[[:space:]]*\$//g' | cut -f2 -d ' ') - # HOST_IP=$(ip addr show dev $IFACE | grep "inet $IP" | awk '{print $2}' | cut -f1 -d/) - # HOST_CIDR=$(ip addr show dev $IFACE | grep "inet $IP" | awk '{print $2}' | cut -f2 -d/) - # HOST_NETMASK=$(cidr2mask $HOST_CIDR) - # HOST_GATEWAY=$(ip route get 8.8.8.8 | grep via | cut -f3 -d ' ') - # NAMESERVER=$(grep nameserver /etc/resolv.conf | grep -v "#" | cut -f2 -d ' ') ) - # NAMESERVERS=$(echo ${NAMESERVER[*]} | sed "s/ /,/") - # SEARCH=$(grep -E ^search /etc/resolv.conf | grep -v "#" | cut -f2- -d ' ' | tr ' ' ',') - - # fail if any of the above aren't suitable # here - [ -n "$MAC" ] - [ -n "$HOST_IP" ] - [ -n "$HOST_CIDR" ] - [ -n "$HOST_NETMASK" ] - [ -n "$HOST_GATEWAY" ] - [ -n "$NAMESERVER" ] - [ -n "$NAMESERVERS" ] - [ -n "$SEARCH" ] - - # we must enable forwarding inside the container - echo 1 > /proc/sys/net/ipv4/ip_forward - - # we support exposing port 5900 on the container but leave - # it up to the operator on whether to expose this - they can - # specify NO_VNC as an environment variable to disable this - # functionality - if [ -z $NO_VNC ]; then - iptables -t nat -A PREROUTING -p tcp \! --dport 5900 -d $HOST_IP -j DNAT --to-destination $VM_IP - iptables -t nat -A POSTROUTING -s $VM_IP -j SNAT --to-source $HOST_IP - else - iptables -t nat -A PREROUTING -d $HOST_IP -j DNAT --to-destination $VM_IP - iptables -t nat -A POSTROUTING -s $VM_IP -j SNAT --to-source $HOST_IP - fi - - # generate VM specifics - cat > /etc/dnsmasq.conf << EOF -user=root -dhcp-range=$VM_IP,$VM_IP -dhcp-host=$NEWMAC,$HOSTNAME,$VM_IP,infinite -dhcp-option=option:router,$VM_GW -dhcp-option=option:netmask,$VM_NETMASK -dhcp-option=option:dns-server,$NAMESERVERS -dhcp-option=119,$SEARCH -EOF - - if [ -z $NO_DHCP ]; then - dnsmasq - fi - - brctl addbr $BRIDGE_IFACE - ip link set dev $BRIDGE_IFACE up - ip addr add $VM_GW/30 dev $BRIDGE_IFACE - - # alanmeadows(NOTE) in many implementations with out of - # subnet gateways the dhcp approach does not work - # if [ -z $NO_DHCP ]; then - # ip addr add $NEWIP/$NEWCIDR dev $BRIDGE_IFACE - # fi - - if [[ $? -ne 0 ]]; then - echo "Failed to bring up network bridge" - exit 4 - fi - - # Exec kvm as PID 1 - mkdir -p /etc/qemu - echo allow $BRIDGE_IFACE > /etc/qemu/bridge.conf -} - -# need to wait until network is ready -ISO=`generate_cloud_drive` -if [[ $ISO ]]; then - KVM_BLK_OPTS=$KVM_BLK_OPTS" -cdrom $ISO" -fi - -setup_bridge_networking - -HOST_IP=`ip addr show dev $IFACE | grep "inet $IP" | awk '{print $2}' | cut -f1 -d/` -VNC="-vnc $HOST_IP:0" - -exec $LAUNCHER qemu-system-x86_64 \ - -smp "$IMG_VCPU" \ - -m "$IMG_RAM_MB" \ - -machine q35 \ - -cpu host,+x2apic \ - -vga vmware \ - -enable-kvm \ - $VNC \ - `eval echo $KVM_BLK_OPTS` \ - `eval echo $KVM_NET_OPTS` \ - -usbdevice tablet -nographic $KVM_ARGS diff --git a/berth/templates/iter-configmap.yaml b/berth/templates/iter-configmap.yaml deleted file mode 100644 index 4840621..0000000 --- a/berth/templates/iter-configmap.yaml +++ /dev/null @@ -1,33 +0,0 @@ - -{{- define "template" -}} -{{- $name := index . 0 -}} -{{- $context := index . 1 -}} -{{- $last := base $context.Template.Name }} -{{- $wtf := $context.Template.Name | replace $last $name -}} -{{ include $wtf $context }} -{{- end -}} - ---- - -apiVersion: v1 -kind: ConfigMap -metadata: - name: configmap-generic-startvm -data: - startvm.sh: | -{{ tuple "bin/_startvm.sh.tpl" . | include "template" | indent 4 }} - ---- - -{{- range $name, $vm := .Values.vmlist }} -{{- if $vm.enabled }} -apiVersion: v1 -kind: ConfigMap -metadata: - name: configmap-cloudconfig-{{ $name }} -data: - metadata: {{ toYaml $vm.cloudconfig.metadata | indent 4 }} - userdata: {{ toYaml $vm.cloudconfig.userdata | indent 4 }} ---- -{{- end }} -{{- end }} diff --git a/berth/templates/iter-deployment.yaml b/berth/templates/iter-deployment.yaml deleted file mode 100644 index fecd008..0000000 --- a/berth/templates/iter-deployment.yaml +++ /dev/null @@ -1,98 +0,0 @@ - -{{- $envAll := . }} - -{{ range $name, $vm := .Values.vmlist }} - -# id: {{- $name }} -{{- if $vm.enabled }} -# vm enabled -apiVersion: extensions/v1beta1 -kind: Deployment -metadata: - name: berth-{{ $name }} -spec: - replicas: 1 - template: - metadata: - labels: - app: berth - annotations: - pod.beta.kubernetes.io/hostname: {{ $name }} - spec: - nodeSelector: - {{ $envAll.Values.labels.node_selector_key }}: {{ $envAll.Values.labels.node_selector_value }} - hostNetwork: false - hostPID: false - securityContext: - runAsUser: 0 - containers: - - name: {{ $name }} - imagePullPolicy: IfNotPresent - image: {{ $envAll.Values.images.vmrunner }} - env: - - name: IMG_SOURCE - value: {{ $vm.vmconfig.rootfs.sourceurl }} - - name: IMG_TARGET - value: {{ $vm.vmconfig.rootfs.localtarget }} - - name: IMG_VCPU - value: "{{ $vm.vmconfig.cpu.vcpu }}" - - name: IMG_RAM_MB - value: "{{ $vm.vmconfig.cpu.ram_mb }}" - securityContext: - privileged: true - command: - - /startvm.sh -{{- if $vm.netconfig.ports }} - ports: -{{- range $for, $port := $vm.netconfig.ports }} - - containerPort: {{ $port }} -{{- end }} -{{- end }} -{{- if $vm.netconfig.readinessTcpProbe }} - readinessProbe: - tcpSocket: - port: {{ $vm.netconfig.readinessTcpProbe }} -{{- end }} - volumeMounts: - - name: volume-startvm - mountPath: /startvm.sh - subPath: startvm.sh - - name: image - mountPath: /image - - name: dev - mountPath: /dev - - name: sys - mountPath: /sys - - name: volume-cloudinit - mountPath: /userdata - subPath: userdata - - name: volume-cloudinit - mountPath: /metadata - subPath: metadata - volumes: - - name: volume-startvm - configMap: - name: configmap-generic-startvm - defaultMode: 0555 - - name: image - persistentVolumeClaim: - claimName: {{ $name }} - - name: dev - hostPath: - path: /dev - - name: sys - hostPath: - path: /sys - - name: volume-cloudinit - configMap: - name: configmap-cloudconfig-{{ $name }} - items: - - key: userdata - path: userdata - - key: metadata - path: metadata -{{- else }} -# {{ $name }} not enabled! -{{- end }} ---- -{{- end }} diff --git a/berth/templates/iter-pvc.yaml b/berth/templates/iter-pvc.yaml deleted file mode 100644 index f5bdb79..0000000 --- a/berth/templates/iter-pvc.yaml +++ /dev/null @@ -1,23 +0,0 @@ - -{{- range $name, $vm := .Values.vmlist }} -# id: {{- $name }} -{{- if $vm.enabled }} -# vm enabled -# {{ $vm.vmconfig.rootfs.pvc_size }} {{ $vm.vmconfig.rootfs.pvc_class }} -kind: PersistentVolumeClaim -apiVersion: v1 -metadata: - name: {{ $name }} -spec: - accessModes: [ "ReadWriteOnce" ] - resources: - requests: - storage: {{ $vm.vmconfig.rootfs.pvc_size }} -{{- if $vm.vmconfig.rootfs.pvc_class }} - storageClassName: {{ $vm.vmconfig.rootfs.pvc_class}} -{{- end }} -{{- else }} -# vm disabled - skipping -{{- end }} ---- -{{- end }} diff --git a/berth/values.yaml b/berth/values.yaml deleted file mode 100644 index 1d615ce..0000000 --- a/berth/values.yaml +++ /dev/null @@ -1,12 +0,0 @@ - -images: - vmrunner: quay.io/attcomdev/berth:latest - -labels: - node_selector_key: openstack-control-plane - node_selector_value: enabled - -# by default in the chart's values.yaml this is empty; use and -# override file and helm --values=... for your specific values -vmlist: { } - diff --git a/doc/requirements.txt b/doc/requirements.txt deleted file mode 100644 index 101a16f..0000000 --- a/doc/requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ -# The order of packages is significant, because pip processes them in the order -# of appearance. Changing the order has an impact on the overall integration -# process, which may cause wedges in the gate later. -sphinx!=1.6.6,!=1.6.7,>=1.6.2 # BSD -sphinxcontrib-apidoc>=0.2.0 # BSD -sphinx_rtd_theme>=0.2.4 -reno>=2.5.0 # Apache-2.0 diff --git a/doc/source/_static/.placeholder b/doc/source/_static/.placeholder deleted file mode 100644 index e69de29..0000000 diff --git a/doc/source/conf.py b/doc/source/conf.py deleted file mode 100644 index 4bd3229..0000000 --- a/doc/source/conf.py +++ /dev/null @@ -1,155 +0,0 @@ -# -*- coding: utf-8 -*- -# -# berth documentation build configuration file, created by -# sphinx-quickstart on Sat Sep 16 03:40:50 2017. -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# -# import os -# import sys -# sys.path.insert(0, os.path.abspath('.')) - - -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -# -# needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = ['sphinx.ext.autodoc'] - -# Add any paths that contain templates here, relative to this directory. -# templates_path = [] - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -# -# source_suffix = ['.rst', '.md'] -source_suffix = '.rst' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = u'Berth' -copyright = u'2017, Berth Authors' -author = u'Berth Authors' - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. -version = u'0.1.0' -# The full version, including alpha/beta/rc tags. -release = u'0.1.0' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This patterns also effect to html_static_path and html_extra_path -exclude_patterns = [] - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = False - - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -import sphinx_rtd_theme -html_theme = "sphinx_rtd_theme" -html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -# -# html_theme_options = {} - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - - -# -- Options for HTMLHelp output ------------------------------------------ - -# Output file base name for HTML help builder. -htmlhelp_basename = 'berthdoc' - - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # - # 'papersize': 'letterpaper', - - # The font size ('10pt', '11pt' or '12pt'). - # - # 'pointsize': '10pt', - - # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', - - # Latex figure (float) alignment - # - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - (master_doc, 'berth.tex', u'Berth Documentation', - u'Berth Authors', 'manual'), -] - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, 'Berth', u'Berth Documentation', - [author], 1) -] - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - (master_doc, 'Berth', u'Berth Documentation', - author, 'Berth', 'A deliberately minimalist VM runner for Kubernetes.', - 'Miscellaneous'), -] diff --git a/doc/source/index.rst b/doc/source/index.rst deleted file mode 100644 index 0ba30cc..0000000 --- a/doc/source/index.rst +++ /dev/null @@ -1,26 +0,0 @@ -.. - Copyright 2017 AT&T Intellectual Property. - 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. - -================================= -Welcome to Berth's documentation! -================================= - -Berth is a deliberately minimalist VM runner for Kubernetes. - -.. toctree:: - :maxdepth: 2 - - readme diff --git a/doc/source/readme.rst b/doc/source/readme.rst deleted file mode 100644 index 38ba804..0000000 --- a/doc/source/readme.rst +++ /dev/null @@ -1 +0,0 @@ -.. include:: ../../README.rst \ No newline at end of file diff --git a/examples/cirros-test.yaml b/examples/cirros-test.yaml deleted file mode 100644 index e2d8657..0000000 --- a/examples/cirros-test.yaml +++ /dev/null @@ -1,22 +0,0 @@ -vmlist: - cirros-test: - enabled: true - vmconfig: - cpu: - vcpu: 1 - ram_mb: 256 - rootfs: - sourceurl: http://stupidest.org/vm/cirros-0.3.5-x86_64-disk.img - localtarget: cirros-vm.qcow2 - pvc_size: 128Mi - netconfig: - ports: - ssh: 22 - vnc: 5900 - cloudconfig: - metadata: | - { "uuid": "093772fe-d6a3-4eea-84bc-5966661a0c3e" } - userdata: | - #cloud-config - fqdn: cirros.example.com - bogus_not_used: "this won't hurt anthing but shouldn't be here" diff --git a/examples/demo-ub14-apache.yaml b/examples/demo-ub14-apache.yaml deleted file mode 100644 index dfda9fb..0000000 --- a/examples/demo-ub14-apache.yaml +++ /dev/null @@ -1,33 +0,0 @@ -vmlist: - demo-ub14-apache: - enabled: true - vmconfig: - cpu: - vcpu: 1 - ram_mb: 1024 - rootfs: - sourceurl: http://stupidest.org/vm/ubuntu-14.04-amd64.img - localtarget: ubuntu-14.04-amd64.qcow2 - pvc_size: 5Gi - pvc_class: managed - netconfig: - ports: - ssh: 22 - vnc: 5900 - readinessTcpProbe: 22 - cloudconfig: - metadata: | - { "uuid": "apache-demo.example.com" } - userdata: | - #cloud-config - fqdn: apache-demo.example.com - users: - - name: root - ssh-authorized-keys: - - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAII+k1AYpUX7Y6+pVzkw3JPbRPNpoh7m1rZBP4Qa37Wz2 user@host" - - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPE/zGmNx3W52ztb/2vvTcgUN7RGbq172QXGcXKAagU1 user@host" - - "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBKVeMUpC6Ba0UwyLeCCWexr/sc4kYwKW6mTSTpcQHDm+F5UqoW3pnbGPn3WSJB2AbCMP9oG0qQrLP2zHmE7fyog= otheruser@otherhost" - ssh_pwauth: True - runcmd: - - [ apt-get, update ] - - [ apt-get, install, -y, --force-yes, apache2 ] diff --git a/examples/ub16-smp-test.yaml b/examples/ub16-smp-test.yaml deleted file mode 100644 index 5551071..0000000 --- a/examples/ub16-smp-test.yaml +++ /dev/null @@ -1,36 +0,0 @@ -vmlist: - ub16-smp-test: - enabled: true - vmconfig: - cpu: - vcpu: 2 - ram_mb: 2048 - rootfs: - sourceurl: http://stupidest.org/vm/cw-ub16-test-3a.qcow2 - localtarget: cw-ub16-test.qcow2 - pvc_size: 7Gi - netconfig: - ports: - ssh: 22 - vnc: 5900 - cloudconfig: - metadata: | - { - "uuid": "093772fe-d6a3-4eea-84bc-5966661a0c3e", - "name": "my-name", - "instance-id": "my-instance-id", - "availability-zone": "my-az", - "hostname": "my-hostname", - "local-hostname": "my-local-hostname", - "launch-index": "123" - } - userdata: | - #cloud-config - fqdn: ub16-smp-test.example.com - users: - - name: root - ssh-authorized-keys: - - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAII+k1AYpUX7Y6+pVzkw3JPbRPNpoh7m1rZBP4Qa37Wz2 user@host" - - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPE/zGmNx3W52ztb/2vvTcgUN7RGbq172QXGcXKAagU1 user@host" - - "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBKVeMUpC6Ba0UwyLeCCWexr/sc4kYwKW6mTSTpcQHDm+F5UqoW3pnbGPn3WSJB2AbCMP9oG0qQrLP2zHmE7fyog= otheruser@otherhost" - ssh_pwauth: True diff --git a/examples/zz-fail-bogus.yaml b/examples/zz-fail-bogus.yaml deleted file mode 100644 index 4495608..0000000 --- a/examples/zz-fail-bogus.yaml +++ /dev/null @@ -1,14 +0,0 @@ -# this vm isn't fully defined, not enabling it is enough to have the -# templates skip over the details and not barf -vmlist: - - bogus-vm: - enabled: false - extra: "thang" - vmconfig: "this is wrong" - cloudconfig: - metadata: "{ " - userdata: false -# bogus mess - somevm: - enabled: "can't be bothered" - extra: "peanuts" diff --git a/examples/zz-fail-nothing.yaml b/examples/zz-fail-nothing.yaml deleted file mode 100644 index 7300fbc..0000000 --- a/examples/zz-fail-nothing.yaml +++ /dev/null @@ -1 +0,0 @@ -# nada diff --git a/examples/zz-fail-parse.yaml b/examples/zz-fail-parse.yaml deleted file mode 100644 index df10564..0000000 --- a/examples/zz-fail-parse.yaml +++ /dev/null @@ -1,3 +0,0 @@ -vmlist: - - wrong - diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 9dbc011..0000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -# The order of packages is significant, because pip processes them in the order -# of appearance. Changing the order has an impact on the overall integration -# process, which may cause wedges in the gate later. diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 013cfdc..0000000 --- a/setup.cfg +++ /dev/null @@ -1,31 +0,0 @@ -[metadata] -name = Berth -summary = A deliberately minimalist VM runner for Kubernetes. -description-file = README.rst -author = The Airship Authors -author-email = airship-discuss@lists.airshipit.org -home-page = https://airship-berth.readthedocs.io/ - -classifier = - Intended Audience :: Information Technology - Intended Audience :: System Administrators - License :: OSI Approved :: Apache Software License - Operating System :: POSIX :: Linux - Programming Language :: Python - Programming Language :: Python :: 2 - Programming Language :: Python :: 2.7 - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.5 - -[files] -packages = - berth - -[build_sphinx] -source-dir = doc/source -build-dir = doc/build -all_files = 1 -warning-is-error = 1 - -[upload_sphinx] -upload-dir = doc/build/html diff --git a/setup.py b/setup.py deleted file mode 100644 index 0b220f4..0000000 --- a/setup.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2017 AT&T Intellectual Property. All other 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. - -import setuptools - -# In python < 2.7.4, a lazy loading of package `pbr` will break -# setuptools if some other modules registered functions in `atexit`. -# solution from: http://bugs.python.org/issue15881#msg170215 -try: - import multiprocessing # noqa -except ImportError: - pass - -setuptools.setup( - setup_requires=['pbr>=2.0.0'], - pbr=True) diff --git a/test-requirements.txt b/test-requirements.txt deleted file mode 100644 index e200bfc..0000000 --- a/test-requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -# The order of packages is significant, because pip processes them in the order -# of appearance. Changing the order has an impact on the overall integration -# process, which may cause wedges in the gate later. - -sphinx>=1.6.2 -sphinx_rtd_theme==0.2.4 diff --git a/tools/gate/setup.sh b/tools/gate/setup.sh deleted file mode 100755 index 313066e..0000000 --- a/tools/gate/setup.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -set -ex - -. /etc/os-release -type=${ID_LIKE:=ID} - -if [ "$type" == "debian" ] ; then - apt-get update - apt-get install netcat-openbsd jq -else - yum install netcat jq -fi diff --git a/tools/gate/test.sh b/tools/gate/test.sh deleted file mode 100755 index 62f582d..0000000 --- a/tools/gate/test.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -set -ex - -NS=berth - -helm install --name=berth --debug ./berth --values=examples/cirros-test.yaml --namespace="${NS}" - -# wait until we get a PODIP -while : ; do - PODIP=$(kubectl -n "${NS}" get pods -o wide -o json | jq -r '.items[].status.podIP') - if [ -n "$PODIP" -a "null" != "$PODIP" ] ; then - break - fi - echo "waiting for PODIP" - # XXX - kubectl get pods --all-namespaces - sleep 2 -done - -kubectl -n "${NS}" get pods - -# wait for pod to come up say something on ssh -timeout=60 -t=0 -while : ; do - if echo "bye" | nc "${PODIP}" 22 | grep --quiet ^SSH ; then - echo "VM up" - break - fi - if [ $t -gt $timeout ] ; then - exit 2 - fi - t=$(($t + 5)) - sleep 2 -done - -# verify we can cleanup -helm upgrade berth ./berth --values=berth/values.yaml - -helm delete --purge berth diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 39871f2..0000000 --- a/tox.ini +++ /dev/null @@ -1,25 +0,0 @@ -[tox] -envlist = py35 - -[testenv] -usedevelop = True -whitelist_externals = rm -setenv = VIRTUAL_ENV={envdir} - LANGUAGE=en_US - LC_ALL=en_US.utf-8 -passenv=HTTP_PROXY HTTPS_PROXY http_proxy https_proxy NO_PROXY no_proxy -deps = -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt -commands = - find . -type f -name "*.pyc" -delete - rm -Rf .testrepository/times.dbm - -[testenv:venv] -commands = {posargs} - -[testenv:docs] -basepython = python3 -deps = -r{toxinidir}/doc/requirements.txt -commands = - rm -rf doc/build - sphinx-build -W -b html doc/source doc/build/html diff --git a/validate.py b/validate.py deleted file mode 100644 index 12f5000..0000000 --- a/validate.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/python -# -# Ideally we would use jsonschema.validate but getting useful error -# output has been challenging. This can be revisited as needed. - -import yaml -import sys - -def validate_leaves(prefix, vm, l): - valid_leaves = [ ] - - # first check to make sure we have what we think we should - for nd in l: - n = nd[0] - t = nd[1] - o = False - if len(nd)>2: - o = nd[2] - try: - if n not in vm.keys(): - if o: - print "[W] Missing leaf:", prefix+n - else: - print "[E] Missing leaf:", prefix+n - continue - if type(vm[n]) != type(t): - print "[E] Wrong type for %s (got '%s' expected '%s')" % (prefix+n, type(vm[n]).__name__, type(t).__name__) - continue - except: - print "[W] Unable to validate leaf:", prefix+n - continue - - valid_leaves.append(n) - - if type(vm) == type(dict()): - # now look for things we don't know how to deal with - for n in vm.keys(): - if n not in [ x[0] for x in l]: - print "[W] Unexpected leaf:", prefix+n - - return valid_leaves - -def validate_file(filename): - try: - yamlgen = list(yaml.safe_load_all(open(filename))) - except yaml.parser.ParserError: - print "[E] Invalid yaml" - return - - if not yamlgen or not yamlgen[0]: - print "[E] File contains no valid yaml" - return - top = list(yamlgen)[0] - - vmlist = top["vmlist"] - if not vmlist or not isinstance(vmlist, dict): - print "[E] No vmlist dict declared" - return - - for name in vmlist: - vm = vmlist[name] - print "VM:", name - - vl = validate_leaves("", vm, [ ("enabled",bool()), ("vmconfig",dict()), ("netconfig",dict()), ("cloudconfig",dict()) ] ) - if "vmconfig" in vl: - # validate vmconfig - vmconfig = vm["vmconfig"] - vl2 = validate_leaves("vmconfig.", vmconfig, [ ("cpu",dict()), ("rootfs",dict()) ]) - - if "cpu" in vl2: - # validate vmconfig.cpu - cpu = vmconfig["cpu"] - vl3 = validate_leaves("vmconfig.cpu.", cpu, [ ("vcpu",int()), ("ram_mb",int()) ]) - if "vcpus" in vl3: - vcpu = int(cpu["vcpus"]) - if vcpu < 1 or vcpu > 8: - print "[W] vmconfig.cpu.vcpu has odd looking value:", vcpu - if "ram_mb" in vl3: - ram_mb = int(cpu["ram_mb"]) - if ram_mb < 512 or ram_mb > 32768: - print "[W] vmconfig.cpu.ram_mb has odd looking value:", ram_mb - - if "rootfs" in vl2: - # validate vmconfig.rootfs - rootfs = vmconfig["rootfs"] - vl3 = validate_leaves("vmconfig.rootfs.", rootfs, [ ("sourceurl",str()), ("localtarget",str()), ("pvc_size",str()), ("pvc_class",str(), True) ]) - - if "sourceurl" in vl3: - if not rootfs["sourceurl"].startswith("http"): - print "[W] vmconfig.rootfs.sourceurl has odd looking value:", rootfs["sourceurl"] - - if "netconfig" in vl: - # validate netconfig - netconfig = vm["netconfig"] - vm2 = validate_leaves("netconfig.", netconfig, [ ("ports",dict()), ("readinessTcpProbe",int(), True) ]) - # do more? - - if "cloudconfig" in vl: - # validate cloudconfig - cloudconfig = vm["cloudconfig"] - vl2 = validate_leaves("cloudconfig.", cloudconfig, [ ("metadata",str()), ("userdata",str()) ]) - - # check things look sane - for yamlobj in [ "metadata", "userdata" ]: - if yamlobj in vl2: - try: - yaml.load(cloudconfig[yamlobj]) - except: - print "[E] Bad yaml for vmconfig.cloudconfig.%s" % yamlobj - - -if __name__ == "__main__": - for fn in sys.argv[1:]: - print "Filename:", fn - validate_file(fn) - print