Skip to content

Commit 49c75b2

Browse files
authored
Merge pull request #35153 from sjhala-ccs/cnv-8578
CNV-8578: Documenting CNV integration with Service Mesh
2 parents 960b724 + 7eb03c2 commit 49c75b2

File tree

3 files changed

+121
-0
lines changed

3 files changed

+121
-0
lines changed

_topic_map.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2858,6 +2858,8 @@ Topics:
28582858
File: virt-configuring-sriov-device-for-vms
28592859
- Name: Configuring certificate rotation
28602860
File: virt-configuring-certificate-rotation
2861+
- Name: Connecting virtual machines to a service mesh
2862+
File: virt-connecting-vm-to-service-mesh
28612863
- Name: Defining an SR-IOV network
28622864
File: virt-defining-an-sriov-network
28632865
- Name: Attaching a virtual machine to an SR-IOV network
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * virt/virtual_machines/vm_networking/virt-connecting-vm-to-service-mesh.adoc
4+
5+
[id="virt-adding-vm-to-service-mesh_{context}"]
6+
= Configuring a virtual machine for the service mesh
7+
8+
To add a virtual machine (VM) workload to a service mesh, enable automatic sidecar injection in the VM configuration file by setting the `sidecar.istio.io/inject` annotation to `true`. Then expose your VM as a service to view your application in the mesh.
9+
10+
11+
.Procedure
12+
13+
. Edit the VM configuration file to add the `sidecar.istio.io/inject: "true"` annotation.
14+
+
15+
.Example configuration file
16+
[source,yaml]
17+
----
18+
apiVersion: kubevirt.io/v1
19+
kind: VirtualMachine
20+
metadata:
21+
labels:
22+
kubevirt.io/vm: vm-istio
23+
name: vm-istio
24+
spec:
25+
runStrategy: Always
26+
template:
27+
metadata:
28+
labels:
29+
kubevirt.io/vm: vm-istio
30+
app: vm-istio <1>
31+
annotations:
32+
sidecar.istio.io/inject: "true" <2>
33+
spec:
34+
domain:
35+
devices:
36+
interfaces:
37+
- name: default
38+
masquerade: {} <3>
39+
disks:
40+
- disk:
41+
bus: virtio
42+
name: containerdisk
43+
- disk:
44+
bus: virtio
45+
name: cloudinitdisk
46+
resources:
47+
requests:
48+
memory: 1024M
49+
networks:
50+
- name: default
51+
pod: {}
52+
terminationGracePeriodSeconds: 0
53+
volumes:
54+
- containerDisk:
55+
image: registry:5000/kubevirt/fedora-cloud-container-disk-demo:devel
56+
name: containerdisk
57+
----
58+
<1> The key/value pair (label) that must be matched to the service selector attribute.
59+
<2> The annotation to enable automatic sidecar injection.
60+
<3> The binding method (masquerade mode) for use with the default pod network.
61+
+
62+
[NOTE]
63+
====
64+
To avoid port conflicts with sidecars, do not use ports used by Istio proxy for user workloads.
65+
====
66+
67+
. Apply the VM configuration:
68+
+
69+
[source,terminal]
70+
----
71+
$ oc apply -f <vm_name>.yaml <1>
72+
----
73+
<1> The name of the virtual machine YAML file.
74+
75+
76+
. Create a `Service` object to expose your VM to the service mesh.
77+
+
78+
[source,yaml]
79+
----
80+
apiVersion: v1
81+
kind: Service
82+
metadata:
83+
name: vm-istio
84+
spec:
85+
selector:
86+
app: vm-istio <1>
87+
ports:
88+
- port: 8080
89+
name: http
90+
protocol: TCP
91+
----
92+
<1> The service selector that determines the set of pods targeted by a service. This attribute corresponds to the `spec.metadata.labels` field in the VM configuration file. In the above example, the `Service` object named `vm-istio` targets TCP port 8080 on any pod with the label `app=vm-istio`.
93+
94+
. Create the service:
95+
+
96+
[source,terminal]
97+
----
98+
$ oc create -f <service_name>.yaml <1>
99+
----
100+
<1> The name of the service YAML file.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[id="virt-connecting-vm-to-service-mesh"]
2+
= Connecting virtual machines to a service mesh
3+
include::modules/virt-document-attributes.adoc[]
4+
:context: virt-connecting-vm-to-service-mesh
5+
6+
toc::[]
7+
8+
{VirtProductName} is now integrated with OpenShift Service Mesh. You can monitor, visualize, and control traffic between pods that run virtual machine workloads on the default pod network with IPv4.
9+
10+
== Prerequisites
11+
12+
* You must have xref:../../../service_mesh/v2x/installing-ossm.adoc#installing-ossm[installed the Service Mesh Operator] and xref:../../../service_mesh/v2x/ossm-create-smcp.adoc#ossm-create-smcp[deployed the service mesh control plane].
13+
14+
* You must have added the namespace where the virtual machine is created to the xref:../../../service_mesh/v2x/ossm-create-mesh.adoc#ossm-create-mesh[service mesh member roll].
15+
16+
* You must use the `masquerade` binding method for the default pod network.
17+
18+
19+
include::modules/virt-adding-vm-to-service-mesh.adoc[leveloffset=+1]

0 commit comments

Comments
 (0)