summaryrefslogtreecommitdiff
path: root/gemfeed/DRAFT-f3s-kubernetes-with-freebsd-part-X.html
blob: b4e9758cbde308c4b5ce733541dfa4c6386fbfcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>f3s: Kubernetes with FreeBSD - Part X: GitOps with ArgoCD</title>
<link rel="shortcut icon" type="image/gif" href="/favicon.ico" />
<link rel="stylesheet" href="../style.css" />
<link rel="stylesheet" href="style-override.css" />
</head>
<body class="rfx-boot">
<div class="rfx-overlay-grid"></div>
<div class="rfx-overlay-scanlines"></div>
<div id="rfx-stars"></div>
<div class="rfx-vignette"></div>
<p class="header">
<a href="https://foo.zone">Home</a> | <a href="https://codeberg.org/snonux/foo.zone/src/branch/content-md/gemfeed/DRAFT-f3s-kubernetes-with-freebsd-part-X.md">Markdown</a> | <a href="gemini://foo.zone/gemfeed/DRAFT-f3s-kubernetes-with-freebsd-part-X.gmi">Gemini</a>
</p>
<h1 style='display: inline' id='f3s-kubernetes-with-freebsd---part-x-gitops-with-argocd'>f3s: Kubernetes with FreeBSD - Part X: GitOps with ArgoCD</h1><br />
<br />
<span class='quote'>DRAFT - Not yet published</span><br />
<br />
<span>This is part X of the f3s series for my self-hosting demands in a home lab. f3s? The "f" stands for FreeBSD, and the "3s" stands for k3s, the Kubernetes distribution I use on FreeBSD-based physical machines.</span><br />
<br />
<a class='textlink' href='./2024-11-17-f3s-kubernetes-with-freebsd-part-1.html'>2024-11-17 f3s: Kubernetes with FreeBSD - Part 1: Setting the stage</a><br />
<a class='textlink' href='./2024-12-03-f3s-kubernetes-with-freebsd-part-2.html'>2024-12-03 f3s: Kubernetes with FreeBSD - Part 2: Hardware and base installation</a><br />
<a class='textlink' href='./2025-02-01-f3s-kubernetes-with-freebsd-part-3.html'>2025-02-01 f3s: Kubernetes with FreeBSD - Part 3: Protecting from power cuts</a><br />
<a class='textlink' href='./2025-04-05-f3s-kubernetes-with-freebsd-part-4.html'>2025-04-05 f3s: Kubernetes with FreeBSD - Part 4: Rocky Linux Bhyve VMs</a><br />
<a class='textlink' href='./2025-05-11-f3s-kubernetes-with-freebsd-part-5.html'>2025-05-11 f3s: Kubernetes with FreeBSD - Part 5: WireGuard mesh network</a><br />
<a class='textlink' href='./2025-07-14-f3s-kubernetes-with-freebsd-part-6.html'>2025-07-14 f3s: Kubernetes with FreeBSD - Part 6: Storage</a><br />
<a class='textlink' href='./2025-10-02-f3s-kubernetes-with-freebsd-part-7.html'>2025-10-02 f3s: Kubernetes with FreeBSD - Part 7: k3s and first pod deployments</a><br />
<a class='textlink' href='./2025-12-07-f3s-kubernetes-with-freebsd-part-8.html'>2025-12-07 f3s: Kubernetes with FreeBSD - Part 8: Observability</a><br />
<br />
<a href='./f3s-kubernetes-with-freebsd-part-1/f3slogo.png'><img alt='f3s logo' title='f3s logo' src='./f3s-kubernetes-with-freebsd-part-1/f3slogo.png' /></a><br />
<br />
<h2 style='display: inline' id='table-of-contents'>Table of Contents</h2><br />
<br />
<ul>
<li><a href='#f3s-kubernetes-with-freebsd---part-x-gitops-with-argocd'>f3s: Kubernetes with FreeBSD - Part X: GitOps with ArgoCD</a></li>
<li>⇢ <a href='#introduction'>Introduction</a></li>
<li>⇢ <a href='#what-is-gitops'>What is GitOps?</a></li>
<li>⇢ <a href='#what-is-argocd'>What is ArgoCD?</a></li>
<li>⇢ <a href='#why-argocd-for-f3s'>Why ArgoCD for f3s?</a></li>
<li>⇢ <a href='#deploying-argocd'>Deploying ArgoCD</a></li>
<li>⇢ ⇢ <a href='#prerequisites'>Prerequisites</a></li>
<li>⇢ ⇢ <a href='#installing-argocd'>Installing ArgoCD</a></li>
<li>⇢ ⇢ <a href='#accessing-argocd'>Accessing ArgoCD</a></li>
<li>⇢ <a href='#argocd-application-structure'>ArgoCD Application Structure</a></li>
<li>⇢ <a href='#repository-organization'>Repository Organization</a></li>
<li>⇢ <a href='#migration-strategy-incremental-one-app-at-a-time'>Migration Strategy: Incremental, One App at a Time</a></li>
<li>⇢ ⇢ <a href='#migration-phases'>Migration Phases</a></li>
<li>⇢ <a href='#example-migration-miniflux'>Example Migration: Miniflux</a></li>
<li>⇢ ⇢ <a href='#before-imperative-helm-deployment'>Before: Imperative Helm deployment</a></li>
<li>⇢ ⇢ <a href='#after-declarative-gitops-with-argocd'>After: Declarative GitOps with ArgoCD</a></li>
<li>⇢ ⇢ <a href='#migration-procedure'>Migration procedure</a></li>
<li>⇢ <a href='#complex-migration-prometheus-with-multi-source'>Complex Migration: Prometheus with Multi-Source</a></li>
<li>⇢ ⇢ <a href='#sync-waves-and-hooks'>Sync Waves and Hooks</a></li>
<li>⇢ <a href='#migration-results'>Migration Results</a></li>
<li>⇢ <a href='#benefits-realized'>Benefits Realized</a></li>
<li>⇢ ⇢ <a href='#1-single-source-of-truth'>1. Single Source of Truth</a></li>
<li>⇢ ⇢ <a href='#2-automatic-synchronization'>2. Automatic Synchronization</a></li>
<li>⇢ ⇢ <a href='#3-drift-detection-and-self-healing'>3. Drift Detection and Self-Healing</a></li>
<li>⇢ ⇢ <a href='#4-easy-rollbacks'>4. Easy Rollbacks</a></li>
<li>⇢ ⇢ <a href='#5-disaster-recovery'>5. Disaster Recovery</a></li>
<li>⇢ ⇢ <a href='#6-documentation-by-default'>6. Documentation by Default</a></li>
<li>⇢ ⇢ <a href='#7-safe-experimentation'>7. Safe Experimentation</a></li>
<li>⇢ <a href='#challenges-and-solutions'>Challenges and Solutions</a></li>
<li>⇢ ⇢ <a href='#challenge-1-helm-release-adoption'>Challenge 1: Helm Release Adoption</a></li>
<li>⇢ ⇢ <a href='#challenge-2-persistent-volumes-not-tracked-by-helm'>Challenge 2: Persistent Volumes Not Tracked by Helm</a></li>
<li>⇢ ⇢ <a href='#challenge-3-secrets-management'>Challenge 3: Secrets Management</a></li>
<li>⇢ ⇢ <a href='#challenge-4-grafana-not-reloading-datasources'>Challenge 4: Grafana Not Reloading Datasources</a></li>
<li>⇢ ⇢ <a href='#challenge-5-prometheus-with-multiple-sources'>Challenge 5: Prometheus With Multiple Sources</a></li>
<li>⇢ ⇢ <a href='#challenge-6-sync-ordering-for-prometheus'>Challenge 6: Sync Ordering for Prometheus</a></li>
<li>⇢ <a href='#justfile-evolution'>Justfile Evolution</a></li>
<li>⇢ <a href='#lessons-learned'>Lessons Learned</a></li>
<li>⇢ <a href='#future-improvements'>Future Improvements</a></li>
<li>⇢ ⇢ <a href='#1-external-secrets-operator'>1. External Secrets Operator</a></li>
<li>⇢ ⇢ <a href='#2-applicationset-for-similar-apps'>2. ApplicationSet for Similar Apps</a></li>
<li>⇢ ⇢ <a href='#3-app-of-apps-pattern'>3. App-of-Apps Pattern</a></li>
<li>⇢ ⇢ <a href='#4-argocd-image-updater'>4. ArgoCD Image Updater</a></li>
<li>⇢ <a href='#summary'>Summary</a></li>
</ul><br />
<h2 style='display: inline' id='introduction'>Introduction</h2><br />
<br />
<span>In the previous posts, I deployed applications to the k3s cluster using Helm charts and Justfiles—running <span class='inlinecode'>just install</span> or <span class='inlinecode'>just upgrade</span> to imperatively push changes to the cluster. While this approach works, it has several drawbacks:</span><br />
<br />
<ul>
<li>**No single source of truth**: The cluster state depends on which commands were run and when</li>
<li>**Manual synchronization**: Every change requires manually running commands</li>
<li>**Drift detection is hard**: No easy way to know if cluster state matches the desired configuration</li>
<li>**Rollback complexity**: Rolling back changes means re-running old Helm commands</li>
<li>**No audit trail**: Hard to track who changed what and when</li>
</ul><br />
<span>This blog post covers the migration from imperative Helm deployments to declarative GitOps using ArgoCD. After this migration, the Git repository becomes the single source of truth, and ArgoCD automatically ensures the cluster matches what&#39;s defined in Git.</span><br />
<br />
<h2 style='display: inline' id='what-is-gitops'>What is GitOps?</h2><br />
<br />
<span>GitOps is an operational framework that applies DevOps best practices—like version control, collaboration, and CI/CD—to infrastructure automation. The core idea is simple: the entire desired state of your infrastructure is stored in Git, and automated processes ensure the actual state matches the desired state.</span><br />
<br />
<span>Key principles:</span><br />
<br />
<ul>
<li>**Declarative**: The system&#39;s desired state is described declaratively (YAML manifests, Helm values)</li>
<li>**Versioned and immutable**: All changes are committed to Git, providing a complete history</li>
<li>**Pulled automatically**: An agent in the cluster continuously pulls the desired state from Git</li>
<li>**Continuously reconciled**: The agent ensures the actual state matches the desired state, automatically correcting drift</li>
</ul><br />
<span>For Kubernetes, this means:</span><br />
<br />
<span>1. All manifests, Helm charts, and configuration live in a Git repository</span><br />
<span>2. A tool (ArgoCD in our case) watches the repository</span><br />
<span>3. When changes are pushed to Git, ArgoCD automatically applies them to the cluster</span><br />
<span>4. If someone manually changes resources in the cluster, ArgoCD detects the drift and can automatically revert it</span><br />
<br />
<h2 style='display: inline' id='what-is-argocd'>What is ArgoCD?</h2><br />
<br />
<span>ArgoCD is a declarative, GitOps continuous delivery tool for Kubernetes. It&#39;s implemented as a Kubernetes controller that continuously monitors running applications and compares the current, live state against the desired target state defined in Git.</span><br />
<br />
<a class='textlink' href='https://argo-cd.readthedocs.io'>ArgoCD Documentation</a><br />
<br />
<span>Key features:</span><br />
<br />
<ul>
<li>**Automated deployment**: Monitors Git repositories and automatically syncs changes to the cluster</li>
<li>**Application definitions**: Defines applications as CRDs (Custom Resource Definitions)</li>
<li>**Health assessment**: Understands Kubernetes resources and can determine if an application is healthy</li>
<li>**Web UI and CLI**: Provides both a web interface and command-line tool for managing applications</li>
<li>**RBAC**: Role-based access control for team collaboration</li>
<li>**SSO integration**: Can integrate with existing authentication systems</li>
<li>**Multi-cluster support**: Can manage applications across multiple Kubernetes clusters</li>
<li>**Sync waves and hooks**: Control the order of resource deployment and run jobs at specific lifecycle points</li>
</ul><br />
<h2 style='display: inline' id='why-argocd-for-f3s'>Why ArgoCD for f3s?</h2><br />
<br />
<span>For a home lab cluster, ArgoCD provides several benefits:</span><br />
<br />
<span>**Disaster recovery**: If the entire cluster is lost, I can rebuild it by:</span><br />
<span>1. Bootstrapping a new k3s cluster</span><br />
<span>2. Installing ArgoCD</span><br />
<span>3. Pointing ArgoCD at the Git repository</span><br />
<span>4. All applications automatically deploy to the desired state</span><br />
<br />
<span>**Experimentation safety**: I can test changes in a separate Git branch without affecting the running cluster. Once validated, merge to master and ArgoCD applies the changes.</span><br />
<br />
<span>**Drift detection**: If I manually change something in the cluster (for debugging), ArgoCD shows the difference and can automatically revert it.</span><br />
<br />
<span>**Declarative configuration**: The Git repository documents the entire cluster configuration. No need to remember which <span class='inlinecode'>just</span> commands to run or in which order.</span><br />
<br />
<span>**Automatic sync**: Push to Git, and changes deploy automatically. No need to SSH to a workstation and run Helm commands.</span><br />
<br />
<h2 style='display: inline' id='deploying-argocd'>Deploying ArgoCD</h2><br />
<br />
<span>ArgoCD itself runs as a set of Kubernetes resources in the cluster. The official installation method uses <span class='inlinecode'>kubectl apply</span>, which is fitting—ArgoCD manages everything else via GitOps, but ArgoCD itself needs a bootstrap.</span><br />
<br />
<h3 style='display: inline' id='prerequisites'>Prerequisites</h3><br />
<br />
<span>Create the <span class='inlinecode'>cicd</span> namespace where ArgoCD will run:</span><br />
<br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#ff0000">$ kubectl create namespace cicd</font>
<font color="#ff0000">namespace/cicd created</font>
</pre>
<br />
<h3 style='display: inline' id='installing-argocd'>Installing ArgoCD</h3><br />
<br />
<span>The ArgoCD installation lives in the configuration repository:</span><br />
<br />
<a class='textlink' href='https://codeberg.org/snonux/conf/src/branch/master/f3s/argocd'>codeberg.org/snonux/conf/f3s/argocd</a><br />
<br />
<span>I deployed ArgoCD using Helm instead of the raw manifests. This provides easier upgrades and customization. The installation is managed via a Justfile:</span><br />
<br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#ff0000">$ cd conf/f3s/argocd</font>
<font color="#ff0000">$ just install</font>
<font color="#ff0000">helm repo add argo https</font><font color="#F3E651">:</font><font color="#ff0000">//argoproj</font><font color="#F3E651">.</font><font color="#ff0000">github</font><font color="#F3E651">.</font><font color="#ff0000">io/argo-helm</font>
<font color="#ff0000">helm repo update</font>
<font color="#ff0000">helm install argocd argo/argo-cd </font><font color="#F3E651">\</font>
<font color="#ff0000">    --namespace cicd </font><font color="#F3E651">\</font>
<font color="#ff0000">    --version </font><font color="#bb00ff">7.7</font><font color="#F3E651">.</font><font color="#bb00ff">12</font><font color="#ff0000"> </font><font color="#F3E651">\</font>
<font color="#ff0000">    -f values</font><font color="#F3E651">.</font><font color="#ff0000">yaml</font>
<font color="#ff0000">NAME</font><font color="#F3E651">:</font><font color="#ff0000"> argocd</font>
<font color="#ff0000">LAST DEPLOYED</font><font color="#F3E651">:</font><font color="#ff0000"> </font><font color="#F3E651">...</font>
<font color="#ff0000">NAMESPACE</font><font color="#F3E651">:</font><font color="#ff0000"> cicd</font>
<font color="#ff0000">STATUS</font><font color="#F3E651">:</font><font color="#ff0000"> deployed</font>
</pre>
<br />
<span>The <span class='inlinecode'>values.yaml</span> file configures several important aspects:</span><br />
<br />
<span>**Persistent storage for the repo-server**: ArgoCD clones Git repositories to cache them locally. I configured a persistent volume so the cache survives pod restarts:</span><br />
<br />
<pre>
repoServer:
  volumes:
    - name: repo-cache
      persistentVolumeClaim:
        claimName: argocd-repo-cache-pvc
  volumeMounts:
    - name: repo-cache
      mountPath: /tmp
