Free RedHat EX316 Practice Test & Real Exam Questions
How do you verify on which node a VM is running before and after migration?
Correct Answer:
See the Explanation.
Explanation:
1. Run:
oc get vmi <vm-name> -o wide
2. Note NODE field before migration.
3. After running virtctl migrate <vm>, check again.
4. Ensure node name is different post-migration.
5. Confirms that migration occurred.
Explanation:
1. Run:
oc get vmi <vm-name> -o wide
2. Note NODE field before migration.
3. After running virtctl migrate <vm>, check again.
4. Ensure node name is different post-migration.
5. Confirms that migration occurred.
How do you enforce which nodes support external bridge networking?
Correct Answer:
See the Explanation.
Explanation:
1. Label specific nodes:
oc label node worker-0 external-bridge=true
2. Define nodeSelector in your VM:
spec:
template:
spec:
nodeSelector:
external-bridge: "true"
3. Apply and confirm pod is scheduled on that node.
4. Ensure br-ext exists on that node only.
5. Prevent scheduling to misconfigured nodes.
Explanation:
1. Label specific nodes:
oc label node worker-0 external-bridge=true
2. Define nodeSelector in your VM:
spec:
template:
spec:
nodeSelector:
external-bridge: "true"
3. Apply and confirm pod is scheduled on that node.
4. Ensure br-ext exists on that node only.
5. Prevent scheduling to misconfigured nodes.
How do you list all available virtual machine templates in the cluster?
Correct Answer:
See the Explanation.
Explanation:
1. Run: oc get templates -n openshift
2. Filter only VM templates:
oc get templates -n openshift -l template.kubevirt.io/type=base
3. View details: oc describe template <name> -n openshift
4. Check parameters and objects section.
5. Use templates to create new VMs.
Explanation:
1. Run: oc get templates -n openshift
2. Filter only VM templates:
oc get templates -n openshift -l template.kubevirt.io/type=base
3. View details: oc describe template <name> -n openshift
4. Check parameters and objects section.
5. Use templates to create new VMs.
How do you configure DNS for the imported VM for internal service discovery?
Correct Answer:
See the Explanation.
Explanation:
1. Expose the VM using a ClusterIP service.
2. Kubernetes DNS will resolve:
<svc-name>.<namespace>.svc.cluster.local
3. Inside cluster, ping <svc-name>
4. Confirm via /etc/resolv.conf
5. Ensure hostname resolution works.
Explanation:
1. Expose the VM using a ClusterIP service.
2. Kubernetes DNS will resolve:
<svc-name>.<namespace>.svc.cluster.local
3. Inside cluster, ping <svc-name>
4. Confirm via /etc/resolv.conf
5. Ensure hostname resolution works.
How do you ensure a VM only talks to other VMs in the same namespace?
Correct Answer:
See the Explanation.
Explanation:
1. Create a default deny policy (see Q7).
2. Add allow policy with podSelector on namespace:
from:
- namespaceSelector:
matchLab
els:
name:
default
3. Label namespace: oc label ns default name=default
4. Apply both policies.
Explanation:
1. Create a default deny policy (see Q7).
2. Add allow policy with podSelector on namespace:
from:
- namespaceSelector:
matchLab
els:
name:
default
3. Label namespace: oc label ns default name=default
4. Apply both policies.
How do you enable cloud-init in an imported VM for post-deploy config?
Correct Answer:
See the Explanation.
Explanation:
1. Add cloudInitNoCloud to VM definition.
2. Example:
userData: | #cloud-
config hostname:
imported-vm users:
- name: user ssh-
authorized-keys:
- <SSH-PUB-KEY>
3. Ensure base image has cloud-init installed.
4. Restart the VM.
5. Validate config inside the VM.
Explanation:
1. Add cloudInitNoCloud to VM definition.
2. Example:
userData: | #cloud-
config hostname:
imported-vm users:
- name: user ssh-
authorized-keys:
- <SSH-PUB-KEY>
3. Ensure base image has cloud-init installed.
4. Restart the VM.
5. Validate config inside the VM.
How do you automatically create a ClusterIP service with a VM using templates?
Correct Answer:
See the Explanation.
Explanation:
1. Use a VM template that includes a label (e.g., app: my-vm)
2. Create a Service YAML that selects that label.
3. Deploy from template and then deploy the service.
4. Both connect seamlessly.
5. Test with curl or ssh.
Explanation:
1. Use a VM template that includes a label (e.g., app: my-vm)
2. Create a Service YAML that selects that label.
3. Deploy from template and then deploy the service.
4. Both connect seamlessly.
5. Test with curl or ssh.
How do you check which nodes are running Virtual Machine Instances (VMIs)?
Correct Answer:
See the Explanation.
Explanation:
1. Run:
oc get vmi -A -o wide
2. Check the NODE column for each VMI.
3. Identify which nodes host running VMs.
4. Use this information before starting maintenance.
5. Migrate or shut down VMs accordingly.
Explanation:
1. Run:
oc get vmi -A -o wide
2. Check the NODE column for each VMI.
3. Identify which nodes host running VMs.
4. Use this information before starting maintenance.
5. Migrate or shut down VMs accordingly.
How do you live attach a disk to a running VM (if hotplug is enabled)?
Correct Answer:
See the Explanation.
Explanation:
1. Create PVC for the disk.
2. Use:
virtctl addvolume <vm-name> --volume-name hotplug-disk --persist
3. Monitor attachment: oc describe vmi <vm-name>
4. Access inside VM: lsblk, dmesg
5. Detach with virtctl removevolume.
Explanation:
1. Create PVC for the disk.
2. Use:
virtctl addvolume <vm-name> --volume-name hotplug-disk --persist
3. Monitor attachment: oc describe vmi <vm-name>
4. Access inside VM: lsblk, dmesg
5. Detach with virtctl removevolume.
How do you use tolerations to allow VMs on tainted nodes?
Correct Answer:
See the Explanation.
Explanation:
1. Taint a node:
oc adm taint nodes worker-2 dedicated=vm:NoSchedule
2. Add to VM YAML:
template:
spec:
tolerations:
- key: dedicated
value: vm
effect: NoSchedule
3. VM will now schedule on tainted node.
4. Used for isolating workloads.
5. Confirm with: oc describe node worker-2
Explanation:
1. Taint a node:
oc adm taint nodes worker-2 dedicated=vm:NoSchedule
2. Add to VM YAML:
template:
spec:
tolerations:
- key: dedicated
value: vm
effect: NoSchedule
3. VM will now schedule on tainted node.
4. Used for isolating workloads.
5. Confirm with: oc describe node worker-2
How do you configure a liveness probe to restart a VM if it becomes unresponsive?
Correct Answer:
See the Explanation.
Explanation:
1. Add to VM YAML:
spec:
template:
spec:
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 30
periodSeconds: 10
2. Ensure the VM exposes /health endpoint on port 8080.
3. Apply and restart the VM.
4. If the probe fails continuously, VM will be restarted.
5. Check with oc describe vmi.
Explanation:
1. Add to VM YAML:
spec:
template:
spec:
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 30
periodSeconds: 10
2. Ensure the VM exposes /health endpoint on port 8080.
3. Apply and restart the VM.
4. If the probe fails continuously, VM will be restarted.
5. Check with oc describe vmi.
How do you verify that KubeVirt components are installed after operator deployment?
Correct Answer:
See the Explanation.
Explanation:
1. Check pods: oc get pods -n openshift-cnv | grep virt
2. Verify deployments: oc get deployments -n openshift-cnv
3. Confirm API services: oc get apiservices | grep kubevirt.io
4. Run: oc get crds | grep kubevirt
5. Check the custom resource: oc get kubevirt -n openshift-cnv
Explanation:
1. Check pods: oc get pods -n openshift-cnv | grep virt
2. Verify deployments: oc get deployments -n openshift-cnv
3. Confirm API services: oc get apiservices | grep kubevirt.io
4. Run: oc get crds | grep kubevirt
5. Check the custom resource: oc get kubevirt -n openshift-cnv
How do you connect a virtual machine to an iSCSI external storage volume using Multus?
Correct Answer:
See the Explanation.
Explanation:
1. Create a Multus NAD that connects to storage VLAN/network.
2. Attach this to the VM's spec as a second interface.
3. Inside VM:
o Install iSCSI initiator: yum install iscsi-initiator-utils
o Discover target: iscsiadm -m discovery -t sendtargets -p <target-ip>
o Login: iscsiadm -m node -T <target-name> -p <target-ip> --login
4. Confirm disk with lsblk.
Explanation:
1. Create a Multus NAD that connects to storage VLAN/network.
2. Attach this to the VM's spec as a second interface.
3. Inside VM:
o Install iSCSI initiator: yum install iscsi-initiator-utils
o Discover target: iscsiadm -m discovery -t sendtargets -p <target-ip>
o Login: iscsiadm -m node -T <target-name> -p <target-ip> --login
4. Confirm disk with lsblk.
How do you create a LoadBalancer service to expose a VM (if your cloud provider supports it)?
Correct Answer:
See the Explanation.
Explanation:
1. Create YAML:
apiVersion: v1
kind: Service
metadata:
name: vm-lb
spec:
type: LoadBalancer
selector:
kubevirt.io/domain: vm1
ports:
- protocol: TCP
port: 22
targetPort: 22
2. Apply with oc apply -f service.yaml
3. Wait for external IP: oc get svc vm-lb
4. Test connection to the LoadBalancer IP.
Explanation:
1. Create YAML:
apiVersion: v1
kind: Service
metadata:
name: vm-lb
spec:
type: LoadBalancer
selector:
kubevirt.io/domain: vm1
ports:
- protocol: TCP
port: 22
targetPort: 22
2. Apply with oc apply -f service.yaml
3. Wait for external IP: oc get svc vm-lb
4. Test connection to the LoadBalancer IP.
