Initial commit

This commit is contained in:
Gene Liverman 2021-11-30 17:01:17 -05:00
commit 074778d0b0
No known key found for this signature in database
GPG key ID: 3AF83985B6C857C6
34 changed files with 1381 additions and 0 deletions

20
.github/dependabot.yml vendored Normal file
View file

@ -0,0 +1,20 @@
version: 2
updates:
- package-ecosystem: bundler
directory: "/docker/test-all-providers/"
schedule:
interval: daily
time: "13:00"
open-pull-requests-limit: 10
- package-ecosystem: docker
directory: "/docker/dev/"
schedule:
interval: daily
time: "13:00"
open-pull-requests-limit: 10
- package-ecosystem: docker
directory: "/docker/test-all-providers/"
schedule:
interval: daily
time: "13:00"
open-pull-requests-limit: 10

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
/*/**/vendor/bundle/
/docker/**/vmpooler.yaml
.vagrant/

201
LICENSE Normal file
View file

@ -0,0 +1,201 @@
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.

7
README.md Normal file
View file

@ -0,0 +1,7 @@
# vmpooler-deployment
This repo contains Dockerfiles and a Helm chart that can be used to deploy [VMPooler](https://github.com/puppetlabs/vmpooler).
## Status
This repo is a work in progress. It mostly works but many bits need adjusting here and there as they were compiled from other locations. More details will be added soon.

17
Vagrantfile vendored Normal file
View file

@ -0,0 +1,17 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "genebean/almalinux-8-docker-ce"
config.vm.network "forwarded_port", guest: 8080, host: 8080 # VMPooler api in docker-compose
config.vm.network "forwarded_port", guest: 8081, host: 8081 # VMPooler manager in docker-compose
config.vm.network "forwarded_port", guest: 8082, host: 8082 # Jaeger in docker-compose
config.vm.provision "shell", inline: <<-SCRIPT
mkdir /var/log/vmpooler
chown vagrant:vagrant /var/log/vmpooler
curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version
SCRIPT
end

3
docker/dev/.dockerignore Normal file
View file

@ -0,0 +1,3 @@
.bundle/
vendor/
update-gemfile-lock.sh

36
docker/dev/Dockerfile Normal file
View file

@ -0,0 +1,36 @@
# Run vmpooler in a Docker container! Configuration can either be embedded
# and built within the current working directory, or stored in a
# VMPOOLER_CONFIG environment value and passed to the Docker daemon.
#
# BUILD:
# docker build -t vmpooler .
#
# RUN:
# docker run -e VMPOOLER_CONFIG -p 80:4567 -it vmpooler
FROM jruby:9.2-jdk
ENV RACK_ENV=production
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends make && \
apt-get clean autoclean && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
COPY docker/docker-entrypoint.sh /usr/local/bin/
COPY ./Gemfile ./
COPY ./vmpooler.gemspec ./
COPY ./lib/vmpooler/version.rb ./lib/vmpooler/version.rb
RUN gem install bundler && \
bundle config set --local jobs 3 && \
bundle install
COPY ./ ./
RUN gem build vmpooler.gemspec && \
gem install vmpooler*.gem && \
chmod +x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]

39
docker/dev/Dockerfile-aio Normal file
View file

@ -0,0 +1,39 @@
# Run vmpooler in a Docker container! Configuration can either be embedded
# and built within the current working directory, or stored in a
# VMPOOLER_CONFIG environment value and passed to the Docker daemon.
#
# BUILD:
# docker build -t vmpooler .
#
# RUN:
# docker run -e VMPOOLER_CONFIG -p 80:4567 -it vmpooler
FROM jruby:9.2.9-jdk
RUN mkdir -p /var/lib/vmpooler
WORKDIR /var/lib/vmpooler
RUN echo "deb http://httpredir.debian.org/debian jessie main" >/etc/apt/sources.list.d/jessie-main.list
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends make redis-server && \
apt-get clean autoclean && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
ADD Gemfile* /var/lib/vmpooler/
RUN bundle install --system
RUN ln -s /opt/jruby/bin/jruby /usr/bin/jruby
COPY . /var/lib/vmpooler
ENV VMPOOLER_LOG /var/log/vmpooler.log
CMD \
/etc/init.d/redis-server start \
&& /var/lib/vmpooler/scripts/vmpooler_init.sh start \
&& while [ ! -f ${VMPOOLER_LOG} ]; do sleep 1; done ; \
tail -f ${VMPOOLER_LOG}

