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

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'