</pre>
<br />
<span>**Admin password preservation**: By default, the admin password is auto-generated and stored in a secret. To ensure it persists across Helm upgrades:</span><br />
<br />
<pre>
configs:
  secret:
    createSecret: false
</pre>
<br />
<span>I manually created the secret before installation:</span><br />
<br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#ff0000">$ </font><font color="#ff0000">ARGOCD_ADMIN_PASSWORD</font><font color="#F3E651">=</font><font color="#ff0000">$(</font><font color="#ff0000">pwgen -s </font><font color="#bb00ff">32</font><font color="#ff0000"> </font><font color="#bb00ff">1</font><font color="#F3E651">)</font>
<font color="#ff0000">$ </font><font color="#ff0000">BCRYPT_HASH</font><font color="#F3E651">=</font><font color="#ff0000">$(</font><font color="#ff0000">htpasswd -nbBC </font><font color="#bb00ff">10</font><font color="#ff0000"> </font><font color="#bb00ff">""</font><font color="#ff0000"> </font><font color="#bb00ff">"$ARGOCD_ADMIN_PASSWORD"</font><font color="#ff0000"> </font><font color="#F3E651">|</font><font color="#ff0000"> tr -d </font><font color="#bb00ff">':</font><font color="#ffffff">\n</font><font color="#bb00ff">'</font><font color="#ff0000"> </font><font color="#F3E651">|</font><font color="#ff0000"> sed </font><font color="#bb00ff">'s/$2y/$2a/'</font><font color="#F3E651">)</font>
<font color="#ff0000">$ kubectl create secret generic argocd-secret </font><font color="#F3E651">\</font>
<font color="#ff0000">    --from-literal</font><font color="#F3E651">=</font><font color="#ff0000">admin</font><font color="#F3E651">.</font><font color="#ff0000">password</font><font color="#F3E651">=</font><font color="#bb00ff">"$BCRYPT_HASH"</font><font color="#ff0000"> </font><font color="#F3E651">\</font>
<font color="#ff0000">    -n cicd</font>
<font color="#ff0000">$ echo </font><font color="#bb00ff">"ArgoCD admin password: $ARGOCD_ADMIN_PASSWORD"</font>
</pre>
<br />
<span>**Server configuration**: Enabled insecure mode since TLS is handled by the OpenBSD edge relays:</span><br />
<br />
<pre>
server:
  insecure: true