View file

@ -0,0 +1,73 @@
# For local development run with a dummy provider
version: '3.8'
services:
vmpooler-api:
build:
context: ../
dockerfile: docker/Dockerfile_local
volumes:
- type: bind
source: ${PWD}/vmpooler.yaml
target: /etc/vmpooler/vmpooler.yaml
ports:
- "8080:4567"
networks:
- redis-net
environment:
- VMPOOLER_DEBUG=true # for use of dummy auth
- VMPOOLER_CONFIG_FILE=/etc/vmpooler/vmpooler.yaml
- REDIS_SERVER=redislocal
- LOGFILE=/dev/null
- JRUBY_OPTS=-Xinvokedynamic.yield=false
- VMPOOLER_TRACING_ENABLED=true
- VMPOOLER_TRACING_JAEGER_HOST=http://jaeger-aio:14268/api/traces
image: vmpooler-local
command: api
depends_on:
- redislocal
vmpooler-manager:
build:
context: ../
dockerfile: docker/Dockerfile_local
volumes:
- type: bind
source: ${PWD}/vmpooler.yaml
target: /etc/vmpooler/vmpooler.yaml
ports:
- "8081:4567"
networks:
- redis-net
environment:
- VMPOOLER_DEBUG=true # for use of dummy auth
- VMPOOLER_CONFIG_FILE=/etc/vmpooler/vmpooler.yaml
- REDIS_SERVER=redislocal
- LOGFILE=/dev/null
- JRUBY_OPTS=-Xinvokedynamic.yield=false
- VMPOOLER_TRACING_ENABLED=true
- VMPOOLER_TRACING_JAEGER_HOST=http://jaeger-aio:14268/api/traces
image: vmpooler-local
command: manager
depends_on:
- redislocal
redislocal:
image: redis
# Uncomment this if you don't want the redis data to persist
#command: "redis-server --save '' --appendonly no"
ports:
- "6379:6379"
networks:
- redis-net
jaeger-aio:
image: jaegertracing/all-in-one:1.18
ports:
- "14250:14250"
- "8082:16686"
networks:
- redis-net
user: '1001'
read_only: true
cap_drop:
- ALL
networks:
redis-net:

View file

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

View file

@ -0,0 +1,2 @@
---
BUNDLE_PATH: "vendor/bundle"

View file

@ -0,0 +1,3 @@
.bundle/
vendor/
update-gemfile-lock.sh

View file

@ -0,0 +1,34 @@
# Run vmpooler in a Docker container! Configuration can either be embedded
# and built within the current working directory, or stored in a
# VMPOOLER_CONFIG environment value and passed to the Docker daemon.
#
# BUILD:
# docker build -t vmpooler .
#
# RUN:
# docker run -e VMPOOLER_CONFIG -p 80:4567 -it vmpooler
FROM jruby:9.2-jdk
ENV RACK_ENV=production
ENV LOGFILE=/dev/stdout \
RACK_ENV=production
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends make && \
apt-get clean autoclean && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
COPY ./docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
COPY ./Gemfile* ./
RUN gem install bundler && \
bundle config set --local jobs 3 && \
bundle install
ENTRYPOINT ["docker-entrypoint.sh"]

View file

@ -0,0 +1,4 @@
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
gem 'vmpooler', git: 'https://github.com/puppetlabs/vmpooler.git', branch: 'extract-vsphere-provider'
gem 'vmpooler-vsphere-provider', git: 'https://github.com/puppetlabs/vmpooler-provider-vsphere.git'

View file

