add yamls and mods to accept various images
This commit is contained in:
parent
e9825ad01a
commit
b44639dfe0
6 changed files with 133 additions and 18 deletions
|
|
@ -1,8 +1,6 @@
|
|||
FROM ubuntu:16.10
|
||||
MAINTAINER Dalton Hubble <dghubble@gmail.com>
|
||||
ARG CL_CHANNEL
|
||||
ARG CL_VERSION
|
||||
COPY scripts /scripts
|
||||
RUN /scripts/build
|
||||
EXPOSE 2222
|
||||
ENTRYPOINT ["/scripts/start"]
|
||||
EXPOSE 2222 5900
|
||||
ENTRYPOINT ["/scripts/start"]
|
||||
|
|
|
|||
48
kvm-rc-windows.yaml
Normal file
48
kvm-rc-windows.yaml
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
apiVersion: v1
|
||||
kind: ReplicationController
|
||||
metadata:
|
||||
name: kvm-test-windows
|
||||
labels:
|
||||
k8s-app: kvm-test-windows
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
k8s-app: kvm-test-windows
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: kvm-test-windows
|
||||
name: kvm-test-windows
|
||||
spec:
|
||||
terminationGracePeriodSeconds: 60
|
||||
containers:
|
||||
- image: docker.barakmich.com/barak/k8s-kvm:latest
|
||||
name: kvm-test-windows
|
||||
imagePullPolicy: Always
|
||||
securityContext:
|
||||
privileged: true
|
||||
ports:
|
||||
- containerPort: 2222
|
||||
name: ssh
|
||||
- containerPort: 5901
|
||||
name: vnc
|
||||
env:
|
||||
- name: VM_NAME
|
||||
value: kvmtest
|
||||
- name: VM_MEMORY
|
||||
value: 2G
|
||||
- name: DISK_IMG
|
||||
value: /data/windows.img
|
||||
- name: CD_IMG
|
||||
value: /data/n-msws16.iso
|
||||
args:
|
||||
- -spice port=5901,password=testme
|
||||
- -drive file=/data/virtio-win.iso,media=cdrom
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /data
|
||||
volumes:
|
||||
- name: data
|
||||
nfs:
|
||||
server: "127.0.0.1"
|
||||
path: "/fs/srv/k8skvm/windows"
|
||||
47
kvm-rc.yaml
Normal file
47
kvm-rc.yaml
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
apiVersion: v1
|
||||
kind: ReplicationController
|
||||
metadata:
|
||||
name: kvm-test
|
||||
labels:
|
||||
k8s-app: kvm-test
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
k8s-app: kvm-test
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: kvm-test
|
||||
name: kvm-test
|
||||
spec:
|
||||
terminationGracePeriodSeconds: 60
|
||||
containers:
|
||||
- image: docker.barakmich.com/barak/k8s-kvm:latest
|
||||
name: kvm-test
|
||||
imagePullPolicy: Always
|
||||
securityContext:
|
||||
privileged: true
|
||||
ports:
|
||||
- containerPort: 2222
|
||||
name: ssh
|
||||
- containerPort: 5900
|
||||
name: vnc
|
||||
env:
|
||||
- name: VM_NAME
|
||||
value: kvmtest
|
||||
- name: VM_MEMORY
|
||||
value: 2G
|
||||
- name: DISK_IMG
|
||||
value: /data/ubuntu.img
|
||||
- name: CD_IMG
|
||||
value: /data/lubuntu-17.04-desktop-amd64.iso
|
||||
args:
|
||||
- -spice port=5900,password=testme
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /data
|
||||
volumes:
|
||||
- name: data
|
||||
nfs:
|
||||
server: "127.0.0.1"
|
||||
path: "/fs/srv/k8skvm"
|
||||
23
kvm-windows.svc.yaml
Normal file
23
kvm-windows.svc.yaml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
# Arbitrary Metadata block. Must have a name.
|
||||
metadata:
|
||||
name: kvm-windows
|
||||
#labels:
|
||||
#name: my-service
|
||||
spec:
|
||||
# Optionally, have a type. Valid options are ExternalName, ClusterIP, NodePort, and LoadBalancer
|
||||
#type: NodePort
|
||||
#
|
||||
# Selector finds the target pod this service routes to.
|
||||
selector:
|
||||
name: kvm-test-windows
|
||||
ports:
|
||||
- port: 5901
|
||||
# service name for this port, must be a DNS label.
|
||||
name: spice
|
||||
# targetPort can be a name or a number on the pod that we're targeting
|
||||
targetPort: 5901
|
||||
protocol: TCP
|
||||
# If 'type: NodePort', which port to expose on all machines
|
||||
#nodePort: 32378
|
||||
|
|
@ -5,19 +5,13 @@ set -exu
|
|||
apt-get update
|
||||
apt-get install -y \
|
||||
curl \
|
||||
bzip2 \
|
||||
openssh-client \
|
||||
qemu-kvm
|
||||
|
||||
URL="http://${CL_CHANNEL}.release.core-os.net/amd64-usr/${CL_VERSION}/coreos_production_qemu_image.img.bz2"
|
||||
echo "Downloading Container Linux $CL_CHANNEL $CL_VERSION $URL"
|
||||
curl -O $URL
|
||||
bzip2 -d coreos_production_qemu_image.img.bz2
|
||||
|
||||
curl -L https://github.com/coreos/container-linux-config-transpiler/releases/download/v0.3.0/ct-v0.3.0-x86_64-unknown-linux-gnu -o ct
|
||||
chmod +x ct
|
||||
|
||||
apt-get remove -y curl bzip2
|
||||
apt-get autoremove -y
|
||||
apt-get clean
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
#!/usr/bin/env bash
|
||||
set -eox pipefail
|
||||
|
||||
VM_NAME="${VM_NAME:-coreos-kvm}"
|
||||
VM_NAME="${VM_NAME:-k8s-kvm}"
|
||||
VM_MEMORY="${VM_MEMORY:-4G}"
|
||||
VM_DISK_SIZE="${VM_DISK_SIZE:-12G}"
|
||||
# hostfwd=[tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport
|
||||
HOSTFWD="${HOSTFWD:-hostfwd=tcp::2222-:22}"
|
||||
DISK_IMG="${DISK_IMG:-./coreos_production_qemu_image.img}"
|
||||
CD_ARG=""
|
||||
|
||||
if [ -n "${CLOUD_CONFIG_FILE}" ]; then
|
||||
echo "Setting cloud config file: ${CLOUD_CONFIG_FILE}"
|
||||
|
|
@ -32,7 +33,9 @@ if [ -n "$CONFIG_FILE" ]; then
|
|||
set -- -fw_cfg name=opt/com.coreos/config,file="${PWD}/ignition.json" "$@"
|
||||
fi
|
||||
|
||||
qemu-img resize ./coreos_production_qemu_image.img "${VM_DISK_SIZE}"
|
||||
if [ -n "$CD_IMG" ]; then
|
||||
CD_ARG="-drive file=${CD_IMG},media=cdrom"
|
||||
fi
|
||||
|
||||
# https://alpha.release.core-os.net/amd64-usr/current/coreos_production_qemu.sh
|
||||
qemu-system-x86_64 \
|
||||
|
|
@ -40,10 +43,12 @@ qemu-system-x86_64 \
|
|||
-enable-kvm \
|
||||
-cpu host \
|
||||
-m "${VM_MEMORY}" \
|
||||
-net nic,model=virtio \
|
||||
-net user,"${HOSTFWD}",hostname="${VM_NAME}" \
|
||||
-drive if=virtio,file=./coreos_production_qemu_image.img \
|
||||
-device virtio-net,netdev=vmnic \
|
||||
-netdev user,id=vmnic,"${HOSTFWD}",hostname="${VM_NAME}" \
|
||||
-drive if=virtio,file="${DISK_IMG}" \
|
||||
${CD_ARG} \
|
||||
-nographic \
|
||||
-machine accel=kvm \
|
||||
-vga std \
|
||||
-smp 2 \
|
||||
"$@"
|
||||
$@
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue