Improve development experience

This commit is contained in:
Jake Spain 2023-08-14 10:01:19 -04:00
parent 3f34b85dcb
commit 45388de4e1
No known key found for this signature in database
GPG key ID: BC1C4DA0A085E113
12 changed files with 119 additions and 99 deletions

3
.gitignore vendored
View file

@ -1,9 +1,8 @@
/*/**/vendor/bundle/ /*/**/vendor/bundle/
/docker/**/vmpooler.yaml /docker/data/vmpooler*.yaml
/docker/data/*.json /docker/data/*.json
.vagrant/ .vagrant/
.idea/ .idea/
helm-charts/vmpooler/charts/ helm-charts/vmpooler/charts/
/docker/data/redis/** /docker/data/redis/**
!docker/data/**/*.yaml
!docker/data/**/.gitkeep !docker/data/**/.gitkeep

View file

@ -1,15 +1,16 @@
# vmpooler-deployment # vmpooler-deployment
- [VMPooler Components](#vmpooler-components) - [vmpooler-deployment](#vmpooler-deployment)
- [Docker Registry](#docker-registry) - [VMPooler Components](#vmpooler-components)
- [Helm Repository](#helm-repository) - [Docker Registry](#docker-registry)
- [Adding / updating charts](#adding--updating-charts) - [Helm Repository](#helm-repository)
- [Development](#development) - [Adding / updating charts](#adding--updating-charts)
- [Docker Compose URLs](#docker-compose-urls) - [Development](#development)
- [Deploy Chart for Testing](#deploy-chart-for-testing) - [Docker Compose URLs](#docker-compose-urls)
- [Releasing](#releasing) - [Deploy Chart for Testing](#deploy-chart-for-testing)
- [Contributing](#contributing) - [Releasing](#releasing)
- [License](#license) - [Contributing](#contributing)
- [License](#license)
This repo contains Dockerfiles and a Helm chart that can be used to deploy [VMPooler](https://github.com/puppetlabs/vmpooler). The Release Engineering team at Puppet uses the code here as part of operating our VMPooler instances. This repo contains Dockerfiles and a Helm chart that can be used to deploy [VMPooler](https://github.com/puppetlabs/vmpooler). The Release Engineering team at Puppet uses the code here as part of operating our VMPooler instances.
@ -64,21 +65,21 @@ Prerequisites:
```bash ```bash
|-- vmpooler-projects |-- vmpooler-projects
| |--vmpooler
| |--vmpooler-deployment | |--vmpooler-deployment
| |--vmpooler-dns-google-clouddns | |--vmpooler-dns-gcp
| |--vmpooler-provider-ec2 | |--vmpooler-provider-ec2
| |--vmpooler-provider-gce | |--vmpooler-provider-gce
| |--vmpooler-provider-vsphere | |--vmpooler-provider-vsphere
``` ```
2. From the `vmpooler-projects` directory run `docker build -t vmpooler-local -f vmpooler-deployment/docker/Dockerfile.local .` 2. From the `vmpooler-projects/vmpooler-deployment` directory run `docker compose -f docker/docker-compose.dev.yml up --build`
3. Run `docker compose -f vmpooler-deployment/docker/docker-compose.local.yml up`
- Develop via Git source: - Develop via Git source:
4. For the component(s) you are developing on, commit and push changes to a branch. 1. For the component(s) you are developing on, commit and push changes to a branch.
5. Change to the `docker` directory and modify the `Gemfile` as needed to pull the gem(s) from your git branch. 2. Change to the `docker` directory and modify the `Gemfile` as needed to pull the gem(s) from your git branch.
6. Run `./update-gemfile-lock` to update the `Gemfile.lock` 3. Run `./update-gemfile-lock` to update the `Gemfile.lock`
7. Run `docker compose build && docker compose up`. 4. Run `docker compose build && docker compose up`.
When a dependency Helm chart is updated, be sure to run `./update-chart-lock` to update the lockfile, otherwise the test and release workflows will fail. When a dependency Helm chart is updated, be sure to run `./update-chart-lock` to update the lockfile, otherwise the test and release workflows will fail.
@ -91,7 +92,7 @@ These are the default ports used in the docker compose file, to change them edit
| Redis Server | `localhost:6379` (Password: `vmpooler`) | | Redis Server | `localhost:6379` (Password: `vmpooler`) |
| Redis Commander | <http://localhost:8080> (Credentials: `admin:admin`) | | Redis Commander | <http://localhost:8080> (Credentials: `admin:admin`) |
| Jaeger | <http://localhost:8081> | Jaeger | <http://localhost:8081>
| VMPooler API | <http://localhost:8082/api/v2> | | VMPooler API | <http://localhost:8082/api/v3> |
| VMPooler Dashboard | <http://localhost:8082/dashboard> | | VMPooler Dashboard | <http://localhost:8082/dashboard> |
| Metrics (API) | <http://localhost:8082/prometheus> | | Metrics (API) | <http://localhost:8082/prometheus> |
| Metrics (Manager) | <http://localhost:8083/prometheus> | | Metrics (Manager) | <http://localhost:8083/prometheus> |

View file

@ -1,6 +1,8 @@
# Exclude everything by default; explicitly include necessary files # Exclude everything by default; explicitly include necessary files
* *
!Gemfile !.rerun
!Gemfile.lock !docker-entrypoint.dev.sh
!Gemfile.local
!docker-entrypoint.sh !docker-entrypoint.sh
!Gemfile
!Gemfile.dev
!Gemfile.lock

2
docker/.rerun Normal file
View file

@ -0,0 +1,2 @@
--dir /opt/vmpooler-projects/
--pattern **/lib/**/*.{erb,rb}

View file

@ -31,7 +31,7 @@ RUN chmod +x /usr/local/bin/docker-entrypoint.sh
COPY ./Gemfile* ./ COPY ./Gemfile* ./
RUN bundle config set --local jobs 3 && \ RUN bundle config set --local jobs 3 without development && \
bundle install bundle install
ENTRYPOINT ["docker-entrypoint.sh"] ENTRYPOINT ["docker-entrypoint.sh"]

View file

@ -24,21 +24,15 @@ RUN apt-get update -qq && \
apt-get autoremove -y && \ apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
COPY vmpooler /opt/vmpooler
COPY vmpooler-dns-gcp /opt/vmpooler-dns-gcp
COPY vmpooler-provider-ec2 /opt/vmpooler-provider-ec2
COPY vmpooler-provider-gce /opt/vmpooler-provider-gce
COPY vmpooler-provider-vsphere /opt/vmpooler-provider-vsphere
RUN gem install bundler RUN gem install bundler
COPY vmpooler-deployment/docker/docker-entrypoint.sh /usr/local/bin/ COPY docker-entrypoint.dev.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh RUN chmod +x /usr/local/bin/docker-entrypoint.sh
COPY vmpooler-deployment/docker/Gemfile.local ./Gemfile COPY Gemfile.dev ./Gemfile
COPY .rerun ./.rerun
RUN bundle config set --local jobs 3 && \ RUN bundle config set --local jobs 3
bundle install
ENTRYPOINT ["docker-entrypoint.sh"] ENTRYPOINT ["docker-entrypoint.sh"]

11
docker/Gemfile.dev Normal file
View file

@ -0,0 +1,11 @@
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
gem 'vmpooler', path: '/opt/vmpooler-projects/vmpooler'
gem 'vmpooler-dns-gcp', path: '/opt/vmpooler-projects/vmpooler-dns-gcp'
# gem 'vmpooler-provider-ec2', path: '/opt/vmpooler-projects/vmpooler-provider-ec2'
gem 'vmpooler-provider-gce', path: '/opt/vmpooler-projects/vmpooler-provider-gce'
gem 'vmpooler-provider-vsphere', path: '/opt/vmpooler-projects/vmpooler-provider-vsphere'
group :development do
gem 'rerun', '~> 0.14'
end

View file

@ -1,7 +0,0 @@
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
gem 'vmpooler', path: '/opt/vmpooler'
gem 'vmpooler-dns-gcp', path: '/opt/vmpooler-dns-gcp'
gem 'vmpooler-provider-ec2', path: '/opt/vmpooler-provider-ec2'
gem 'vmpooler-provider-gce', path: '/opt/vmpooler-provider-gce'
gem 'vmpooler-provider-vsphere', path: '/opt/vmpooler-provider-vsphere'

View file

@ -1,56 +0,0 @@
---
:dns_configs:
ddns_domain: 'dynamic.example.com'
:gcp-clouddns:
project: vmpooler-example
domain: vmpooler.example.com
dns_zone_resource_name: vmpooler-example-com
:providers:
# :gce:
# network_name: projects/vmpooler-example/global/networks/default
# project: vmpooler-example
# title: gce
# zone: us-west1-b
:dummy:
filename: '/tmp/dummy-backing.yaml'
:prometheus:
prefix: 'vmpooler-local'
:redis:
server: 'redis-server'
:auth:
provider: 'dummy'
:config:
site_name: 'vmpooler'
logfile: '/var/log/vmpooler.log'
task_limit: 10
timeout: 15
vm_checktime: 1
vm_lifetime: 12
vm_lifetime_auth: 24
allowed_tags:
- 'created_by'
- 'project'
:pools:
# - name: 'fedora-36-x86_64'
# template: 'projects/fedora-cloud/global/images/fedora-cloud-base-gcp-36-20220506-n-0-x86-64'
# size: 0
# provider: 'gce'
# dns_plugin: 'google-clouddns'
# machine_type: 'zones/us-west1-b/machineTypes/n1-standard-2'
# disk_type: 'pd-ssd'
# subnetwork_name: 'projects/vmpooler-example/regions/us-west1/subnetworks/default'
- name: 'debian-11-x86_64'
template: 'Templates/debian-11-x86_64'
folder: 'Pooled VMs/debian-11-x86_64'
datastore: 'vmstorage'
size: 5
timeout: 15
ready_ttl: 1440
provider: dummy

View file

@ -36,8 +36,14 @@ services:
vmpooler-api: vmpooler-api:
# See image build instructions in README and Dockerfile.local # See image build instructions in README and Dockerfile.local
image: vmpooler-local build:
context: .
dockerfile: ./Dockerfile.dev
tty: true
volumes: volumes:
- type: bind
source: ../../
target: /opt/vmpooler-projects
- type: bind - type: bind
source: ./data/vmpooler.yaml source: ./data/vmpooler.yaml
target: /etc/vmpooler/vmpooler.yaml target: /etc/vmpooler/vmpooler.yaml
@ -63,8 +69,14 @@ services:
vmpooler-manager: vmpooler-manager:
# See image build instructions in README and Dockerfile.local # See image build instructions in README and Dockerfile.local
image: vmpooler-local build:
context: .
dockerfile: ./Dockerfile.dev
tty: true
volumes: volumes:
- type: bind
source: ../../
target: /opt/vmpooler-projects
- type: bind - type: bind
source: ./data/vmpooler.yaml source: ./data/vmpooler.yaml
target: /etc/vmpooler/vmpooler.yaml target: /etc/vmpooler/vmpooler.yaml

View file

@ -0,0 +1,8 @@
#!/bin/sh
set -e
bundle install
set -- rerun -- bundle exec vmpooler "$@"
exec "$@"

54
docker/vmpooler.yaml Normal file
View file

@ -0,0 +1,54 @@
---
:providers:
:dummy:
filename: '/tmp/dummy-backing.yaml'
:dns_configs:
:example:
dns_class: dynamic-dns
#domain: 'localhost' # Flip these out for local requests
domain: 'example.com'
:redis:
server: 'localhost'
:auth:
provider: 'dummy'
:tagfilter:
url: '(.*)\/'
:config:
site_name: 'vmpooler'
logfile: '/var/log/vmpooler.log'
task_limit: 10
timeout: 15
vm_checktime: 1
vm_lifetime: 12
vm_lifetime_auth: 24
allowed_tags:
- 'created_by'
- 'project'
prefix: 'poolvm-'
:pools:
- name: 'debian-7-i386'
alias: [ 'debian-7-32' ]
template: 'Templates/debian-7-i386'
folder: 'Pooled VMs/debian-7-i386'
datastore: 'vmstorage'
size: 5
timeout: 15
ready_ttl: 1440
provider: dummy
dns_plugin: 'example'
- name: 'debian-7-x86_64'
alias: [ 'debian-7-64', 'debian-7-amd64' ]
template: 'Templates/debian-7-x86_64'
folder: 'Pooled VMs/debian-7-x86_64'
datastore: 'vmstorage'
size: 5
timeout: 15
ready_ttl: 1440
provider: dummy
dns_plugin: 'example'