@ -0,0 +1,141 @@
GIT
remote: https://github.com/puppetlabs/vmpooler-provider-vsphere.git
revision: a08cba099f867b1db01a50940ec3ae9239245db5
specs:
vmpooler-vsphere-provider (1.3.0)
rbvmomi (>= 2.1, < 4.0)
GIT
remote: https://github.com/puppetlabs/vmpooler.git
revision: d1c86eaf9b8fc1945213dad009db1172dffac7f2
branch: extract-vsphere-provider
specs:
vmpooler (1.3.0)
concurrent-ruby (~> 1.1)
connection_pool (~> 2.2)
net-ldap (~> 0.16)
nokogiri (~> 1.10)
opentelemetry-exporter-jaeger (= 0.17.0)
opentelemetry-instrumentation-concurrent_ruby (= 0.17.0)
opentelemetry-instrumentation-redis (= 0.17.0)
opentelemetry-instrumentation-sinatra (= 0.17.0)
opentelemetry-resource_detectors (= 0.17.0)
opentelemetry-sdk (= 0.17.0)
pickup (~> 0.0.11)
prometheus-client (~> 2.0)
puma (~> 5.0, >= 5.0.4)
rack (~> 2.2)
rake (~> 13.0)
redis (~> 4.1)
sinatra (~> 2.0)
spicy-proton (~> 2.1)
statsd-ruby (~> 1.4)
GEM
remote: https://rubygems.org/
specs:
bindata (2.4.10)
builder (3.2.4)
concurrent-ruby (1.1.9)
connection_pool (2.2.5)
faraday (1.8.0)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0.1)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.1)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
multipart-post (>= 1.2, < 3)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
google-cloud-env (1.5.0)
faraday (>= 0.17.3, < 2.0)
json (2.6.1)
json (2.6.1-java)
multipart-post (2.1.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
net-ldap (0.17.0)
nio4r (2.5.8)
nio4r (2.5.8-java)
nokogiri (1.12.5-java)
racc (~> 1.4)
nokogiri (1.12.5-x86_64-linux)
racc (~> 1.4)
opentelemetry-api (0.17.0)
opentelemetry-common (0.17.0)
opentelemetry-api (~> 0.17.0)
opentelemetry-exporter-jaeger (0.17.0)
opentelemetry-api (~> 0.17.0)
opentelemetry-common (~> 0.17.0)
opentelemetry-sdk (~> 0.17.0)
thrift
opentelemetry-instrumentation-base (0.17.0)
opentelemetry-api (~> 0.17.0)
opentelemetry-instrumentation-concurrent_ruby (0.17.0)
opentelemetry-api (~> 0.17.0)
opentelemetry-instrumentation-base (~> 0.17.0)
opentelemetry-instrumentation-redis (0.17.0)
opentelemetry-api (~> 0.17.0)
opentelemetry-common (~> 0.17.0)
opentelemetry-instrumentation-base (~> 0.17.0)
opentelemetry-instrumentation-sinatra (0.17.0)
opentelemetry-api (~> 0.17.0)
opentelemetry-instrumentation-base (~> 0.17.0)
opentelemetry-resource_detectors (0.17.0)
google-cloud-env
opentelemetry-sdk
opentelemetry-sdk (0.17.0)
opentelemetry-api (~> 0.17.0)
opentelemetry-common (~> 0.17.0)
opentelemetry-instrumentation-base (~> 0.17.0)
optimist (3.0.1)
pickup (0.0.11)
prometheus-client (2.1.0)
puma (5.5.2)
nio4r (~> 2.0)
puma (5.5.2-java)
nio4r (~> 2.0)
racc (1.6.0)
racc (1.6.0-java)
rack (2.2.3)
rack-protection (2.1.0)
rack
rake (13.0.6)
rbvmomi (3.0.0)
builder (~> 3.2)
json (~> 2.3)
nokogiri (~> 1.10)
optimist (~> 3.0)
redis (4.5.1)
ruby2_keywords (0.0.5)
sinatra (2.1.0)
mustermann (~> 1.0)
rack (~> 2.2)
rack-protection (= 2.1.0)
tilt (~> 2.0)
spicy-proton (2.1.13)
bindata (~> 2.3)
statsd-ruby (1.5.0)
thrift (0.15.0)
tilt (2.0.10)
PLATFORMS
universal-java-1.8
x86_64-linux
DEPENDENCIES
vmpooler!
vmpooler-vsphere-provider!
BUNDLED WITH
2.2.32

View file

@ -0,0 +1,73 @@
# For local development run with a dummy provider
version: '3.8'
services:
vmpooler-api:
build:
context: ./
dockerfile: Dockerfile
volumes:
- type: bind
source: ${PWD}/vmpooler.yaml
target: /etc/vmpooler/vmpooler.yaml
ports:
- "8080:4567"
networks:
- redis-net
environment:
- VMPOOLER_DEBUG=true # for use of dummy auth
- VMPOOLER_CONFIG_FILE=/etc/vmpooler/vmpooler.yaml
- REDIS_SERVER=redislocal
- LOGFILE=/dev/null
- JRUBY_OPTS=-Xinvokedynamic.yield=false
- VMPOOLER_TRACING_ENABLED=true
- VMPOOLER_TRACING_JAEGER_HOST=http://jaeger-aio:14268/api/traces
image: vmpooler-local
command: api
depends_on:
- redislocal
vmpooler-manager:
build:
context: ./
dockerfile: Dockerfile
volumes:
- type: bind
source: ${PWD}/vmpooler.yaml
target: /etc/vmpooler/vmpooler.yaml
ports:
- "8081:4567"
networks:
- redis-net
environment:
- VMPOOLER_DEBUG=true # for use of dummy auth
- VMPOOLER_CONFIG_FILE=/etc/vmpooler/vmpooler.yaml
- REDIS_SERVER=redislocal
- LOGFILE=/dev/null
- JRUBY_OPTS=-Xinvokedynamic.yield=false
- VMPOOLER_TRACING_ENABLED=true
- VMPOOLER_TRACING_JAEGER_HOST=http://jaeger-aio:14268/api/traces
image: vmpooler-local
command: manager
depends_on:
- redislocal
redislocal:
image: redis
# Uncomment this if you don't want the redis data to persist
#command: "redis-server --save '' --appendonly no"
ports:
- "6379:6379"
networks:
- redis-net
jaeger-aio:
image: jaegertracing/all-in-one:1.18
ports:
- "14250:14250"
- "8082:16686"
networks:
- redis-net
user: '1001'
read_only: true
cap_drop:
- ALL
networks:
redis-net:

View file

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

View file

@ -0,0 +1,6 @@
#!/usr/bin/env bash
docker run -it --rm \
-v $(pwd):/app \
$(grep ^FROM ./Dockerfile |cut -d ' ' -f2) \
/bin/bash -c 'apt-get update -qq && apt-get install -y --no-install-recommends make && cd /app && gem install bundler && bundle install --jobs 3'

23
helm/vmpooler/.helmignore Normal file
View file

@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

6
helm/vmpooler/Chart.lock Normal file
View file

@ -0,0 +1,6 @@
dependencies:
- name: redis
repository: https://charts.bitnami.com/bitnami
version: 10.7.12
digest: sha256:cd2b6498209e347387f3467403cb063d93a44fdd345cd75fb090eed1eb8debee
generated: "2020-08-03T16:14:08.491207-07:00"

10
helm/vmpooler/Chart.yaml Normal file
View file

@ -0,0 +1,10 @@
apiVersion: v2
name: vmpooler
description: A Helm chart to deploy vmpooler
type: application
version: 1.5.2
appVersion: 1.3.0
dependencies:
- name: redis
repository: https://charts.bitnami.com/bitnami
version: 10.7.12

Binary file not shown.

View file

@ -0,0 +1,21 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "vmpooler.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "vmpooler.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "vmpooler.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "vmpooler.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
{{- end }}

View file

@ -0,0 +1,63 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "vmpooler.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "vmpooler.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "vmpooler.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Common labels
*/}}
{{- define "vmpooler.labels" -}}
helm.sh/chart: {{ include "vmpooler.chart" . }}
{{ include "vmpooler.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{/*
Selector labels
*/}}
{{- define "vmpooler.selectorLabels" -}}
app.kubernetes.io/name: {{ include "vmpooler.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
{{/*
Create the name of the service account to use
*/}}
{{- define "vmpooler.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "vmpooler.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

View file

@ -0,0 +1,20 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: vmpooler-baseconfig
data:
vmpooler.yaml: |
---
{{- with .Values.baseconfig_extras }}
{{- toYaml . | nindent 4 }}
{{- end }}
:tagfilter:
project: '^([^/]+)'
:auth:
{{- with .Values.auth }}
{{- toYaml . | nindent 6 }}
{{- end }}
:prometheus:
prefix: {{ .Values.vmpoolerInstance }}

View file

@ -0,0 +1,11 @@
{{- if eq .Values.poolsConfigMapName "vmpooler-pools" -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: vmpooler-pools
data:
pools.yaml: |
---
:pools:
{{- toYaml .Values.pools | nindent 6 }}
{{- end -}}

View file

@ -0,0 +1,122 @@
{{- $fullName := include "vmpooler.fullname" . -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ $fullName }}-api
labels:
app: {{ $fullName }}-api
redis-client: "true"
{{- include "vmpooler.labels" . | nindent 4 }}
test: liveness
annotations:
configmap.reloader.stakater.com/reload: "{{ .Values.configmapName }},vmpooler-pools"
secret.reloader.stakater.com/reload: 'redis'
spec:
replicas: {{ .Values.api.replicaCount }}
selector:
matchLabels:
app: {{ $fullName }}-api
template:
metadata:
labels:
app: {{ $fullName }}-api
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "vmpooler.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ $fullName }}-api
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: {{ .Values.service.port }}
resources:
{{- toYaml .Values.api.resources | nindent 12 }}
args:
- 'api'
livenessProbe:
httpGet:
path: /api/v1/status
port: {{ .Values.service.port }}
initialDelaySeconds: 40
periodSeconds: 10
readinessProbe:
httpGet:
path: /api/v1/status
port: {{ .Values.service.port }}
initialDelaySeconds: 40
periodSeconds: 10
env:
- name: JRUBY_OPTS
value: '-J-XX:+UseG1GC'
- name: PORT
value: {{ .Values.service.port | quote }}
- name: SITE_NAME
value: '<b>{{ .Values.vmpoolerInstance }}</b>.{{ .Values.ingress.domain }}'
- name: DOMAIN
value: {{ .Values.sut_domain }}
- name: EXPERIMENTAL_FEATURES
value: 'true'
- name: USAGE_STATS
value: '{{ .Values.usage_stats }}'
- name: VMPOOLER_CONFIG_FILE
value: /etc/vmpooler/vmpooler.yaml
- name: VMPOOLER_TRACING_ENABLED
value: '{{ .Values.tracing.enabled }}'
- name: VMPOOLER_TRACING_JAEGER_HOST
value: '{{ .Values.tracing.jaegerHost }}'
- name: EXTRA_CONFIG
value: '/etc/vmpooler/config/pools.yaml'
- name: REDIS_SERVER
value: 'redis-master'
- name: ONDEMAND_REQUEST_TTL
value: "50"
- name: ONDEMAND_CLONE_LIMIT
value: "50"
- name: MAX_LIFETIME_UPPER_LIMIT
value: "336"
- name: VM_LIFETIME
value: '2'
- name: VM_LIFETIME_AUTH
value: '12'
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: redis
key: redis-password
volumeMounts:
- name: config-volume
mountPath: /etc/vmpooler
- name: pools-config
mountPath: /etc/vmpooler/config
volumes:
- name: config-volume
configMap:
name: {{ .Values.configmapName }}
items:
- key: vmpooler.yaml
path: vmpooler.yaml
- name: pools-config
configMap:
name: vmpooler-pools
items:
- key: pools.yaml
path: pools.yaml
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View file

@ -0,0 +1,162 @@
{{- $fullName := include "vmpooler.fullname" . -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ $fullName }}-manager
labels:
app: {{ $fullName }}-manager
redis-client: "true"
{{- include "vmpooler.labels" . | nindent 4 }}
test: liveness
annotations:
configmap.reloader.stakater.com/reload: "{{ .Values.configmapName }},vmpooler-pools"
secret.reloader.stakater.com/reload: 'redis'
spec:
replicas: 1
selector:
matchLabels:
app: {{ $fullName }}-manager
strategy:
type: Recreate
template:
metadata:
labels:
app: {{ $fullName }}-manager
{{- with .Values.manager.annotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "vmpooler.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ $fullName }}-manager
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: {{ .Values.service.port }}
resources:
{{- toYaml .Values.manager.resources | nindent 12 }}
args:
- 'manager'
livenessProbe:
exec:
command:
- /bin/sh
- -c
- ps -p 1 > /dev/null
initialDelaySeconds: 40
periodSeconds: 10
readinessProbe:
exec:
command:
- /bin/sh
- -c
- ps -p 1 > /dev/null
initialDelaySeconds: 40
periodSeconds: 10
env:
- name: JRUBY_OPTS
value: '-J-XX:+UseG1GC -Xinvokedynamic.yield=false'
- name: TASK_LIMIT
value: '30'
- name: MIGRATION_LIMIT
value: '10'
- name: VM_LIFETIME
value: '2'
- name: VM_LIFETIME_AUTH
value: '12'
- name: VM_CHECKTIME
value: '1'
- name: CREATE_FOLDERS
value: 'true'
- name: CREATE_TEMPLATE_DELTA_DISKS
value: 'true'
- name: CREATE_LINKED_CLONES
value: 'true'
- name: MAX_TRIES
value: '3'
- name: RETRY_FACTOR
value: '20'
- name: PURGE_UNCONFIGURED_FOLDERS
value: 'true'
- name: DOMAIN
value: {{ .Values.sut_domain }}
- name: VMPOOLER_CONFIG_FILE
value: /etc/vmpooler/vmpooler.yaml
- name: VMPOOLER_TRACING_ENABLED
value: '{{ .Values.tracing.enabled }}'
- name: VMPOOLER_TRACING_JAEGER_HOST
value: '{{ .Values.tracing.jaegerHost }}'
- name: LOGFILE
value: /dev/stdout
- name: EXTRA_CONFIG
value: '{{ .Values.additionalConfigFiles }}'
- name: TIMEOUT
value: '15'
- name: READY_TTL
value: "480"
- name: REDIS_SERVER
value: 'redis-master'
- name: REDIS_CONNECTION_POOL_SIZE
value: "200"
- name: REDIS_CONNECTION_POOL_TIMEOUT
value: "40"
- name: ONDEMAND_REQUEST_TTL
value: "50"
- name: ONDEMAND_CLONE_LIMIT
value: "50"
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: redis
key: redis-password
volumeMounts:
- name: base-config
mountPath: /etc/vmpooler
- name: pools-config
mountPath: /etc/vmpooler/config
volumes:
- name: base-config
configMap:
name: {{ .Values.configmapName }}
items:
- key: vmpooler.yaml
path: vmpooler.yaml
- name: pools-config
configMap:
name: {{ .Values.poolsConfigMapName }}
items:
- key: pools.yaml
path: pools.yaml
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View file

@ -0,0 +1,33 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "vmpooler.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "vmpooler.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
rules:
- host: '{{ .Values.vmpoolerInstance }}.{{ .Values.ingress.domain }}'
http:
paths:
- backend:
serviceName: {{ $fullName }}-api
servicePort: {{ $svcPort }}
path: /
{{ if .Values.ingress.useTLS -}}
tls:
- hosts:
- '{{ .Values.vmpoolerInstance }}.{{ .Values.ingress.domain }}'
secretName: '{{ .Values.vmpoolerInstance }}.{{ .Values.ingress.domain }}-tls'
{{- end }}
{{- end }}

View file

@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "vmpooler.fullname" . }}-api
labels:
{{- include "vmpooler.labels" . | nindent 4 }}
annotations:
prometheus.io/scrape: {{ .Values.service.metricsEnabled | quote }}
prometheus.io/path: '/prometheus'
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: {{ .Values.service.port }}
protocol: TCP
name: http
clusterIP: None
selector:
app: {{ include "vmpooler.fullname" . }}-api

View file

@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "vmpooler.fullname" . }}-manager
labels:
{{- include "vmpooler.labels" . | nindent 4 }}
annotations:
prometheus.io/scrape: {{ .Values.service.metricsEnabled | quote }}
prometheus.io/path: '/prometheus'
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: {{ .Values.service.port }}
protocol: TCP
name: http
clusterIP: None
selector:
app: {{ include "vmpooler.fullname" . }}-manager

View file

@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "vmpooler.serviceAccountName" . }}
labels:
{{- include "vmpooler.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end -}}

View file

@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "vmpooler.fullname" . }}-test-connection"
labels:
{{- include "vmpooler.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test-success
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "vmpooler.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never

171
helm/vmpooler/values.yaml Normal file
View file

@ -0,0 +1,171 @@
# this is used for the site name, the metrics prefix, and is
# the hostname in the ingress
vmpoolerInstance: 'test-instance'
image:
repository: vmpooler
pullPolicy: Always
configmapName: 'vmpooler-baseconfig'
sut_domain: 'vmpooler.example.com'
usage_stats: true
tracing:
enabled: 'false'
# jaegerHost: 'http://otel-collector.otel-collector.svc:14268/api/traces'
baseconfig_extras: {}
# :config:
# backend_weight:
# vmware_cluster1: 0
# vmware_cluster2: 100
# vmware_cluster4: 180
auth:
provider: 'dummy'
# provider: 'ldap'
# :ldap:
# host: 'ldap.example.com'
# port: 636
# encryption:
# :method: :simple_tls
# :tls_options:
# :ssl_version: 'TLSv1_2'
# base:
# - 'ou=dept1,dc=example,dc=com'
# - 'ou=dept2,dc=example,dc=com'
# user_object:
# - 'uid'
# - 'cn'
additionalConfigFiles: '/etc/vmpooler/config/pools.yaml'
api:
replicaCount: 1
resources:
requests:
cpu: 1500m
memory: 2Gi
limits:
cpu: 2000m
memory: 2Gi
manager:
resources:
requests:
cpu: 4000m
memory: 4Gi
limits:
cpu: 4000m
memory: 4Gi
annotations: {}
serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
# Letting the name be created automatically will prevent the SA resource from being
# shared between multiple instances of vmpooler such as when stage and prod are both
# deployed to the same cluster.
name: ''
podSecurityContext:
fsGroup: 1001
securityContext:
capabilities:
drop:
- ALL
runAsNonRoot: true
readOnlyRootFilesystem: true
runAsUser: 1001
runAsGroup: 1001
service:
type: ClusterIP
port: 4567
metricsEnabled: true
ingress:
enabled: false
# useTLS: true
# annotations:
# cert-manager.io/cluster-issuer: letsencrypt-prod
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: 'true'
# nginx.ingress.kubernetes.io/ssl-redirect: 'true'
# domain: k8s.example.com
nodeSelector: {}
tolerations: []
affinity: {}
# Redis provided by bitnami/redis
# For a full list of parameters see: https://github.com/bitnami/charts/tree/master/bitnami/redis/
redis:
fullnameOverride: redis
cluster:
enabled: false
networkPolicy:
enabled: true
securityContext:
enabled: true
fsGroup: 1001
runAsUser: 1001
master:
resources:
requests:
cpu: 1000m
memory: 2048Mi
limits:
cpu: 1000m
memory: 2048Mi
livenessProbe:
failureThreshold: 10
readinessProbe:
failureThreshold: 10
metrics:
enabled: true
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
cpu: 200m
memory: 256Mi
# Pools are listed last becaue the list can be really long when listed here.
# The default ConfigMap uses the value of the pools key to create pools.yaml.
# You could, instead, provide your own ConfigMap and specify its name below.
poolsConfigMapName: vmpooler-pools
pools:
- name: 'almalinux-8-x86_64-pixa4'
template: 'templates/cluster2/almalinux-8-x86_64-0.0.2'
folder: 'test-instance/cluster2/almalinux-8-x86_64'
datastore: 'vmpooler_cluster2'
clone_target: 'cluster2'
size: 5
datacenter: 'pix'
provider: 'vsphere-ci67'
snapshot_mainMem_ioBlockPages: '2048'
snapshot_mainMem_iowait: '5'
network: 'vmpooler1'
- name: 'centos-6-x86_64-pixa4'
alias: [ 'centos-6-x86_64' ]
template: 'templates/cluster2/centos-6.8-x86_64-0.0.2-8gb'
folder: test-instance/cluster2/centos-6-x86_64'
datastore: 'vmpooler_cluster2'
clone_target: 'cluster2'
size: 0
timeout: 5
datacenter: 'pix'
provider: 'vsphere-ci67'
snapshot_mainMem_ioBlockPages: '2048'
snapshot_mainMem_iowait: '5'
network: 'vmpooler2'