</pre>
<br />
<h3 style='display: inline' id='accessing-argocd'>Accessing ArgoCD</h3><br />
<br />
<span>After deployment, ArgoCD runs several pods in the <span class='inlinecode'>cicd</span> namespace:</span><br />
<br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#ff0000">$ kubectl get pods -n cicd</font>
<font color="#ff0000">NAME                                                READY   STATUS    RESTARTS   AGE</font>
<font color="#ff0000">argocd-application-controller-</font><font color="#bb00ff">0</font><font color="#ff0000">                     </font><font color="#bb00ff">1</font><font color="#F3E651">/</font><font color="#bb00ff">1</font><font color="#ff0000">     Running   </font><font color="#bb00ff">0</font><font color="#ff0000">          45d</font>
<font color="#ff0000">argocd-applicationset-controller-66d6b9b8f4-vhm9k   </font><font color="#bb00ff">1</font><font color="#F3E651">/</font><font color="#bb00ff">1</font><font color="#ff0000">     Running   </font><font color="#bb00ff">0</font><font color="#ff0000">          45d</font>
<font color="#ff0000">argocd-dex-server-7fb556b7dd-xjr2l                  </font><font color="#bb00ff">1</font><font color="#F3E651">/</font><font color="#bb00ff">1</font><font color="#ff0000">     Running   </font><font color="#bb00ff">0</font><font color="#ff0000">          45d</font>
<font color="#ff0000">argocd-notifications-controller-6d8dd4c5f5-b8vwl    </font><font color="#bb00ff">1</font><font color="#F3E651">/</font><font color="#bb00ff">1</font><font color="#ff0000">     Running   </font><font color="#bb00ff">0</font><font color="#ff0000">          45d</font>
<font color="#ff0000">argocd-redis-77b8d6c6d4-mz9hg                       </font><font color="#bb00ff">1</font><font color="#F3E651">/</font><font color="#bb00ff">1</font><font color="#ff0000">     Running   </font><font color="#bb00ff">0</font><font color="#ff0000">          45d</font>
<font color="#ff0000">argocd-repo-server-5f98f77b97-8xtcq                 </font><font color="#bb00ff">1</font><font color="#F3E651">/</font><font color="#bb00ff">1</font><font color="#ff0000">     Running   </font><font color="#bb00ff">0</font><font color="#ff0000">          45d</font>
<font color="#ff0000">argocd-server-6b9c4b4f8d-kxw7p                      </font><font color="#bb00ff">1</font><font color="#F3E651">/</font><font color="#bb00ff">1</font><font color="#ff0000">     Running   </font><font color="#bb00ff">0</font><font color="#ff0000">          45d</font>
</pre>
<br />
<span>I created an ingress to expose the ArgoCD web UI:</span><br />
<br />
<pre>
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: argocd-server-ingress
  namespace: cicd
  annotations:
    spec.ingressClassName: traefik
    traefik.ingress.kubernetes.io/router.entrypoints: web
spec:
  rules:
    - host: argocd.f3s.buetow.org
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: argocd-server
                port:
                  number: 80
</pre>
<br />
<span>Following the same pattern as other services, the OpenBSD edge relays terminate TLS and forward traffic through WireGuard to the cluster. ArgoCD is now accessible at:</span><br />
<br />
<a class='textlink' href='https://argocd.f3s.buetow.org'>ArgoCD Web UI</a><br />
<br />
<span>The ArgoCD CLI can also be used for operations:</span><br />
<br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#ff0000">$ argocd login argocd</font><font color="#F3E651">.</font><font color="#ff0000">f3s</font><font color="#F3E651">.</font><font color="#ff0000">buetow</font><font color="#F3E651">.</font><font color="#ff0000">org</font>
<font color="#ff0000">$ argocd app list</font>
</pre>
<br />
<h2 style='display: inline' id='argocd-application-structure'>ArgoCD Application Structure</h2><br />
<br />
<span>ArgoCD uses a CRD called <span class='inlinecode'>Application</span> to define what should be deployed. Each application specifies:</span><br />
<br />
<ul>
<li>**Source**: Where the manifests live (Git repo, Helm chart repository, or both)</li>
<li>**Destination**: Which cluster and namespace to deploy to</li>
<li>**Sync policy**: Whether to automatically sync changes</li>
</ul><br />
<span>Here&#39;s a simple example for the miniflux application:</span><br />
<br />
<pre>
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: miniflux
  namespace: cicd
  finalizers:
    - resources-finalizer.argocd.argoproj.io
spec:
  project: default
  source:
    repoURL: https://codeberg.org/snonux/conf.git
    targetRevision: master
    path: f3s/miniflux/helm-chart
  destination:
    server: https://kubernetes.default.svc
    namespace: services
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - CreateNamespace=false
    retry:
      limit: 3
      backoff:
        duration: 5s
        factor: 2
        maxDuration: 1m
