Skip to content

Instantly share code, notes, and snippets.

@pojntfx
Last active March 12, 2020 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pojntfx/e252c901efa1616b60f1fa00c69f69a1 to your computer and use it in GitHub Desktop.
Save pojntfx/e252c901efa1616b60f1fa00c69f69a1 to your computer and use it in GitHub Desktop.
Example KubeVirt Machine based on Ubuntu 18.04 with custom SSH key
  • Install it with: https://gist.githubusercontent.com/pojntfx/e252c901efa1616b60f1fa00c69f69a1/raw/main.yaml
  • SSH into it with: ssh root@116.203.88.162 -p 30000 (replace 116.203.88.162 with any of the node's IP)
  • You can also set up an ingress to the service below if you want to!
---
apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachine
metadata:
name: test-vmi
labels:
special: key
spec:
running: true
template:
metadata:
labels:
special: key
spec:
domain:
devices:
disks:
- disk:
bus: virtio
name: containerdisk
- disk:
bus: virtio
name: cloudinitdisk
machine:
type: ""
resources:
requests:
memory: 1024M
terminationGracePeriodSeconds: 0
volumes:
- containerDisk:
image: tedezed/ubuntu-container-disk:latest
name: containerdisk
- cloudInitNoCloud:
userData: |
#!/bin/sh
echo 'Add authorized SSH keys'
mkdir -p /root/.ssh
echo 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9VXy86B5iB8uszD9i5vYoRhaRYpzBI0h6hHIBt/sR6pkv9iPZc1mIhI5OQHF9rhNdWMklrx1TJ6swAOOTkxdxGBe9Ji5Sa6w/g+U715XFLhx2YfyAa2RdAPHltmNcNsPlHUWjbUAAI6nPmtDILiE0urbgUQ+BsAoLo2+5f5TFzJEmmlfdaVwYP2+jwX/fqC/aiz3oxnovHibb+S2eC9Ff7qVZjvpYrHfocTpHnPtF9Hyvg1+Jy083p5/aswb9O3dORjk4JijckYTmcSjnEbaB3VnR93XaZM7yh/2CKms7BxncLpKCZU2//a6n7Uc9qjX3Rm6BnfL0aYwVSTBLzrlH pojntfx@thinkpadx1c3.pojtinger.space' > /root/.ssh/authorized_keys
name: cloudinitdisk
---
apiVersion: v1
kind: Service
metadata:
name: test-vmi
spec:
externalTrafficPolicy: Cluster
ports:
- name: nodeport
nodePort: 30000
port: 27017
protocol: TCP
targetPort: 22
selector:
special: key
type: NodePort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment