Skip to content

Commit fe9f31e

Browse files
committed
updating customize section
1 parent cd858c7 commit fe9f31e

File tree

1 file changed

+58
-75
lines changed

1 file changed

+58
-75
lines changed

content/patterns/ansible-edge-gitops/ideas-for-customization.adoc

Lines changed: 58 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,43 @@ One of the major goals of the Red Hat patterns development process is to create
1515

1616
This demo in particular can be customized in a several ways that might be very interesting and here are some starter ideas with some instructions on exactly what and where changes would need to be made in the pattern to accommodate those changes.
1717

18-
== Define your own VM sets using the chart
18+
== Defining your own VM sets using the chart
1919

20-
. Fork the repo or copy the `edge-gitops-vms`` chart out of it.
20+
. Fork the link:https://github.com/validatedpatterns/ansible-edge-gitops[repo].
2121

22-
. Customize the https://github.com/validatedpatterns/ansible-edge-gitops/blob/main/charts/hub/edge-gitops-vms/values.yaml[values.yaml] file
22+
. Clone the repo to your local machine.
2323

24-
The `vms` data structure is designed to support multiple groups and types of VMs. The `kiosk` example defines all of the variables currently supported by the chart, including references to the Vault instance and port definitions. If, for example, you wanted to replace kiosk with new `iotsensor`` and `iotgateway` types, the file might look like this:
24+
. Change to the `ansible-edge-gitops` directory.
2525

26+
. Create and switch to a new branch named `my-branch`, by running the following command:
27+
+
28+
[source,shell]
29+
----
30+
$ git checkout -b my-branch
31+
----
32+
33+
. Change to the `overides` directory.
34+
+
35+
For example, to replace kiosk with new `iotsensor`` and `iotgateway` types, the file might look like this:
36+
+
2637
[source,yaml]
2738
----
2839
---
29-
secretStore:
30-
name: vault-backend
31-
kind: ClusterSecretStore
32-
33-
cloudInit:
34-
defaultUser: 'cloud-user'
35-
defaultPassword: '6toh-n1d5-9xpq'
36-
3740
vms:
41+
# Define the iotsensor VMs
3842
iotsensor:
3943
count: 4
4044
flavor: small
4145
workload: server
4246
os: rhel8
43-
role: iotgateway
47+
role: iotsensor
4448
storage: 20Gi
4549
memory: 2Gi
4650
cores: 1
4751
sockets: 1
4852
threads: 1
4953
cloudInitUser: cloud-user
50-
cloudInitPassword: 6toh-n1d5-9xpq
54+
cloudInitPassword: 'password123'
5155
template: rhel8-server-small
5256
sshsecret: secret/data/hub/iotsensor-ssh
5357
sshpubkeyfield: publickey
@@ -56,6 +60,8 @@ vms:
5660
port: 22
5761
protocol: TCP
5862
targetPort: 22
63+
64+
# Define the iotgateway VMs
5965
iotgateway:
6066
count: 1
6167
flavor: medium
@@ -68,7 +74,7 @@ vms:
6874
sockets: 1
6975
threads: 1
7076
cloudInitUser: cloud-user
71-
cloudInitPassword: 6toh-n1d5-9xpq
77+
cloudInitPassword: 'password123'
7278
template: rhel8-server-medium
7379
sshsecret: secret/data/hub/iotgateway-ssh
7480
sshpubkeyfield: publickey
@@ -85,29 +91,34 @@ vms:
8591

8692
This would create 1 `iotgateway` VM and 4 `iotsensor` VMs.
8793

88-
Adjustments would also need to be made in https://github.com/validatedpatterns/ansible-edge-gitops/blob/main/values-secret.yaml.template[values-secret] and https://github.com/validatedpatterns/ansible-edge-gitops/blob/main/scripts/ansible_load_controller.sh[ansible-load-controller] to add the `iotgateway-ssh` and `iotsensor-ssh` data structures.
94+
You also need to to define the SSH secrets (`iotgateway-ssh` and `iotsensor-ssh`) data structures in `~/values-secret.yaml`.
8995

9096
== Defining your own VM sets "`from scratch`"
9197

92-
. Pick a default template from the standard OpenShift Virtualization
93-
template library in the `+openshift+` namespace. For this pattern, we
94-
used `+rhel8-desktop-medium+`:
98+
. Pick a default template from the standard OpenShift Virtualization template library in the `openshift` namespace. For this pattern, we used `rhel8-desktop-medium`:
9599
+
96100
[source,text]
97101
----
98102
$ oc get template -n openshift rhel8-desktop-medium
103+
----
104+
+
105+
.Example output
106+
[source,text]
107+
----
99108
NAME DESCRIPTION PARAMETERS OBJECTS
100109
rhel8-desktop-medium Template for Red Hat Enterprise Linux 8 VM or newer. A PVC with the RHEL disk... 4 (2 generated) 1
101110
----
102111

103-
. Create a VM through the command line template process, and see what objects OpenShift Virtualization creates to bring
104-
that VM up:
112+
. Create a VM through the command line template process by running the following command:
105113
+
106-
To see the actual JSON that the template converts into:
114+
[source,shell]
115+
----
116+
oc process -n openshift rhel8-desktop-medium | oc apply -f -
117+
----
107118
+
119+
.Example output
108120
[source,text]
109121
----
110-
$ oc process -n openshift rhel8-desktop-medium
111122
{
112123
"kind": "List",
113124
"apiVersion": "v1",
@@ -118,23 +129,23 @@ $ oc process -n openshift rhel8-desktop-medium
118129
"kind": "VirtualMachine",
119130
"metadata": {
120131
"annotations": {
121-
"vm.kubevirt.io/validations": "[\n {\n \"name\": \"minimal-required-memory\",\n \"path\": \"jsonpath::.spec.domain.resources.requests.memory\",\n \"rule\": \"integer\",\n \"message\": \"This VM requires more memory.\",\n \"min\": 1610612736\n }\n]\n"
132+
"vm.kubevirt.io/validations": "[\n {\n \"name\": \"minimal-required-memory\",\n \"path\": \"jsonpath::.spec.domain.memory.guest\",\n \"rule\": \"integer\",\n \"message\": \"This VM requires more memory.\",\n \"min\": 1610612736\n }\n]\n"
122133
},
123134
"labels": {
124-
"app": "rhel8-yywa22lijw8hl017",
135+
"app": "rhel8-y43iixn7issko1lu",
125136
"vm.kubevirt.io/template": "rhel8-desktop-medium",
126137
"vm.kubevirt.io/template.revision": "1",
127-
"vm.kubevirt.io/template.version": "v0.19.5"
138+
"vm.kubevirt.io/template.version": "v0.31.1"
128139
},
129-
"name": "rhel8-yywa22lijw8hl017"
140+
"name": "rhel8-y43iixn7issko1lu"
130141
},
131142
"spec": {
132143
"dataVolumeTemplates": [
133144
{
134145
"apiVersion": "cdi.kubevirt.io/v1beta1",
135146
"kind": "DataVolume",
136147
"metadata": {
137-
"name": "rhel8-yywa22lijw8hl017"
148+
"name": "rhel8-y43iixn7issko1lu"
138149
},
139150
"spec": {
140151
"sourceRef": {
@@ -161,11 +172,12 @@ $ oc process -n openshift rhel8-desktop-medium
161172
"vm.kubevirt.io/workload": "desktop"
162173
},
163174
"labels": {
164-
"kubevirt.io/domain": "rhel8-yywa22lijw8hl017",
175+
"kubevirt.io/domain": "rhel8-y43iixn7issko1lu",
165176
"kubevirt.io/size": "medium"
166177
}
167178
},
168179
"spec": {
180+
"architecture": "amd64",
169181
"domain": {
170182
"cpu": {
171183
"cores": 1,
@@ -178,7 +190,7 @@ $ oc process -n openshift rhel8-desktop-medium
178190
"disk": {
179191
"bus": "virtio"
180192
},
181-
"name": "rhel8-yywa22lijw8hl017"
193+
"name": "rootdisk"
182194
},
183195
{
184196
"disk": {
@@ -197,22 +209,16 @@ $ oc process -n openshift rhel8-desktop-medium
197209
"interfaces": [
198210
{
199211
"masquerade": {},
212+
"model": "virtio",
200213
"name": "default"
201214
}
202215
],
203-
"networkInterfaceMultiqueue": true,
204216
"rng": {}
205217
},
206-
"machine": {
207-
"type": "pc-q35-rhel8.4.0"
208-
},
209-
"resources": {
210-
"requests": {
211-
"memory": "4Gi"
212-
}
218+
"memory": {
219+
"guest": "4Gi"
213220
}
214221
},
215-
"evictionStrategy": "LiveMigrate",
216222
"networks": [
217223
{
218224
"name": "default",
@@ -223,13 +229,13 @@ $ oc process -n openshift rhel8-desktop-medium
223229
"volumes": [
224230
{
225231
"dataVolume": {
226-
"name": "rhel8-yywa22lijw8hl017"
232+
"name": "rhel8-y43iixn7issko1lu"
227233
},
228-
"name": "rhel8-yywa22lijw8hl017"
234+
"name": "rootdisk"
229235
},
230236
{
231237
"cloudInitNoCloud": {
232-
"userData": "#cloud-config\nuser: cloud-user\npassword: nnpa-12td-e0r7\nchpasswd: { expire: False }"
238+
"userData": "#cloud-config\nuser: cloud-user\npassword: 1pna-7owu-mrna\nchpasswd: { expire: False }"
233239
},
234240
"name": "cloudinitdisk"
235241
}
@@ -246,45 +252,22 @@ $ oc process -n openshift rhel8-desktop-medium
246252
+
247253
[source,shell]
248254
----
249-
oc process -n openshift rhel8-desktop-medium | oc apply -f -
255+
$ oc process -n openshift rhel8-desktop-medium | oc apply -f -
256+
----
257+
+
258+
.Example output
259+
[source,text]
260+
----
250261
virtualmachine.kubevirt.io/rhel8-q63yuvxpjdvy18l7 created
251262
----
252-
263+
+
253264
In just a few minutes, you will have a blank rhel8 VM running, which you can then login to by using the console and customize.
254265

255266
. Get the details of this template as a local YAML file:
256267
+
257268
[source,shell]
258269
----
259-
oc get template -n openshift rhel8-desktop-medium -o yaml > my-template.yaml
270+
$ oc get template -n openshift rhel8-desktop-medium -o yaml > my-template.yaml
260271
----
261-
262-
Once you have this local template, you can view the elements you want to customize, possibly using
263-
https://github.com/validatedpatterns/ansible-edge-gitops/blob/main/charts/hub/edge-gitops-vms/templates/virtual-machines.yaml[this]
264-
as an example.
265-
266-
== Defining your own Ansible Controller Configuration
267-
268-
The https://github.com/validatedpatterns/ansible-edge-gitops/blob/main/scripts/ansible_load_controller.sh[ansible_load_controller.sh]
269-
is designed to be relatively easy to customize with a new controller configuration. Structurally, it is principally based on
270-
https://github.com/redhat-cop/controller_configuration/blob/devel/playbooks/configure_controller.yml[configure_controller.yml]
271-
from the Red Hat Community of Practice https://github.com/redhat-cop/controller_configuration[controller_configuration]
272-
collection. The order and specific list of roles invoked is taken from there.
273-
274-
To customize it, the main thing would be to replace the different variables in the role tasks with the your own. The script includes the
275-
roles for variable types that this pattern does not manage in order to make that part straightforward. Feel free to add your own roles and
276-
playbooks (and add them to the controller configuration script).
277-
278-
The reason this pattern ships with a script as it does instead of invoking the referenced playbook directly is that several of the
279-
configuration elements depend on each other, and there was not a super-convenient place to put things like the controller credentials as
280-
the playbook suggests.
281-
282-
== Substitute your own container application (instead of ignition)
283-
284-
285-
. Adjust the query in the https://github.com/validatedpatterns/ansible-edge-gitops/blob/main/ansible/inventory_preplay.yml[inventory_preplay.yml]
286-
either by overriding the vars for the play, or forking the repo and replacing the vars with your own query terms. (That is, use your own
287-
label(s) and namespace to discover the services you want to connect to.
288-
289-
. Adjust or override the vars in the https://github.com/validatedpatterns/ansible-edge-gitops/blob/main/ansible/provision_kiosk.yml[provision_kiosk.yml]
290-
playbook to suitable values for your own container application. The roles it calls are fairly generic, so changing the vars is all you should need to do.
272+
+
273+
Once you have this local template, you can view the elements you want to customize.

0 commit comments

Comments
 (0)