Other helpful Links:
https://kubevirt.io/user-guide/operations/virtctl_client_tool/
https://kubevirt.io/user-guide/virtual_machines/service_objects/
https://www.opensourcerers.org/2020/11/30/first-steps-with-openshift-virtualization/
NOTE: Depending on access needed, use EITHER ClusterIP or NodePort, not BOTH as NodePort will allow for internal AND external communication; whereas ClusterIP in internal only.
Intra-Cluster (ClusterIP) Service:
apiVersion: v1
kind: Service
metadata:
name: svc-postgres-clusterip
namespace: percap
spec:
ports:
- protocol: TCP
port: 5432
targetPort: 5432
selector:
internalService: svc-postgres-clusterip
type: ClusterIP
Extra-Cluster (NodePort, must be higher than 30000) Service:
apiVersion: v1
kind: Service
metadata:
name: svc-postgres-nodeport
namespace: percap
spec:
ports:
- protocol: TCP
port: 5432
targetPort: 5432
nodePort: 30000
selector:
externalService: svc-postgres-nodeport
type: NodePort
VM Customizations (VM MUST be fully powered off, not just rebooted, if already powered on to make services work, notice ports/port):
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: postgres
namespace: percap
spec:
running: false
template:
metadata:
labels:
internalService: svc-postgres-clusterip
domain:
devices:
interfaces:
- macAddress: '00:50:56:81:35:dd'
masquerade: {}
model: virtio
name: net-0
ports:
- port: 5432
networks:
- name: net-0
pod: {}
External connections can be made to the VM using the below (No Route is required):
Any externally facing cluster IP (Master or Worker node IPs)
API and Ingress IPs (In this case I am using 172.16.1.150, the API IP, or could use the FQDN)