133 lines
3.3 KiB
YAML
133 lines
3.3 KiB
YAML
# FIXME(cw); refactor into multiple per-function files
|
|
|
|
# FIXME(cw) consider using OSH helm-toolkit.utils.template
|
|
{{- 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: cloudinit
|
|
data:
|
|
metadata: |
|
|
{ "uuid": "example-01-vm.mydomain.com" }
|
|
userdata: |
|
|
#cloud-config
|
|
fqdn: example-01-vm.mydomain.com
|
|
users:
|
|
- name: root
|
|
ssh-authorized-keys:
|
|
- {{ .Values.auth.ssh_key }}
|
|
ssh_pwauth: True
|
|
runcmd:
|
|
- [ apt-get, update ]
|
|
- [ apt-get, install, -y, --force-yes, apache2 ]
|
|
---
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: configmap-startvm
|
|
data:
|
|
startvm: |
|
|
#!/bin/bash
|
|
#
|
|
# start of startvm
|
|
{{ tuple "bin/_startvm.txt" . | include "template" | indent 4 }}
|
|
# end of startvm
|
|
---
|
|
kind: PersistentVolumeClaim
|
|
apiVersion: v1
|
|
metadata:
|
|
name: example-01-vm
|
|
spec:
|
|
accessModes: [ "ReadWriteOnce" ]
|
|
resources:
|
|
requests:
|
|
storage: {{ .Values.volume.size }}
|
|
{{ if not .Values.volume.class_name }}
|
|
storageClassName: {{ .Values.volume.class_name }}
|
|
{{ end }}
|
|
---
|
|
apiVersion: extensions/v1beta1
|
|
kind: Deployment
|
|
metadata:
|
|
name: berth
|
|
spec:
|
|
replicas: 1
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: berth
|
|
annotations:
|
|
pod.beta.kubernetes.io/hostname: example-01-vm
|
|
spec:
|
|
nodeSelector:
|
|
{{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }}
|
|
hostNetwork: false
|
|
hostPID: false
|
|
securityContext:
|
|
runAsUser: 0
|
|
containers:
|
|
- name: example-01-vm
|
|
imagePullPolicy: IfNotPresent
|
|
image: {{ .Values.images.entrypoint }}
|
|
env:
|
|
- name: IMG_SOURCE
|
|
value: http://stupidest.org/vm/ubuntu-14.04-amd64.img
|
|
- name: IMG_TARGET
|
|
value: ubuntu-14.04-amd64.img
|
|
securityContext:
|
|
privileged: true
|
|
command:
|
|
- /usr/local/bin/startvm
|
|
ports:
|
|
- containerPort: {{ .Values.network.port }}
|
|
- containerPort: {{ .Values.network.vnc }}
|
|
readinessProbe:
|
|
tcpSocket:
|
|
port: {{ .Values.network.vnc }}
|
|
volumeMounts:
|
|
- name: volume-startvm
|
|
mountPath: /usr/local/bin/startvm
|
|
subPath: startvm
|
|
- name: image
|
|
mountPath: /image
|
|
- name: dev
|
|
mountPath: /dev
|
|
- name: sys
|
|
mountPath: /sys
|
|
- name: cloudinit
|
|
mountPath: /userdata
|
|
subPath: userdata
|
|
- name: cloudinit
|
|
mountPath: /metadata
|
|
subPath: metadata
|
|
volumes:
|
|
- name: volume-startvm
|
|
configMap:
|
|
name: configmap-startvm
|
|
defaultMode: 0755
|
|
- name: image
|
|
persistentVolumeClaim:
|
|
claimName: example-01-vm
|
|
- name: dev
|
|
hostPath:
|
|
path: /dev
|
|
- name: sys
|
|
hostPath:
|
|
path: /sys
|
|
- name: cloudinit
|
|
configMap:
|
|
name: cloudinit
|
|
items:
|
|
- key: userdata
|
|
path: userdata
|
|
- key: metadata
|
|
path: metadata
|