</pre>
<br />
<span>Key fields:</span><br />
<br />
<ul>
<li><span class='inlinecode'>source.path</span>: Points to the Helm chart directory in Git</li>
<li><span class='inlinecode'>destination.namespace</span>: Where to deploy the application</li>
<li><span class='inlinecode'>syncPolicy.automated.prune</span>: Delete resources that are removed from Git</li>
<li><span class='inlinecode'>syncPolicy.automated.selfHeal</span>: Automatically revert manual changes in the cluster</li>
<li><span class='inlinecode'>finalizers</span>: Ensures ArgoCD deletes all resources when the Application is deleted</li>
</ul><br />
<h2 style='display: inline' id='repository-organization'>Repository Organization</h2><br />
<br />
<span>I reorganized the configuration repository to support GitOps:</span><br />
<br />
<pre>
/home/paul/git/conf/f3s/
├── argocd-apps/               # ArgoCD Application manifests (organized by namespace)
│   ├── README.md              # Documentation of structure
│   ├── monitoring/            # Observability stack (6 apps)
│   │   ├── alloy.yaml
│   │   ├── grafana-ingress.yaml
│   │   ├── loki.yaml
│   │   ├── prometheus.yaml
│   │   ├── pushgateway.yaml
│   │   └── tempo.yaml
│   ├── services/              # User-facing applications (13 apps)
│   │   ├── anki-sync-server.yaml
│   │   ├── audiobookshelf.yaml
│   │   ├── filebrowser.yaml
│   │   ├── immich.yaml
│   │   ├── keybr.yaml
│   │   ├── kobo-sync-server.yaml
│   │   ├── miniflux.yaml
│   │   ├── opodsync.yaml
│   │   ├── radicale.yaml
│   │   ├── syncthing.yaml
│   │   ├── tracing-demo.yaml
│   │   ├── wallabag.yaml
│   │   └── webdav.yaml
│   ├── infra/                 # Infrastructure services (1 app)
│   │   └── registry.yaml
│   └── test/                  # Test/example applications (1 app)
│       └── example-apache-volume-claim.yaml
├── miniflux/                  # Application directories (unchanged)
│   ├── helm-chart/
│   │   ├── Chart.yaml
│   │   ├── values.yaml
│   │   └── templates/
│   └── Justfile               # Updated for ArgoCD
├── prometheus/
│   ├── manifests/             # NEW: Additional manifests
│   │   ├── persistent-volumes.yaml
│   │   ├── grafana-restart-hook.yaml
│   │   ├── freebsd-recording-rules.yaml
│   │   └── ...
│   └── Justfile               # Updated for ArgoCD
└── ...
</pre>
<br />
<span>The application directories (miniflux, prometheus, etc.) remained mostly unchanged—ArgoCD references the same Helm charts. The main additions:</span><br />
<br />
<span>1. **argocd-apps/**: Application manifests organized by Kubernetes namespace for better clarity</span><br />
<span>   - <span class='inlinecode'>monitoring/</span>: 6 observability applications</span><br />
<span>   - <span class='inlinecode'>services/</span>: 13 user-facing applications</span><br />
<span>   - <span class='inlinecode'>infra/</span>: 1 infrastructure application (registry)</span><br />
<span>   - <span class='inlinecode'>test/</span>: 1 test application</span><br />
<span>2. ***/manifests/**: Additional Kubernetes manifests for complex apps (like Prometheus)</span><br />
<span>3. **Justfiles updated**: Changed from <span class='inlinecode'>helm install/upgrade</span> to <span class='inlinecode'>argocd app sync</span></span><br />
<br />
<span>This organization makes it easy to apply all applications in a specific namespace or manage them independently.</span><br />
<br />
<h2 style='display: inline' id='migration-strategy-incremental-one-app-at-a-time'>Migration Strategy: Incremental, One App at a Time</h2><br />
<br />
<span>Rather than attempting a "big bang" migration of all 21 applications at once, I migrated them incrementally:</span><br />
<br />
<span>1. **Start with a simple app**: Validate the pattern with a low-risk application</span><br />
<span>2. **Migrate in waves**: Group similar applications and migrate together</span><br />
<span>3. **Validate thoroughly**: Ensure each app is healthy before moving to the next</span><br />
<span>4. **Learn and iterate**: Apply lessons from earlier migrations to later ones</span><br />
<br />
<span>This approach reduced risk and allowed me to refine the migration process.</span><br />
<br />
<h3 style='display: inline' id='migration-phases'>Migration Phases</h3><br />
<br />
<span>**Phase 1: Simple services** (13 apps)</span><br />
<ul>
<li>miniflux, freshrss, wallabag</li>
<li>anki-sync-server, kobo-sync-server, opodsync</li>
<li>radicale, syncthing, audiobookshelf</li>
<li>filebrowser, keybr, webdav</li>
<li>example-apache, example-apache-volume-claim</li>
</ul><br />
<span>These apps have straightforward Helm charts with no complex dependencies. Pattern established:</span><br />
<span>1. Create Application manifest in <span class='inlinecode'>argocd-apps/</span></span><br />
<span>2. Apply with <span class='inlinecode'>kubectl apply -f argocd-apps/&lt;app&gt;.yaml</span></span><br />
<span>3. Verify sync status: <span class='inlinecode'>argocd app get &lt;app&gt;</span></span><br />
<span>4. Update Justfile to use ArgoCD commands</span><br />
<br />
<span>**Phase 2: Infrastructure apps** (3 apps)</span><br />
<ul>
<li>registry (Docker image registry)</li>
<li>pushgateway (Prometheus metrics ingestion)</li>
<li>immich (photo management with complex dependencies)</li>
</ul><br />
<span>**Phase 3: Monitoring stack** (4 apps)</span><br />
<ul>
<li>tempo (distributed tracing)</li>
<li>loki (log aggregation)</li>
<li>alloy (log collection)</li>
<li>prometheus (metrics and monitoring)</li>
</ul><br />
<span>**Phase 4: Monitoring addons** (1 app)</span><br />
<ul>
<li>grafana-ingress (separate ingress for Grafana)</li>
</ul><br />
<h2 style='display: inline' id='example-migration-miniflux'>Example Migration: Miniflux</h2><br />
<br />
<span>Let me walk through the migration of miniflux as a concrete example.</span><br />
<br />
<h3 style='display: inline' id='before-imperative-helm-deployment'>Before: Imperative Helm deployment</h3><br />
<br />
<span>Original Justfile:</span><br />
<br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#F3E651">NAMESPACE :=</font><font color="#ff0000"> </font><font color="#bb00ff">"services"</font>
<font color="#F3E651">APP_NAME :=</font><font color="#ff0000"> </font><font color="#bb00ff">"miniflux"</font>

<font color="#F3E651">install:</font>
<font color="#ff0000">    kubectl apply -f helm-chart/persistent-volumes.yaml</font>
<font color="#ff0000">    helm install {{APP_NAME}} </font><font color="#F3E651">.</font><font color="#ff0000">/helm-chart --namespace {{NAMESPACE}}</font>

<font color="#F3E651">upgrade:</font>
<font color="#ff0000">    helm upgrade {{APP_NAME}} </font><font color="#F3E651">.</font><font color="#ff0000">/helm-chart --namespace {{NAMESPACE}}</font>

<font color="#F3E651">uninstall:</font>
<font color="#ff0000">    helm uninstall {{APP_NAME}} --namespace {{NAMESPACE}}</font>
<font color="#ff0000">    kubectl delete -f helm-chart/persistent-volumes.yaml</font>

<font color="#F3E651">status:</font>
<font color="#ff0000">    @kubectl get all -n {{NAMESPACE}} -l </font><font color="#ff0000">app</font><font color="#F3E651">=</font><font color="#ff0000">{{APP_NAME}}</font>
</pre>
<br />
<span>Workflow:</span><br />
<span>1. Make changes to <span class='inlinecode'>helm-chart/</span></span><br />
<span>2. Run <span class='inlinecode'>just upgrade</span></span><br />
<span>3. Helm pushes changes to cluster</span><br />
<br />
<h3 style='display: inline' id='after-declarative-gitops-with-argocd'>After: Declarative GitOps with ArgoCD</h3><br />
<br />
<span>Created <span class='inlinecode'>argocd-apps/services/miniflux.yaml</span>:</span><br />
<br />
<pre>
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: miniflux
  namespace: cicd
  finalizers:
    - resources-finalizer.argocd.argoproj.io
spec:
  project: default
  source:
    repoURL: https://codeberg.org/snonux/conf.git
    targetRevision: master
    path: f3s/miniflux/helm-chart
  destination:
    server: https://kubernetes.default.svc
    namespace: services
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - CreateNamespace=false
    retry:
      limit: 3
      backoff:
        duration: 5s
        factor: 2
        maxDuration: 1m
</pre>
<br />
<span>Updated Justfile:</span><br />
<br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#F3E651">NAMESPACE :=</font><font color="#ff0000"> </font><font color="#bb00ff">"services"</font>
<font color="#F3E651">APP_NAME :=</font><font color="#ff0000"> </font><font color="#bb00ff">"miniflux"</font>

<font color="#F3E651">status:</font>
<font color="#ff0000">    @echo </font><font color="#bb00ff">"=== Pods ==="</font>
<font color="#ff0000">    @kubectl get pods -n {{NAMESPACE}} -l </font><font color="#ff0000">app</font><font color="#F3E651">=</font><font color="#ff0000">{{APP_NAME}}</font>
<font color="#ff0000">    @echo </font><font color="#bb00ff">""</font>
<font color="#ff0000">    @echo </font><font color="#bb00ff">"=== Services ==="</font>
<font color="#ff0000">    @kubectl get svc -n {{NAMESPACE}} -l </font><font color="#ff0000">app</font><font color="#F3E651">=</font><font color="#ff0000">{{APP_NAME}}</font>
<font color="#ff0000">    @echo </font><font color="#bb00ff">""</font>
<font color="#ff0000">    @echo </font><font color="#bb00ff">"=== ArgoCD Status ==="</font>
<font color="#ff0000">    @kubectl get application {{APP_NAME}} -n cicd -o </font><font color="#ff0000">jsonpath</font><font color="#F3E651">=</font><font color="#bb00ff">'Sync: {.status.sync.status}, Health: {.status.health.status}'</font><font color="#ff0000"> </font><font color="#bb00ff">2</font><font color="#F3E651">&gt;</font><font color="#ff0000">/dev/null </font><font color="#F3E651">&amp;&amp;</font><font color="#ff0000"> echo </font><font color="#bb00ff">""</font>

<font color="#F3E651">sync:</font>
<font color="#ff0000">    @echo </font><font color="#bb00ff">"Triggering ArgoCD sync..."</font>
<font color="#ff0000">    @kubectl annotate application {{APP_NAME}} -n cicd argocd.argoproj.io/refresh</font><font color="#F3E651">=</font><font color="#ff0000">normal --overwrite</font>
<font color="#ff0000">    @sleep </font><font color="#bb00ff">2</font>
<font color="#ff0000">    @kubectl get application {{APP_NAME}} -n cicd -o </font><font color="#ff0000">jsonpath</font><font color="#F3E651">=</font><font color="#bb00ff">'Sync: {.status.sync.status}, Health: {.status.health.status}'</font><font color="#ff0000"> </font><font color="#F3E651">&amp;&amp;</font><font color="#ff0000"> echo </font><font color="#bb00ff">""</font>

<font color="#F3E651">argocd-status:</font>
<font color="#ff0000">    argocd app get {{APP_NAME}} --core</font>

<font color="#F3E651">logs:</font>
<font color="#ff0000">    kubectl logs -n {{NAMESPACE}} -l </font><font color="#ff0000">app</font><font color="#F3E651">=</font><font color="#ff0000">{{APP_NAME}} --tail</font><font color="#F3E651">=</font><font color="#bb00ff">100</font><font color="#ff0000"> -f</font>
</pre>
<br />
<span>New workflow:</span><br />
<span>1. Make changes to <span class='inlinecode'>helm-chart/</span></span><br />
<span>2. Commit and push to Git</span><br />
<span>3. ArgoCD automatically detects and syncs changes</span><br />
<span>4. (Optional) Run <span class='inlinecode'>just sync</span> to force immediate sync</span><br />
<br />
<h3 style='display: inline' id='migration-procedure'>Migration procedure</h3><br />
<br />
<span>1. **Backup current state**:</span><br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#ff0000">$ helm get values miniflux -n services </font><font color="#F3E651">&gt;</font><font color="#ff0000"> /tmp/miniflux-backup-values</font><font color="#F3E651">.</font><font color="#ff0000">yaml</font>
<font color="#ff0000">$ kubectl get all</font><font color="#F3E651">,</font><font color="#ff0000">ingress -n services -o yaml </font><font color="#F3E651">&gt;</font><font color="#ff0000"> /tmp/miniflux-backup</font><font color="#F3E651">.</font><font color="#ff0000">yaml</font>
</pre>
<br />
<span>2. **Create Application manifest**:</span><br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#ff0000">$ kubectl apply -f argocd-apps/services/miniflux</font><font color="#F3E651">.</font><font color="#ff0000">yaml</font>
<font color="#ff0000">application</font><font color="#F3E651">.</font><font color="#ff0000">argoproj</font><font color="#F3E651">.</font><font color="#ff0000">io/miniflux created</font>
</pre>
<br />
<span>3. **Verify ArgoCD adopted the resources**:</span><br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#ff0000">$ argocd app get miniflux</font>
<font color="#ff0000">Name</font><font color="#F3E651">:</font><font color="#ff0000">               miniflux</font>
<font color="#ff0000">Project</font><font color="#F3E651">:</font><font color="#ff0000">            default</font>
<font color="#ff0000">Server</font><font color="#F3E651">:</font><font color="#ff0000">             https</font><font color="#F3E651">:</font><font color="#ff0000">//kubernetes</font><font color="#F3E651">.</font><font color="#ff0000">default</font><font color="#F3E651">.</font><font color="#ff0000">svc</font>
<font color="#ff0000">Namespace</font><font color="#F3E651">:</font><font color="#ff0000">          services</font>
<font color="#ff0000">URL</font><font color="#F3E651">:</font><font color="#ff0000">                https</font><font color="#F3E651">:</font><font color="#ff0000">//argocd</font><font color="#F3E651">.</font><font color="#ff0000">f3s</font><font color="#F3E651">.</font><font color="#ff0000">buetow</font><font color="#F3E651">.</font><font color="#ff0000">org/applications/miniflux</font>
<font color="#ff0000">Repo</font><font color="#F3E651">:</font><font color="#ff0000">               https</font><font color="#F3E651">:</font><font color="#ff0000">//codeberg</font><font color="#F3E651">.</font><font color="#ff0000">org/snonux/conf</font><font color="#F3E651">.</font><font color="#ff0000">git</font>
<font color="#ff0000">Target</font><font color="#F3E651">:</font><font color="#ff0000">             master</font>
<font color="#ff0000">Path</font><font color="#F3E651">:</font><font color="#ff0000">               f3s/miniflux/helm-chart</font>
<font color="#ff0000">SyncWindow</font><font color="#F3E651">:</font><font color="#ff0000">         Sync Allowed</font>
<font color="#ff0000">Sync Policy</font><font color="#F3E651">:</font><font color="#ff0000">        Automated </font><font color="#F3E651">(</font><font color="#ff0000">Prune</font><font color="#F3E651">)</font>
<font color="#ff0000">Sync Status</font><font color="#F3E651">:</font><font color="#ff0000">        Synced to master </font><font color="#F3E651">(</font><font color="#ff0000">4e3c216</font><font color="#F3E651">)</font>
<font color="#ff0000">Health Status</font><font color="#F3E651">:</font><font color="#ff0000">      Healthy</font>
</pre>
<br />
<span>4. **Monitor for issues**:</span><br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#ff0000">$ kubectl get pods -n services -l </font><font color="#ff0000">app</font><font color="#F3E651">=</font><font color="#ff0000">miniflux -w</font>
<font color="#ff0000">NAME                                READY   STATUS    RESTARTS   AGE</font>
<font color="#ff0000">miniflux-postgres-556444cb8d-xvv2p  </font><font color="#bb00ff">1</font><font color="#F3E651">/</font><font color="#bb00ff">1</font><font color="#ff0000">     Running   </font><font color="#bb00ff">0</font><font color="#ff0000">          54d</font>
<font color="#ff0000">miniflux-server-85d7c64664-stmt</font><font color="#bb00ff">9</font><font color="#ff0000">    </font><font color="#bb00ff">1</font><font color="#F3E651">/</font><font color="#bb00ff">1</font><font color="#ff0000">     Running   </font><font color="#bb00ff">0</font><font color="#ff0000">          54d</font>
</pre>
<br />
<span>5. **Test the application**:</span><br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#ff0000">$ curl -I https</font><font color="#F3E651">:</font><font color="#ff0000">//flux</font><font color="#F3E651">.</font><font color="#ff0000">f3s</font><font color="#F3E651">.</font><font color="#ff0000">buetow</font><font color="#F3E651">.</font><font color="#ff0000">org</font>
<font color="#ff0000">HTTP</font><font color="#F3E651">/</font><font color="#bb00ff">2</font><font color="#ff0000"> </font><font color="#bb00ff">200</font>
</pre>
<br />
<span>6. **Update Justfile** and commit changes</span><br />
<br />
<span>Total time: 10 minutes. Zero downtime.</span><br />
<br />
<h2 style='display: inline' id='complex-migration-prometheus-with-multi-source'>Complex Migration: Prometheus with Multi-Source</h2><br />
<br />
<span>The Prometheus migration was more complex because it combines:</span><br />
<ul>
<li>Upstream Helm chart (kube-prometheus-stack)</li>
<li>Custom manifests (PersistentVolumes, recording rules, dashboards)</li>
<li>Sync hooks (PostSync job to restart Grafana)</li>
</ul><br />
<span>ArgoCD supports "multi-source" Applications that combine multiple sources:</span><br />
<br />
<pre>
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: prometheus
  namespace: cicd
  finalizers:
    - resources-finalizer.argocd.argoproj.io
spec:
  project: default
  sources:
    # Source 1: Upstream Helm chart from prometheus-community
    - repoURL: https://prometheus-community.github.io/helm-charts
      chart: kube-prometheus-stack
      targetRevision: 55.5.0
      helm:
        releaseName: prometheus
        valuesObject:
          # Full Prometheus configuration embedded here
          kubeEtcd:
            enabled: true
            endpoints:
              - 192.168.2.120
              - 192.168.2.121
              - 192.168.2.122
          # ... (hundreds of lines of configuration)

    # Source 2: Additional manifests from Git repository
    - repoURL: https://codeberg.org/snonux/conf.git
      targetRevision: master
      path: f3s/prometheus/manifests

  destination:
    server: https://kubernetes.default.svc
    namespace: monitoring

  syncPolicy:
    automated:
      prune: false  # Manual pruning for safety on complex stack
      selfHeal: true
    syncOptions:
      - CreateNamespace=false
      - ServerSideApply=true
    retry:
      limit: 3
      backoff:
        duration: 10s
        factor: 2
        maxDuration: 3m
</pre>
<br />
<span>The <span class='inlinecode'>prometheus/manifests/</span> directory contains:</span><br />
<br />
<pre>
f3s/prometheus/manifests/
├── persistent-volumes.yaml              # Sync wave 0
├── additional-scrape-configs-secret.yaml # Sync wave 1
├── grafana-datasources-configmap.yaml   # Sync wave 1
├── freebsd-recording-rules.yaml         # Sync wave 3
├── openbsd-recording-rules.yaml         # Sync wave 3
├── zfs-recording-rules.yaml             # Sync wave 3
├── epimetheus-dashboard.yaml            # Sync wave 4
├── zfs-dashboards.yaml                  # Sync wave 4
├── grafana-restart-hook.yaml            # Sync wave 10 (PostSync)
└── grafana-restart-rbac.yaml            # Sync wave 0
</pre>
<br />
<h3 style='display: inline' id='sync-waves-and-hooks'>Sync Waves and Hooks</h3><br />
<br />
<span>ArgoCD allows controlling the order of resource deployment using sync waves (the <span class='inlinecode'>argocd.argoproj.io/sync-wave</span> annotation):</span><br />
<br />
<ul>
<li>**Wave 0**: Infrastructure (PersistentVolumes, RBAC)</li>
<li>**Wave 1**: Configuration (Secrets, ConfigMaps)</li>
<li>**Wave 3**: Recording rules (PrometheusRule CRDs)</li>
<li>**Wave 4**: Dashboards (ConfigMaps with <span class='inlinecode'>grafana_dashboard: &#39;1&#39;</span> label)</li>
<li>**Wave 10**: PostSync hooks (Jobs that run after everything else)</li>
</ul><br />
<span>The Grafana restart hook ensures Grafana reloads datasources after they&#39;re updated:</span><br />
<br />
<pre>
apiVersion: batch/v1
kind: Job
metadata:
  name: grafana-restart-hook
  namespace: monitoring
  annotations:
    argocd.argoproj.io/hook: PostSync
    argocd.argoproj.io/hook-delete-policy: BeforeHookCreation
    argocd.argoproj.io/sync-wave: "10"
spec:
  template:
    spec:
      serviceAccountName: grafana-restart-sa
      restartPolicy: OnFailure
      containers:
        - name: kubectl
          image: bitnami/kubectl:latest
          command:
            - /bin/sh
            - -c
            - |
              kubectl wait --for=condition=available --timeout=300s deployment/prometheus-grafana -n monitoring || true
              kubectl delete pod -n monitoring -l app.kubernetes.io/name=grafana --ignore-not-found=true
  backoffLimit: 2
</pre>
<br />
<span>This replaces the manual step in the old Justfile that required running <span class='inlinecode'>kubectl delete pod</span> after every upgrade.</span><br />
<br />
<h2 style='display: inline' id='migration-results'>Migration Results</h2><br />
<br />
<span>After migrating all 21 applications to ArgoCD:</span><br />
<br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#ff0000">$ argocd app list</font>
<font color="#ff0000">NAME                      CLUSTER                         NAMESPACE    PROJECT  STATUS  HEALTH   SYNCPOLICY</font>
<font color="#ff0000">alloy                     https</font><font color="#F3E651">:</font><font color="#ff0000">//kubernetes</font><font color="#F3E651">.</font><font color="#ff0000">default</font><font color="#F3E651">.</font><font color="#ff0000">svc  monitoring   default  Synced  Healthy  Auto-Prune</font>
<font color="#ff0000">anki-sync-server          https</font><font color="#F3E651">:</font><font color="#ff0000">//kubernetes</font><font color="#F3E651">.</font><font color="#ff0000">default</font><font color="#F3E651">.</font><font color="#ff0000">svc  services     default  Synced  Healthy  Auto-Prune</font>
<font color="#ff0000">audiobookshelf            https</font><font color="#F3E651">:</font><font color="#ff0000">//kubernetes</font><font color="#F3E651">.</font><font color="#ff0000">default</font><font color="#F3E651">.</font><font color="#ff0000">svc  services     default  Synced  Healthy  Auto-Prune</font>
<font color="#ff0000">example-apache            https</font><font color="#F3E651">:</font><font color="#ff0000">//kubernetes</font><font color="#F3E651">.</font><font color="#ff0000">default</font><font color="#F3E651">.</font><font color="#ff0000">svc  </font><b><font color="#ffffff">test</font></b><font color="#ff0000">         default  Synced  Healthy  Auto-Prune</font>
<font color="#ff0000">example-apache-volume-</font><font color="#F3E651">...</font><font color="#ff0000"> https</font><font color="#F3E651">:</font><font color="#ff0000">//kubernetes</font><font color="#F3E651">.</font><font color="#ff0000">default</font><font color="#F3E651">.</font><font color="#ff0000">svc  </font><b><font color="#ffffff">test</font></b><font color="#ff0000">         default  Synced  Healthy  Auto-Prune</font>
<font color="#ff0000">filebrowser               https</font><font color="#F3E651">:</font><font color="#ff0000">//kubernetes</font><font color="#F3E651">.</font><font color="#ff0000">default</font><font color="#F3E651">.</font><font color="#ff0000">svc  services     default  Synced  Healthy  Auto-Prune</font>
<font color="#ff0000">freshrss                  https</font><font color="#F3E651">:</font><font color="#ff0000">//kubernetes</font><font color="#F3E651">.</font><font color="#ff0000">default</font><font color="#F3E651">.</font><font color="#ff0000">svc  services     default  Synced  Healthy  Auto-Prune</font>
<font color="#ff0000">grafana-ingress           https</font><font color="#F3E651">:</font><font color="#ff0000">//kubernetes</font><font color="#F3E651">.</font><font color="#ff0000">default</font><font color="#F3E651">.</font><font color="#ff0000">svc  monitoring   default  Synced  Healthy  Auto-Prune</font>
<font color="#ff0000">immich                    https</font><font color="#F3E651">:</font><font color="#ff0000">//kubernetes</font><font color="#F3E651">.</font><font color="#ff0000">default</font><font color="#F3E651">.</font><font color="#ff0000">svc  services     default  Synced  Healthy  Auto-Prune</font>
<font color="#ff0000">keybr                     https</font><font color="#F3E651">:</font><font color="#ff0000">//kubernetes</font><font color="#F3E651">.</font><font color="#ff0000">default</font><font color="#F3E651">.</font><font color="#ff0000">svc  services     default  Synced  Healthy  Auto-Prune</font>
<font color="#ff0000">kobo-sync-server          https</font><font color="#F3E651">:</font><font color="#ff0000">//kubernetes</font><font color="#F3E651">.</font><font color="#ff0000">default</font><font color="#F3E651">.</font><font color="#ff0000">svc  services     default  Synced  Healthy  Auto-Prune</font>
<font color="#ff0000">loki                      https</font><font color="#F3E651">:</font><font color="#ff0000">//kubernetes</font><font color="#F3E651">.</font><font color="#ff0000">default</font><font color="#F3E651">.</font><font color="#ff0000">svc  monitoring   default  Synced  Healthy  Auto-Prune</font>
<font color="#ff0000">miniflux                  https</font><font color="#F3E651">:</font><font color="#ff0000">//kubernetes</font><font color="#F3E651">.</font><font color="#ff0000">default</font><font color="#F3E651">.</font><font color="#ff0000">svc  services     default  Synced  Healthy  Auto-Prune</font>
<font color="#ff0000">opodsync                  https</font><font color="#F3E651">:</font><font color="#ff0000">//kubernetes</font><font color="#F3E651">.</font><font color="#ff0000">default</font><font color="#F3E651">.</font><font color="#ff0000">svc  services     default  Synced  Healthy  Auto-Prune</font>
<font color="#ff0000">prometheus                https</font><font color="#F3E651">:</font><font color="#ff0000">//kubernetes</font><font color="#F3E651">.</font><font color="#ff0000">default</font><font color="#F3E651">.</font><font color="#ff0000">svc  monitoring   default  Synced  Healthy  Auto</font>
<font color="#ff0000">pushgateway               https</font><font color="#F3E651">:</font><font color="#ff0000">//kubernetes</font><font color="#F3E651">.</font><font color="#ff0000">default</font><font color="#F3E651">.</font><font color="#ff0000">svc  monitoring   default  Synced  Healthy  Auto-Prune</font>
<font color="#ff0000">radicale                  https</font><font color="#F3E651">:</font><font color="#ff0000">//kubernetes</font><font color="#F3E651">.</font><font color="#ff0000">default</font><font color="#F3E651">.</font><font color="#ff0000">svc  services     default  Synced  Healthy  Auto-Prune</font>
<font color="#ff0000">registry                  https</font><font color="#F3E651">:</font><font color="#ff0000">//kubernetes</font><font color="#F3E651">.</font><font color="#ff0000">default</font><font color="#F3E651">.</font><font color="#ff0000">svc  infra        default  Synced  Healthy  Auto-Prune</font>
<font color="#ff0000">syncthing                 https</font><font color="#F3E651">:</font><font color="#ff0000">//kubernetes</font><font color="#F3E651">.</font><font color="#ff0000">default</font><font color="#F3E651">.</font><font color="#ff0000">svc  services     default  Synced  Healthy  Auto-Prune</font>
<font color="#ff0000">tempo                     https</font><font color="#F3E651">:</font><font color="#ff0000">//kubernetes</font><font color="#F3E651">.</font><font color="#ff0000">default</font><font color="#F3E651">.</font><font color="#ff0000">svc  monitoring   default  Synced  Healthy  Auto-Prune</font>
<font color="#ff0000">wallabag                  https</font><font color="#F3E651">:</font><font color="#ff0000">//kubernetes</font><font color="#F3E651">.</font><font color="#ff0000">default</font><font color="#F3E651">.</font><font color="#ff0000">svc  services     default  Synced  Healthy  Auto-Prune</font>
<font color="#ff0000">webdav                    https</font><font color="#F3E651">:</font><font color="#ff0000">//kubernetes</font><font color="#F3E651">.</font><font color="#ff0000">default</font><font color="#F3E651">.</font><font color="#ff0000">svc  services     default  Synced  Healthy  Auto-Prune</font>
</pre>
<br />
<span>All 21 applications: **Synced** and **Healthy**.</span><br />
<br />
<span>ArgoCD Web UI:</span><br />
<br />
<a href='./f3s-kubernetes-with-freebsd-part-X/argocd-apps-list.png'><img alt='ArgoCD Applications List' title='ArgoCD Applications List' src='./f3s-kubernetes-with-freebsd-part-X/argocd-apps-list.png' /></a><br />
<br />
<a href='./f3s-kubernetes-with-freebsd-part-X/argocd-app-tree.png'><img alt='ArgoCD Application Resource Tree' title='ArgoCD Application Resource Tree' src='./f3s-kubernetes-with-freebsd-part-X/argocd-app-tree.png' /></a><br />
<br />
<h2 style='display: inline' id='benefits-realized'>Benefits Realized</h2><br />
<br />
<h3 style='display: inline' id='1-single-source-of-truth'>1. Single Source of Truth</h3><br />
<br />
<span>The Git repository at <span class='inlinecode'>https://codeberg.org/snonux/conf</span> now contains the complete cluster configuration. Anyone can clone it and see exactly what&#39;s deployed:</span><br />
<br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#ff0000">$ git clone https</font><font color="#F3E651">:</font><font color="#ff0000">//codeberg</font><font color="#F3E651">.</font><font color="#ff0000">org/snonux/conf</font><font color="#F3E651">.</font><font color="#ff0000">git</font>
<font color="#ff0000">$ cd conf/f3s</font>
<font color="#ff0000">$ ls argocd-apps</font><font color="#F3E651">/</font>
<font color="#ff0000">alloy</font><font color="#F3E651">.</font><font color="#ff0000">yaml  anki-sync-server</font><font color="#F3E651">.</font><font color="#ff0000">yaml  audiobookshelf</font><font color="#F3E651">.</font><font color="#ff0000">yaml  </font><font color="#F3E651">...</font>
</pre>
<br />
<h3 style='display: inline' id='2-automatic-synchronization'>2. Automatic Synchronization</h3><br />
<br />
<span>Push to Git, and changes deploy automatically:</span><br />
<br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#ff0000">$ cd conf/f3s/miniflux/helm-chart</font>
<font color="#ff0000">$ vim values</font><font color="#F3E651">.</font><font color="#ff0000">yaml  </font><i><font color="#ababab"># Change replica count from 1 to 2</font></i>
<font color="#ff0000">$ git add values</font><font color="#F3E651">.</font><font color="#ff0000">yaml</font>
<font color="#ff0000">$ git commit -m </font><font color="#bb00ff">"Scale miniflux to 2 replicas"</font>
<font color="#ff0000">$ git push</font>
<i><font color="#ababab"># ArgoCD detects change within 3 minutes and syncs automatically</font></i>
</pre>
<br />
<span>No need to SSH to a workstation, pull the repo, and run <span class='inlinecode'>just upgrade</span>.</span><br />
<br />
<h3 style='display: inline' id='3-drift-detection-and-self-healing'>3. Drift Detection and Self-Healing</h3><br />
<br />
<span>If someone manually changes a resource in the cluster, ArgoCD detects it:</span><br />
<br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#ff0000">$ kubectl scale deployment miniflux-server -n services --replicas</font><font color="#F3E651">=</font><font color="#bb00ff">3</font>
<font color="#ff0000">deployment</font><font color="#F3E651">.</font><font color="#ff0000">apps/miniflux-server scaled</font>

<i><font color="#ababab"># ArgoCD detects drift within 3 minutes</font></i>
<font color="#ff0000">$ argocd app get miniflux</font>
<font color="#F3E651">...</font>
<font color="#ff0000">Sync Status</font><font color="#F3E651">:</font><font color="#ff0000">        OutOfSync from master </font><font color="#F3E651">(</font><font color="#ff0000">4e3c216</font><font color="#F3E651">)</font>
</pre>
<br />
<span>With <span class='inlinecode'>selfHeal: true</span>, ArgoCD automatically reverts the change back to 2 replicas (the value in Git).</span><br />
<br />
<h3 style='display: inline' id='4-easy-rollbacks'>4. Easy Rollbacks</h3><br />
<br />
<span>To rollback a change:</span><br />
<br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#ff0000">$ git revert HEAD</font>
<font color="#ff0000">$ git push</font>
<i><font color="#ababab"># ArgoCD automatically rolls back to the previous state</font></i>
</pre>
<br />
<span>Or rollback to a specific commit:</span><br />
<br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#ff0000">$ argocd app rollback miniflux </font><font color="#F3E651">&lt;</font><font color="#ff0000">revision-id</font><font color="#F3E651">&gt;</font>
</pre>
<br />
<h3 style='display: inline' id='5-disaster-recovery'>5. Disaster Recovery</h3><br />
<br />
<span>If the entire cluster is destroyed, recovery is straightforward:</span><br />
<br />
<span>1. Bootstrap a new k3s cluster</span><br />
<span>2. Create namespaces</span><br />
<span>3. Install ArgoCD</span><br />
<span>4. Apply all Application manifests:</span><br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#ff0000">$ kubectl apply -f argocd-apps</font><font color="#F3E651">/</font>
</pre>
<span>5. ArgoCD deploys all 21 applications to their desired state</span><br />
<br />
<span>Total recovery time: ~30 minutes (mostly waiting for pods to pull images and start).</span><br />
<br />
<h3 style='display: inline' id='6-documentation-by-default'>6. Documentation by Default</h3><br />
<br />
<span>The Application manifests serve as documentation:</span><br />
<br />
<ul>
<li>Which Helm chart version is deployed? → Check <span class='inlinecode'>targetRevision</span></li>
<li>What custom values are configured? → Check <span class='inlinecode'>valuesObject</span></li>
<li>Which namespace does this deploy to? → Check <span class='inlinecode'>destination.namespace</span></li>
<li>Is auto-sync enabled? → Check <span class='inlinecode'>syncPolicy.automated</span></li>
</ul><br />
<span>No more guessing or checking <span class='inlinecode'>helm list</span> output.</span><br />
<br />
<h3 style='display: inline' id='7-safe-experimentation'>7. Safe Experimentation</h3><br />
<br />
<span>Create a feature branch, make changes, and preview them:</span><br />
<br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#ff0000">$ git checkout -b test-prometheus-upgrade</font>
<font color="#ff0000">$ vim argocd-apps/prometheus</font><font color="#F3E651">.</font><font color="#ff0000">yaml  </font><i><font color="#ababab"># Bump chart version</font></i>
<font color="#ff0000">$ git commit -am </font><font color="#bb00ff">"Test Prometheus 56.0.0"</font>
<font color="#ff0000">$ git push origin test-prometheus-upgrade</font>

<i><font color="#ababab"># Temporarily point ArgoCD at the feature branch</font></i>
<font color="#ff0000">$ kubectl patch application prometheus -n cicd </font><font color="#F3E651">\</font>
<font color="#ff0000">    --type merge </font><font color="#F3E651">\</font>
<font color="#ff0000">    -p </font><font color="#bb00ff">'{"spec":{"source":{"targetRevision":"test-prometheus-upgrade"}}}'</font>

<i><font color="#ababab"># Verify changes in ArgoCD Web UI</font></i>
<i><font color="#ababab"># If good: merge to master</font></i>
<i><font color="#ababab"># If bad: revert the patch</font></i>
</pre>
<br />
<h2 style='display: inline' id='challenges-and-solutions'>Challenges and Solutions</h2><br />
<br />
<h3 style='display: inline' id='challenge-1-helm-release-adoption'>Challenge 1: Helm Release Adoption</h3><br />
<br />
<span>When creating an Application for an existing Helm release, ArgoCD needs to "adopt" the resources. This failed initially with errors like:</span><br />
<br />
<pre>
The Helm operation failed with an error: release miniflux failed, and has been uninstalled due to atomic being set: timed out waiting for the condition
</pre>
<br />
<span>**Solution**: For existing Helm releases, I first ensured the Application manifest matched the current Helm values exactly. ArgoCD then recognized the resources were already in the desired state and adopted them without re-deploying.</span><br />
<br />
<h3 style='display: inline' id='challenge-2-persistent-volumes-not-tracked-by-helm'>Challenge 2: Persistent Volumes Not Tracked by Helm</h3><br />
<br />
<span>PersistentVolumes are cluster-scoped resources, not namespace-scoped. Many of my Helm charts created PVs using <span class='inlinecode'>kubectl apply -f persistent-volumes.yaml</span> outside of Helm.</span><br />
<br />
<span>**Solution**: For simple apps, I moved the PV definitions into the Helm chart templates. For complex apps (like Prometheus), I used the multi-source pattern with PVs in the <span class='inlinecode'>manifests/</span> directory with sync wave 0.</span><br />
<br />
<h3 style='display: inline' id='challenge-3-secrets-management'>Challenge 3: Secrets Management</h3><br />
<br />
<span>ArgoCD stores Application manifests in Git, but secrets shouldn&#39;t be committed in plaintext.</span><br />
<br />
<span>**Solution (current)**: Secrets are created manually with <span class='inlinecode'>kubectl create secret</span> and referenced by the Helm charts. The secrets themselves aren&#39;t managed by ArgoCD.</span><br />
<br />
<span>**Future enhancement**: Migrate to External Secrets Operator (ESO) to manage secrets declaratively while storing the actual secrets in a separate backend (Kubernetes secrets in a separate namespace, or eventually Vault).</span><br />
<br />
<h3 style='display: inline' id='challenge-4-grafana-not-reloading-datasources'>Challenge 4: Grafana Not Reloading Datasources</h3><br />
<br />
<span>After updating the Grafana datasources ConfigMap, Grafana wouldn&#39;t detect the changes until pods were manually deleted.</span><br />
<br />
<span>**Solution**: Created a PostSync hook that automatically restarts Grafana pods after every ArgoCD sync. This runs as a Kubernetes Job in sync wave 10, ensuring it executes after all other resources are deployed.</span><br />
<br />
<h3 style='display: inline' id='challenge-5-prometheus-with-multiple-sources'>Challenge 5: Prometheus With Multiple Sources</h3><br />
<br />
<span>Prometheus needed both the upstream Helm chart and custom manifests (recording rules, dashboards, PVs).</span><br />
<br />
<span>**Solution**: Used ArgoCD&#39;s multi-source feature to combine:</span><br />
<ul>
<li>Helm chart from <span class='inlinecode'>prometheus-community.github.io/helm-charts</span></li>
<li>Additional manifests from <span class='inlinecode'>codeberg.org/snonux/conf.git</span> at path <span class='inlinecode'>f3s/prometheus/manifests</span></li>
</ul><br />
<span>This keeps the upstream chart cleanly separated from custom configuration.</span><br />
<br />
<h3 style='display: inline' id='challenge-6-sync-ordering-for-prometheus'>Challenge 6: Sync Ordering for Prometheus</h3><br />
<br />
<span>Prometheus resources have dependencies:</span><br />
<ul>
<li>PVs before PVCs</li>
<li>Secrets before Prometheus Operator</li>
<li>PrometheusRule CRDs before Prometheus Operator can process them</li>
<li>Grafana must be running before the restart hook executes</li>
</ul><br />
<span>**Solution**: Added sync wave annotations to all resources in <span class='inlinecode'>prometheus/manifests/</span>:</span><br />
<ul>
<li>Wave 0: PVs, RBAC</li>
<li>Wave 1: Secrets, ConfigMaps</li>
<li>Wave 3: PrometheusRule CRDs (recording rules)</li>
<li>Wave 4: Dashboard ConfigMaps</li>
<li>Wave 10: PostSync hook (Grafana restart)</li>
</ul><br />
<span>ArgoCD deploys resources in wave order, ensuring correct sequencing.</span><br />
<br />
<h2 style='display: inline' id='justfile-evolution'>Justfile Evolution</h2><br />
<br />
<span>The Justfiles evolved from deployment tools to utility scripts:</span><br />
<br />
<span>**Before (Helm deployment)**:</span><br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#F3E651">install:</font>
<font color="#ff0000">    helm install miniflux </font><font color="#F3E651">.</font><font color="#ff0000">/helm-chart -n services</font>

<font color="#F3E651">upgrade:</font>
<font color="#ff0000">    helm upgrade miniflux </font><font color="#F3E651">.</font><font color="#ff0000">/helm-chart -n services</font>

<font color="#F3E651">uninstall:</font>
<font color="#ff0000">    helm uninstall miniflux -n services</font>
</pre>
<br />
<span>**After (ArgoCD utilities)**:</span><br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#F3E651">status:</font>
<font color="#ff0000">    @kubectl get pods -n services -l </font><font color="#ff0000">app</font><font color="#F3E651">=</font><font color="#ff0000">miniflux</font>
<font color="#ff0000">    @kubectl get application miniflux -n cicd -o </font><font color="#ff0000">jsonpath</font><font color="#F3E651">=</font><font color="#bb00ff">'Sync: {.status.sync.status}, Health: {.status.health.status}'</font>

<font color="#F3E651">sync:</font>
<font color="#ff0000">    @kubectl annotate application miniflux -n cicd argocd.argoproj.io/refresh</font><font color="#F3E651">=</font><font color="#ff0000">normal --overwrite</font>

<font color="#F3E651">argocd-status:</font>
<font color="#ff0000">    argocd app get miniflux --core</font>

<font color="#F3E651">logs:</font>
<font color="#ff0000">    kubectl logs -n services -l </font><font color="#ff0000">app</font><font color="#F3E651">=</font><font color="#ff0000">miniflux --tail</font><font color="#F3E651">=</font><font color="#bb00ff">100</font><font color="#ff0000"> -f</font>
</pre>
<br />
<span>The Justfiles now provide:</span><br />
<ul>
<li><span class='inlinecode'>status</span>: Quick health check</li>
<li><span class='inlinecode'>sync</span>: Force immediate ArgoCD sync (instead of waiting 3 minutes)</li>
<li><span class='inlinecode'>argocd-status</span>: Detailed ArgoCD application status</li>
<li><span class='inlinecode'>logs</span>: Tail application logs</li>
<li>Application-specific utilities (e.g., <span class='inlinecode'>port-forward</span>, <span class='inlinecode'>restart</span>)</li>
</ul><br />
<h2 style='display: inline' id='lessons-learned'>Lessons Learned</h2><br />
<br />
<span>1. **Incremental migration is safer than big-bang**: Migrating one app at a time allowed me to validate the pattern and fix issues before they affected all apps.</span><br />
<br />
<span>2. **Start with simple apps**: The first migration (simple services) established the basic pattern. Complex apps (Prometheus) came later after the pattern was proven.</span><br />
<br />
<span>3. **Sync waves are essential for complex apps**: Without sync waves, resources deployed in random order and caused failures. Proper ordering eliminated all deployment issues.</span><br />
<br />
<span>4. **Multi-source is powerful**: Combining upstream Helm charts with custom manifests keeps configuration clean and maintainable.</span><br />
<br />
<span>5. **PostSync hooks replace manual steps**: The Grafana restart hook eliminated a manual step that was easy to forget.</span><br />
<br />
<span>6. **Documentation in Git is better than tribal knowledge**: The Application manifests document exactly what&#39;s deployed and how. No more "let me check my shell history to remember how I deployed this."</span><br />
<br />
<span>7. **Self-healing prevents configuration drift**: Multiple times I&#39;ve manually tweaked something for debugging, forgotten about it, and ArgoCD automatically reverted it back to the desired state.</span><br />
<br />
<span>8. **ArgoCD Web UI is invaluable**: Seeing the resource tree, sync status, and health status at a glance is much better than running multiple <span class='inlinecode'>kubectl</span> commands.</span><br />
<br />
<h2 style='display: inline' id='future-improvements'>Future Improvements</h2><br />
<br />
<h3 style='display: inline' id='1-external-secrets-operator'>1. External Secrets Operator</h3><br />
<br />
<span>Currently, secrets are manually created with <span class='inlinecode'>kubectl create secret</span>. This works but isn&#39;t declarative. Plan:</span><br />
<br />
<ul>
<li>Deploy External Secrets Operator (ESO)</li>
<li>Store actual secrets in a Kubernetes Secret in a separate <span class='inlinecode'>secrets</span> namespace</li>
<li>Create ExternalSecret CRDs that reference the backend secrets</li>
<li>ArgoCD manages the ExternalSecret CRDs, ESO creates the actual Secrets</li>
</ul><br />
<span>This makes secrets declarative while keeping them out of Git.</span><br />
<br />
<h3 style='display: inline' id='2-applicationset-for-similar-apps'>2. ApplicationSet for Similar Apps</h3><br />
<br />
<span>Many apps have nearly identical Application manifests (miniflux, freshrss, wallabag, etc.). ArgoCD ApplicationSets can generate multiple Applications from a template:</span><br />
<br />
<pre>
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: simple-services
  namespace: cicd
spec:
  generators:
    - list:
        elements:
          - app: miniflux
          - app: freshrss
          - app: wallabag
  template:
    metadata:
      name: &#39;{{app}}&#39;
    spec:
      project: default
      source:
        repoURL: https://codeberg.org/snonux/conf.git
        targetRevision: master
        path: &#39;f3s/{{app}}/helm-chart&#39;
      destination:
        server: https://kubernetes.default.svc
        namespace: services
      syncPolicy:
        automated:
          prune: true
          selfHeal: true
</pre>
<br />
<span>One ApplicationSet could replace 10+ individual Application manifests.</span><br />
<br />
<h3 style='display: inline' id='3-app-of-apps-pattern'>3. App-of-Apps Pattern</h3><br />
<br />
<span>Currently, all Application manifests are applied manually with <span class='inlinecode'>kubectl apply -f argocd-apps/ -R</span>. An alternative is the "app-of-apps" pattern:</span><br />
<br />
<span>Create a root Application that deploys all other Applications. With the namespace-organized structure, this could be done per-namespace or for the entire cluster:</span><br />
<br />
<pre>
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: root
  namespace: cicd
spec:
  source:
    repoURL: https://codeberg.org/snonux/conf.git
    targetRevision: master
    path: f3s/argocd-apps
    directory:
      recurse: true  # Recursively find all manifests in subdirectories
  destination:
    server: https://kubernetes.default.svc
    namespace: cicd
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
</pre>
<br />
<span>Or create separate root apps per namespace:</span><br />
<br />
<pre>
# root-monitoring.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: root-monitoring
  namespace: cicd
spec:
  source:
    repoURL: https://codeberg.org/snonux/conf.git
    targetRevision: master
    path: f3s/argocd-apps/monitoring
  destination:
    server: https://kubernetes.default.svc
    namespace: cicd
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
</pre>
<br />
<span>Then disaster recovery becomes:</span><br />
<!-- Generator: GNU source-highlight 3.1.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><font color="#ff0000">$ kubectl apply -f root-app</font><font color="#F3E651">.</font><font color="#ff0000">yaml</font>
<i><font color="#ababab"># Root app deploys all 21 applications automatically</font></i>

<i><font color="#ababab"># Or apply by namespace</font></i>
<font color="#ff0000">$ kubectl apply -f root-monitoring</font><font color="#F3E651">.</font><font color="#ff0000">yaml</font>
<font color="#ff0000">$ kubectl apply -f root-services</font><font color="#F3E651">.</font><font color="#ff0000">yaml</font>
<font color="#ff0000">$ kubectl apply -f root-infra</font><font color="#F3E651">.</font><font color="#ff0000">yaml</font>
</pre>
<br />
<h3 style='display: inline' id='4-argocd-image-updater'>4. ArgoCD Image Updater</h3><br />
<br />
<span>For applications with custom Docker images (like the registry, tracing-demo), ArgoCD Image Updater can automatically update the image tag in Git when a new image is pushed:</span><br />
<br />
<pre>
metadata:
  annotations:
    argocd-image-updater.argoproj.io/image-list: |
      app=registry.f3s.buetow.org/miniflux:~^v
    argocd-image-updater.argoproj.io/write-back-method: git
</pre>
<br />
<span>When a new image <span class='inlinecode'>registry.f3s.buetow.org/miniflux:v2.1.0</span> is pushed, Image Updater automatically:</span><br />
<span>1. Updates the Helm values in Git</span><br />
<span>2. Commits the change</span><br />
<span>3. ArgoCD syncs the new image</span><br />
<br />
<span>This creates a fully automated CI/CD pipeline.</span><br />
<br />
<h2 style='display: inline' id='summary'>Summary</h2><br />
<br />
<span>Migrating from imperative Helm deployments to declarative GitOps with ArgoCD transformed how I manage the f3s cluster:</span><br />
<br />
<span>**Before**:</span><br />
<ul>
<li>Manual Helm commands for every change</li>
<li>No visibility into cluster state</li>
<li>Difficult to track what changed and when</li>
<li>Disaster recovery required rebuilding from memory/notes</li>
</ul><br />
<span>**After**:</span><br />
<ul>
<li>Git is the single source of truth</li>
<li>Automatic synchronization of changes</li>
<li>Complete audit trail in Git history</li>
<li>Drift detection and self-healing</li>
<li>Disaster recovery: deploy ArgoCD, apply Application manifests, done</li>
<li>Organized by namespace for clarity</li>
</ul><br />
<span>The migration took several days spread over a few weeks, migrating one application at a time. The result is a more maintainable, reliable, and recoverable cluster.</span><br />
<br />
<span>All 21 applications are now managed via GitOps, with the configuration living in:</span><br />
<br />
<a class='textlink' href='https://codeberg.org/snonux/conf/src/branch/master/f3s'>codeberg.org/snonux/conf/f3s</a><br />
<br />
<span>The ArgoCD Application manifests are organized by namespace:</span><br />
<br />
<a class='textlink' href='https://codeberg.org/snonux/conf/src/branch/master/f3s/argocd-apps'>codeberg.org/snonux/conf/f3s/argocd-apps</a><br />
<br />
<span>ArgoCD has become an essential part of the f3s infrastructure, and I can&#39;t imagine managing the cluster without it.</span><br />
<br />
<span>Other *BSD-related posts:</span><br />
<br />
<a class='textlink' href='./2025-12-07-f3s-kubernetes-with-freebsd-part-8.html'>2025-12-07 f3s: Kubernetes with FreeBSD - Part 8: Observability</a><br />
<a class='textlink' href='./2025-10-02-f3s-kubernetes-with-freebsd-part-7.html'>2025-10-02 f3s: Kubernetes with FreeBSD - Part 7: k3s and first pod deployments</a><br />
<a class='textlink' href='./2025-07-14-f3s-kubernetes-with-freebsd-part-6.html'>2025-07-14 f3s: Kubernetes with FreeBSD - Part 6: Storage</a><br />
<a class='textlink' href='./2025-05-11-f3s-kubernetes-with-freebsd-part-5.html'>2025-05-11 f3s: Kubernetes with FreeBSD - Part 5: WireGuard mesh network</a><br />
<a class='textlink' href='./2025-04-05-f3s-kubernetes-with-freebsd-part-4.html'>2025-04-05 f3s: Kubernetes with FreeBSD - Part 4: Rocky Linux Bhyve VMs</a><br />
<a class='textlink' href='./2025-02-01-f3s-kubernetes-with-freebsd-part-3.html'>2025-02-01 f3s: Kubernetes with FreeBSD - Part 3: Protecting from power cuts</a><br />
<a class='textlink' href='./2024-12-03-f3s-kubernetes-with-freebsd-part-2.html'>2024-12-03 f3s: Kubernetes with FreeBSD - Part 2: Hardware and base installation</a><br />
<a class='textlink' href='./2024-11-17-f3s-kubernetes-with-freebsd-part-1.html'>2024-11-17 f3s: Kubernetes with FreeBSD - Part 1: Setting the stage</a><br />
<a class='textlink' href='./2024-04-01-KISS-high-availability-with-OpenBSD.html'>2024-04-01 KISS high-availability with OpenBSD</a><br />
<a class='textlink' href='./2024-01-13-one-reason-why-i-love-openbsd.html'>2024-01-13 One reason why I love OpenBSD</a><br />
<a class='textlink' href='./2022-10-30-installing-dtail-on-openbsd.html'>2022-10-30 Installing DTail on OpenBSD</a><br />
<a class='textlink' href='./2022-07-30-lets-encrypt-with-openbsd-and-rex.html'>2022-07-30 Let&#39;s Encrypt with OpenBSD and Rex</a><br />
<a class='textlink' href='./2016-04-09-jails-and-zfs-on-freebsd-with-puppet.html'>2016-04-09 Jails and ZFS with Puppet on FreeBSD</a><br />
<br />
<span>E-Mail your comments to <span class='inlinecode'>paul@nospam.buetow.org</span></span><br />
<br />
<a class='textlink' href='../'>Back to the main site</a><br />
<p class="footer">
    Generated with <a href="https://codeberg.org/snonux/gemtexter">Gemtexter 3.0.1-develop</a> |
    served by <a href="https://www.OpenBSD.org">OpenBSD</a>/<a href="https://man.openbsd.org/relayd.8">relayd(8)</a>+<a href="https://man.openbsd.org/httpd.8">httpd(8)</a> |
    <a href="https://foo.zone/site-mirrors.html">Site Mirrors</a>
    <br />
    Webring: <a href="https://shring.sh/foo.zone/previous">previous</a> | <a href="https://shring.sh">shring</a> | <a href="https://shring.sh/foo.zone/next">next</a>
</p>
<script type="text/javascript" src="../retrofuturistic.js"></script>
</body>
</html>