Skip to content

Instantly share code, notes, and snippets.

@jcpowermac
Forked from karmab/.gitignore
Created June 29, 2018 20:51
Show Gist options
  • Save jcpowermac/550fe23c733de8fb88b5afbf8603a3c6 to your computer and use it in GitHub Desktop.
Save jcpowermac/550fe23c733de8fb88b5afbf8603a3c6 to your computer and use it in GitHub Desktop.
CNV LAB
*_rsa
*_rsa.pub

How to use

kcli plan -f kubevirt.yml -P nodes=10

Available parameters:

Parameter Default Value
kubevirt_version v0.7.0-alpha.2
openshift_version 3.10
disk_size 60
memory 10240
nodes 1
deploy true
cdi false
nested false

About nested

for nested virtualization, we need a base image with nested enabled

gcloud compute images create nested-centos7 --source-image-family centos-7 --source-image-project centos-cloud --licenses "https://www.googleapis.com/compute/v1/projects/vm-options/global/licenses/enable-vmx"
wget -P /root https://raw.githubusercontent.com/kubevirt/containerized-data-importer/master/manifests/example/golden-pvc.yaml
wget -P /root https://raw.githubusercontent.com/kubevirt/containerized-data-importer/master/manifests/example/endpoint-secret.yaml
wget -P /root https://raw.githubusercontent.com/kubevirt/containerized-data-importer/master/manifests/controller/cdi-controller-deployment.yaml
oc new-project golden-images
oc create -f /root/cdi-controller-deployment.yaml
oc adm policy add-cluster-role-to-user cluster-admin -z cdi-sa -n golden-images
sh /root/requirements.sh
sh /root/openshift.sh
sh /root/kubevirt.sh
[% if cdi %]
sh /root/cdi.sh
[% endif %]
VERSION="[[ kubevirt_version ]]"
yum -y install xorg-x11-xauth virt-viewer
oc project kube-system
wget https://github.com/kubevirt/kubevirt/releases/download/$VERSION/kubevirt.yaml
oc adm policy add-scc-to-user privileged -z kubevirt-privileged -n kube-system
oc adm policy add-scc-to-user privileged -z kubevirt-controller -n kube-system
[% if nested %]
oc create configmap -n kube-system kubevirt-config --from-literal debug.allowEmulation=true
[% endif %]
oc create -f kubevirt.yaml
docker pull kubevirt/virt-launcher:$VERSION
wget https://github.com/kubevirt/kubevirt/releases/download/$VERSION/virtctl-$VERSION-linux-amd64
mv virtctl-$VERSION-linux-amd64 /usr/bin/virtctl
chmod u+x /usr/bin/virtctl
ssh-keygen -t rsa -N '' -f /root/.ssh/id_rsa
[% if openshift_version != '3.10' %]
setfacl -m user:107:rwx /var/lib/origin/openshift.local.pv/pv*
[% elif deploy %]
setfacl -m user:107:rwx /root/openshift.local.clusterup/openshift.local.pv/pv*
[% else %]
setfacl -m user:107:rwx /openshift.local.clusterup/openshift.local.pv/pv*
[%endif %]
oc adm policy add-scc-to-user privileged -z kubevirt-controller -n kube-system
parameters:
kubevirt_version: v0.7.0-alpha.2
openshift_version: "3.10"
disk_size: 60
memory: 10240
nodes: 1
deploy: true
cdi: true
nested: false
keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC5Qbj7vDf0uYQpeYb432g5R4YvYJaPfPA4EM4qc3lO62c7oUsWbZlZBl5neEWX41HGCIP4Zm1ybN9iiDyeIns6hg5OkU2vUGuPtV2KCAZOI7snzXeZxlrjsVMjMy/CYUlvIOAPxY4XzfzMMAJjIJni18R2PqVRI4f4SeSq3IIzpnOu2VQmqjFmmdybQY83BvBvWj6KLszAXkJk9LkZSAoktXimDBWFPQYikzZihLolRxwHzo21lXSw58D1N+6IeMudOviAte5yu6FBUN6dFYbt9dkLuH2/ONliFz/042n5UNp0wC5BLdpVwJpWqqrCVaeXBgla/gYm8YNZJIAlf8K5 [email protected]
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCq9Dr3eNBqaNXTZuHNTvWoaB/gLNpkKYk2AUSzyc6EOexFmXkSOH/3tGIFJINnJhx8YpfHXF+zsp7UfBmxVZQa7zBi7xKixkV7lIBlCD/ZD9LRV7WxBqi5Eb39YPnH1A6W6fwGrR+wQMkC299b2SF3zBzuQgAYdixSYzNDsB7rt89BNSgFmAkv6mL/tVpgVBV6ax6Bmn5XKEvFkHaC/i0YKIiqq+xtoa9w6jq7TQE5XDiAgx51S0uSLvxz+UkKxCbN1oo8FZ4cvGF3rL8NmigzFBzCpmLSUvF1qFbAeMQEEfmZBex5v1TrAbxaH3POBcApOKfEHvaUm9yY44zCXJU5 jcallen@jcallen
[% for node in range(0, nodes) %]
cnvlab0[[ node + 1 ]]:
[% if nested %]
template: nested-centos7
[% else %]
template: centos-7
[% endif %]
numcpus: 2
memory: [[ memory ]]
keys: [[ keys ]]
nets:
- default
disks:
- size: [[ disk_size ]]
pool: default
files:
- path: /root/requirements.sh
origin: requirements.sh
- path: /root/openshift.sh
origin: openshift.sh
- path: /root/kubevirt.sh
origin: kubevirt.sh
[% if cdi %]
- path: /root/cdi.sh
origin: cdi.sh
[% endif %]
[% if deploy %]
scripts:
- deploy.sh
[% endif %]
[% endfor %]
sed -i "s@OPTIONS=.*@OPTIONS='--selinux-enabled --insecure-registry 172.30.0.0/16'@" /etc/sysconfig/docker
systemctl start docker --ignore-dependencies
#export IP=`ip a l eth0 | grep 'inet ' | cut -d' ' -f6 | awk -F'/' '{ print $1}'`
export IP=`curl http://metadata/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/external-ip -H "Metadata-Flavor: Google"`
oc cluster up --public-hostname $IP.xip.io --routing-suffix $IP.xip.io --enable=service-catalog,router,registry,web-console,persistent-volumes,rhel-imagestreams,automation-service-broker
oc login -u system:admin
docker update --restart=always origin
oc adm policy add-cluster-role-to-user cluster-admin developer
[%- set releaseurls = {
'3.9' : 'v3.9.0/openshift-origin-client-tools-v3.9.0-191fece',
'3.10' : 'v3.10.0-rc.0/openshift-origin-client-tools-v3.10.0-rc.0-c20e215',
}
-%]
yum -y install wget docker git
systemctl enable docker
sed -i "s@# INSECURE_REGISTRY=.*@INSECURE_REGISTRY='--insecure-registry 172.30.0.0/16'@" /etc/sysconfig/docker
wget -O /root/oc.tar.gz https://github.com/openshift/origin/releases/download/[[ releaseurls[openshift_version] ]]-linux-64bit.tar.gz
cd /root ; tar zxvf oc.tar.gz
mv /root/openshift-origin-client-tools-*/oc /usr/bin
rm -rf /root/openshift-origin-client-tools-*
curl -L https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl -o /usr/bin/kubectl
chmod +x /usr/bin/kubectl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment