Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
1757 lines (1670 loc) · 73.6 KB
/
Copy pathMakefile
File metadata and controls
1757 lines (1670 loc) · 73.6 KB
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
# Copyright IBM Corp. 2026
# SPDX-License-Identifier: MPL-2.0
# Auto-load .env if present (strips 'export ' prefix for Make compatibility)
ifneq (,$(wildcard .env))
$(shell sed 's/^export //; /^[[:space:]]*#/d; /^$$/d' .env > .env.make)
include .env.make
export
endif
# Always export the Kubernetes version matrix selection to recipe sub-shells,
# even when no .env file is present (e.g. `make k8s-matrix-test K8S_MATRIX_VERSIONS=...`).
export K8S_MATRIX_VERSIONS
# ================================
# PHONY Declarations
# ================================
.PHONY: help format deps clean lint test unit-test worker-config
.PHONY: setup-helm setup-kubeconform setup-trivy setup-kubescape setup-helm-unittest lint-helm-k8s trivy-scan kubescape-scan
.PHONY: acceptance-setup acceptance-cluster acceptance-helm acceptance-test acceptance-full acceptance-cleanup acceptance-all
.PHONY: k8s-matrix-test k8s-matrix-cleanup
.PHONY: openshift-smoke-test openshift-helm openshift-acceptance-test openshift-acceptance-full openshift-acceptance-cleanup
.PHONY: crc-setup crc-helm crc-test crc-full crc-cleanup
.PHONY: microshift-setup microshift-helm microshift-test microshift-full microshift-cleanup
.PHONY: eks-setup eks-helm eks-test eks-full eks-cleanup
.PHONY: tf-setup tf-destroy tf-output tf-plan
.PHONY: aks-setup aks-helm aks-test aks-full aks-cleanup
.PHONY: tf-setup-aks tf-plan-aks tf-destroy-aks tf-output-aks
.PHONY: gke-setup gke-helm gke-test gke-full gke-cleanup
.PHONY: tf-setup-gke tf-plan-gke tf-destroy-gke tf-output-gke
# ================================
# Help Target
# ================================
help:
@echo "================================"
@echo "Boundary Worker Helm Chart - Lint Targets"
@echo "================================"
@echo "Available targets:"
@echo " make format - Format all YAML files with Prettier"
@echo " make deps - Install required tools (macOS)"
@echo " make lint - Run all lints and scans locally (deps + lint + scans)"
@echo " make test - Run unit tests (alias for unit-test)"
@echo " make unit-test - Run Helm unit tests with helm-unittest"
@echo " make clean - Clean generated files"
@echo " make worker-config - Authenticate, create a worker, and generate worker.hcl"
@echo ""
@echo "CI/CD targets:"
@echo " make setup-helm - Install Helm for CI"
@echo " make setup-helm-unittest - Install helm-unittest plugin for CI"
@echo " make setup-kubeconform - Install Kubeconform for CI"
@echo " make setup-trivy - Install Trivy for CI"
@echo " make setup-kubescape - Install Kubescape for CI"
@echo " make lint-helm-k8s - Run Helm lint, render templates, and K8s validation"
@echo " make trivy-scan - Run security scan with Trivy"
@echo " make kubescape-scan - Run security scan with Kubescape"
@echo ""
@echo "Acceptance Testing targets:"
@echo " make acceptance-setup - Install dependencies and setup KIND cluster"
@echo " make acceptance-helm - Install Helm chart from worker.hcl and run Helm tests"
@echo " make acceptance-test - Run acceptance tests"
@echo " make acceptance-full - Run full acceptance workflow (setup + worker-config + helm + tests)"
@echo " make acceptance-cleanup - Delete acceptance cluster"
@echo " make acceptance-all - Run BOTH Kubernetes (KIND) and OpenShift (CRC) acceptance tests"
@echo " make k8s-matrix-test - Run tcp-target-conn-test.sh across kindest/node K8s versions (set K8S_MATRIX_VERSIONS or K8S_VERSIONS)"
@echo " make k8s-matrix-cleanup - Delete the acceptance cluster and generated worker config"
@echo ""
@echo "OpenShift Acceptance Testing targets:"
@echo " make openshift-smoke-test - Run OpenShift cluster + chart smoke test (standalone: installs+verifies+cleans up)"
@echo " make openshift-helm - Install Helm chart on an OpenShift cluster (tests/acceptance/values.openshift.yaml)"
@echo " make openshift-acceptance-test - Run full OpenShift acceptance test suite (chart must already be deployed)"
@echo " make openshift-acceptance-full - Full OpenShift workflow (worker-config + openshift-helm + tests)"
@echo " make openshift-acceptance-cleanup - Uninstall Helm release from OpenShift"
@echo ""
@echo "OpenShift Local (CRC) Acceptance Testing targets:"
@echo " make crc-setup - Start CRC cluster and configure oc context"
@echo " make crc-helm - Install Helm chart on CRC with tests/acceptance/values.openshift.yaml"
@echo " make crc-test - Run full OpenShift acceptance suite against CRC"
@echo " make crc-full - Full CRC workflow (crc-setup + worker-config + crc-helm + crc-test)"
@echo " make crc-cleanup - Uninstall Helm release and stop CRC cluster"
@echo ""
@echo "OpenShift MicroShift (CI) Acceptance Testing targets:"
@echo " make microshift-setup - Start MicroShift AIO cluster in Docker (no external cluster needed)"
@echo " make microshift-helm - Install Helm chart on MicroShift with tests/acceptance/values.openshift.yaml"
@echo " make microshift-test - Run full OpenShift acceptance suite against MicroShift"
@echo " make microshift-full - Full MicroShift workflow (setup + worker-config + helm + test)"
@echo " make microshift-cleanup - Remove MicroShift container and cleanup"
@echo ""
@echo "AWS EKS Acceptance Testing targets (shell-based, legacy):"
@echo " make eks-setup - Provision EKS cluster via Terraform (tf-setup)"
@echo " make eks-helm - Install Helm chart with EKS values (gp3, NLB)"
@echo " make eks-test - Run full EKS acceptance test suite"
@echo " make eks-full - Full EKS workflow (eks-setup + worker-config + helm + test)"
@echo " make eks-cleanup - Uninstall Helm release from EKS (set DESTROY_CLUSTER=true to delete cluster)"
@echo ""
@echo "Terraform EKS targets (recommended):"
@echo " make tf-setup - terraform init + apply (VPC + EKS + EBS CSI + LBC)"
@echo " make tf-plan - terraform plan (preview changes without applying)"
@echo " make tf-destroy - terraform destroy (tear down ALL AWS resources cleanly)"
@echo " make tf-output - Show terraform outputs (cluster name, kubeconfig cmd, etc.)"
@echo ""
@echo "Azure AKS Integration Testing targets:"
@echo " make aks-setup - Provision AKS cluster via Terraform (tf-setup-aks)"
@echo " make aks-helm - Install Helm chart with AKS values (managed-csi-premium, LoadBalancer)"
@echo " make aks-test - Run full AKS integration test suite"
@echo " make aks-full - Full AKS workflow (aks-setup + worker-config + helm + test)"
@echo " make aks-cleanup - Uninstall Helm release from AKS (set DESTROY_CLUSTER=true to delete cluster)"
@echo ""
@echo "Terraform AKS targets:"
@echo " make tf-setup-aks - terraform init + apply (VNet + AKS + StorageClass)"
@echo " make tf-plan-aks - terraform plan (preview changes without applying)"
@echo " make tf-destroy-aks - terraform destroy (tear down ALL Azure resources cleanly)"
@echo " make tf-output-aks - Show terraform outputs (cluster name, kubeconfig cmd, etc.)"
@echo ""
@echo "GCP GKE Integration Testing targets:"
@echo " make gke-setup - Provision GKE cluster via Terraform (tf-setup-gke)"
@echo " make gke-helm - Install Helm chart with GKE values (standard-rwo, LoadBalancer)"
@echo " make gke-test - Run full GKE integration test suite"
@echo " make gke-full - Full GKE workflow (gke-setup + worker-config + helm + test)"
@echo " make gke-cleanup - Uninstall Helm release from GKE (set DESTROY_CLUSTER=true to delete cluster)"
@echo ""
@echo "Terraform GKE targets:"
@echo " make tf-setup-gke - terraform init + apply (GKE cluster + node pool)"
@echo " make tf-plan-gke - terraform plan (preview changes without applying)"
@echo " make tf-destroy-gke - terraform destroy (tear down ALL GCP resources cleanly)"
@echo " make tf-output-gke - Show terraform outputs (cluster name, etc.)"
@echo "================================"
# ================================
# Local Development Targets
# ================================
deps:
@echo "Installing required tools..."
@command -v helm >/dev/null 2>&1 || brew install helm
@command -v kubeconform >/dev/null 2>&1 || brew install kubeconform
@command -v yamllint >/dev/null 2>&1 || brew install yamllint
@command -v trivy >/dev/null 2>&1 || brew install trivy
@command -v kubescape >/dev/null 2>&1 || brew install kubescape
@command -v prettier >/dev/null 2>&1 || npm install -g prettier
@helm plugin list | grep -q unittest || helm plugin install https://github.com/helm-unittest/helm-unittest.git
@echo "✅ All tools installed"
format:
@echo "================================"
@echo "Formatting YAML files with Prettier"
@echo "================================"
@if ! command -v prettier >/dev/null 2>&1; then \
echo "❌ Prettier not found. Install with: npm install -g prettier"; \
exit 1; \
fi
@echo "Formatting YAML files..."
@prettier --write "**/*.{yaml,yml}" \
--ignore-path .gitignore \
--print-width 80 \
--tab-width 2 \
--prose-wrap preserve
@echo "✅ All YAML files formatted"
@echo ""
clean:
@echo "Cleaning generated files..."
@rm -f rendered.yaml yamllint-output.txt trivy-output.txt kubescape-output.json
@echo "✅ Clean complete"
lint: deps
@echo "================================"
@echo "Running All Lints and Scans"
@echo "================================"
@echo ""
@$(MAKE) lint-helm-k8s
@echo ""
@$(MAKE) trivy-scan
@echo ""
@$(MAKE) kubescape-scan
@echo ""
@echo "================================"
@echo "✅ All lints and scans completed successfully!"
@echo "================================"
# ================================
# Unit Testing Targets
# ================================
test: unit-test
unit-test:
@echo "================================"
@echo "Running Helm Unit Tests"
@echo "================================"
@if ! helm plugin list | grep -q unittest; then \
echo "❌ helm-unittest plugin not found. Installing..."; \
helm plugin install https://github.com/helm-unittest/helm-unittest.git; \
fi
@echo "Running unit tests..."
@helm unittest . -f 'tests/unit/*_test.yaml'
@echo "✅ Unit tests passed!"
# ================================
# CI/CD Setup Targets
# ================================
setup-helm-unittest:
@echo "Installing helm-unittest plugin..."
@helm plugin install https://github.com/helm-unittest/helm-unittest.git || true
@helm plugin list | grep unittest
@echo "✅ helm-unittest plugin installed"
setup-helm:
@echo "Installing Helm..."
@curl -fsSL -o /tmp/get-helm-3.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
@chmod +x /tmp/get-helm-3.sh
@/tmp/get-helm-3.sh
@helm version
@echo "✅ Helm installed"
setup-kubeconform:
@echo "Installing Kubeconform..."
@curl -fsSL -o /tmp/kubeconform.tar.gz https://github.com/yannh/kubeconform/releases/latest/download/kubeconform-linux-amd64.tar.gz
@tar -xzf /tmp/kubeconform.tar.gz -C /tmp
@sudo mv /tmp/kubeconform /usr/local/bin/
@kubeconform -v
@echo "✅ Kubeconform installed"
setup-trivy:
@echo "Installing Trivy..."
@sudo apt-get install -y wget apt-transport-https gnupg lsb-release
@wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -
@echo "deb https://aquasecurity.github.io/trivy-repo/deb $$(lsb_release -sc) main" | sudo tee -a /etc/apt/sources.list.d/trivy.list
@sudo apt-get update
@sudo apt-get install -y trivy
@trivy --version
@echo "✅ Trivy installed"
setup-kubescape:
@echo "Installing Kubescape..."
@curl -fsSL -o /tmp/kubescape-install.sh https://raw.githubusercontent.com/kubescape/kubescape/master/install.sh
@chmod +x /tmp/kubescape-install.sh
@/tmp/kubescape-install.sh
@export PATH=$$PATH:$$HOME/.kubescape/bin && \
sudo cp $$HOME/.kubescape/bin/kubescape /usr/local/bin/ && \
kubescape version
@echo "✅ Kubescape installed"
# ================================
# CI/CD Lint & Scan Targets
# ================================
lint-helm-k8s:
@echo "================================"
@echo "Running Helm Lint"
@echo "================================"
helm lint .
@echo "✅ Helm lint passed!"
@echo ""
@echo "================================"
@echo "Rendering Helm Templates"
@echo "================================"
helm template boundary-worker . > rendered.yaml
@echo "✅ Templates rendered successfully!"
@echo "Rendered file size: $$(wc -l < rendered.yaml) lines"
@echo ""
@echo "================================"
@echo "Running Kubernetes Validation"
@echo "================================"
kubeconform -strict rendered.yaml
@echo "✅ Kubernetes validation passed!"
trivy-scan:
@echo "================================"
@echo "Running Security Scan with Trivy"
@echo "================================"
@trivy config rendered.yaml --exit-code 0 2>&1 | tee trivy-output.txt
@CRITICAL_COUNT=$$(grep -E 'CRITICAL: [0-9]+' trivy-output.txt | sed -E 's/.*CRITICAL: ([0-9]+).*/\1/' | head -1); \
HIGH_COUNT=$$(grep -E 'HIGH: [0-9]+' trivy-output.txt | sed -E 's/.*HIGH: ([0-9]+).*/\1/' | head -1); \
MEDIUM_COUNT=$$(grep -E 'MEDIUM: [0-9]+' trivy-output.txt | sed -E 's/.*MEDIUM: ([0-9]+).*/\1/' | head -1); \
LOW_COUNT=$$(grep -E 'LOW: [0-9]+' trivy-output.txt | sed -E 's/.*LOW: ([0-9]+).*/\1/' | head -1); \
CRITICAL_COUNT=$${CRITICAL_COUNT:-0}; \
HIGH_COUNT=$${HIGH_COUNT:-0}; \
MEDIUM_COUNT=$${MEDIUM_COUNT:-0}; \
LOW_COUNT=$${LOW_COUNT:-0}; \
echo ""; \
echo "Security Scan Results:"; \
echo " CRITICAL: $$CRITICAL_COUNT"; \
echo " HIGH: $$HIGH_COUNT"; \
echo " MEDIUM: $$MEDIUM_COUNT"; \
echo " LOW: $$LOW_COUNT"; \
echo ""; \
if [ $$CRITICAL_COUNT -gt 0 ] || [ $$HIGH_COUNT -gt 0 ]; then \
echo "❌ Security scan FAILED: $$CRITICAL_COUNT CRITICAL, $$HIGH_COUNT HIGH issues"; \
exit 1; \
elif [ $$MEDIUM_COUNT -gt 0 ] || [ $$LOW_COUNT -gt 0 ]; then \
echo "⚠️ Security scan completed with warnings: $$MEDIUM_COUNT MEDIUM, $$LOW_COUNT LOW issues"; \
else \
echo "✅ Security scan passed!"; \
fi
kubescape-scan:
@echo "================================"
@echo "Running Security Scan with Kubescape"
@echo "================================"
@kubescape scan rendered.yaml \
--format json \
--output kubescape-output.json \
--exceptions ./kubescape-exceptions.json \
--verbose; KUBESCAPE_EXIT=$$?; \
if [ $$KUBESCAPE_EXIT -ne 0 ] && [ ! -f kubescape-output.json ]; then \
echo "❌ Kubescape failed to run (exit code: $$KUBESCAPE_EXIT)"; \
exit $$KUBESCAPE_EXIT; \
fi
@echo ""
@echo "================================"
@echo "Kubescape Scan Results"
@echo "================================"
@if [ -f kubescape-output.json ]; then \
if command -v jq >/dev/null 2>&1; then \
COMPLIANCE_SCORE=$$(jq -r '.summaryDetails.complianceScore // 0' kubescape-output.json); \
PASSED_RESOURCES=$$(jq -r '.summaryDetails.ResourceCounters.passedResources // 0' kubescape-output.json); \
FAILED_CONTROLS=$$(jq '[.summaryDetails.controls[] | select(.failedResources != null and .failedResources > 0)] | length' kubescape-output.json); \
else \
echo "⚠️ jq not found, using grep fallback (less reliable)"; \
COMPLIANCE_SCORE="N/A"; \
PASSED_RESOURCES=$$(grep -o '"passedResources":[0-9]*' kubescape-output.json | head -1 | cut -d':' -f2 || echo "0"); \
FAILED_CONTROLS=0; \
fi; \
echo " Compliance Score: $$COMPLIANCE_SCORE%"; \
echo " Passed Resources: $$PASSED_RESOURCES"; \
echo " Failed Controls: $$FAILED_CONTROLS"; \
echo ""; \
if [ "$$FAILED_CONTROLS" -gt 0 ]; then \
echo "❌ Kubescape scan FAILED: $$FAILED_CONTROLS control(s) have failed resources"; \
exit 1; \
else \
echo "✅ Kubescape scan passed! All controls passed (compliance: $$COMPLIANCE_SCORE%)"; \
fi; \
else \
echo "⚠️ Kubescape output file not found"; \
fi
# ================================
# Acceptance Testing Targets
# ================================
acceptance-setup:
@echo "================================"
@echo "Setting up Acceptance Environment"
@echo "================================"
@echo ""
@echo "Checking dependencies..."
@# Check for kubectl
@if ! command -v kubectl >/dev/null 2>&1; then \
echo "❌ kubectl is not installed"; \
echo "Please install kubectl: https://kubernetes.io/docs/tasks/tools/"; \
exit 1; \
fi
@echo "✅ kubectl is installed ($$(kubectl version --client --short 2>/dev/null || kubectl version --client))"
@# Check for kind
@if ! command -v kind >/dev/null 2>&1; then \
echo "❌ kind is not installed"; \
echo "Installing kind..."; \
if [ "$$(uname)" = "Darwin" ]; then \
brew install kind; \
else \
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64; \
chmod +x ./kind; \
sudo mv ./kind /usr/local/bin/kind; \
fi; \
fi
@echo "✅ kind is installed ($$(kind version))"
@# Check for helm
@if ! command -v helm >/dev/null 2>&1; then \
echo "❌ helm is not installed"; \
echo "Installing helm..."; \
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash; \
fi
@echo "✅ helm is installed ($$(helm version --short 2>/dev/null || helm version))"
@# Check for boundary CLI
@if ! command -v boundary >/dev/null 2>&1; then \
echo "⚠️ boundary CLI is not installed"; \
echo "Installing boundary CLI..."; \
ENV=$$(uname); \
if [ "$$ENV" = "Darwin" ]; then \
brew tap hashicorp/tap && brew install hashicorp/tap/boundary; \
elif [ "$$ENV" = "Linux" ]; then \
echo "Installing boundary CLI from HashiCorp APT repository..."; \
wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg; \
echo "deb [arch=$$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $$(grep -oP '(?<=UBUNTU_CODENAME=).*' /etc/os-release || lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list; \
sudo apt update && sudo apt install -y boundary; \
else \
echo "❌ Failed to install Boundary"; \
exit 1; \
fi; \
fi
@echo "✅ boundary CLI is installed ($$(boundary version 2>/dev/null | head -n1 || echo 'version unknown'))"
@echo ""
@echo "Setting up KIND cluster..."
@if kind get clusters | grep -q "^acceptance$$"; then \
echo "⚠️ Acceptance cluster already exists"; \
else \
kind create cluster --config tests/acceptance/kind-acceptance-config.yaml; \
echo "✅ Acceptance cluster created"; \
fi
@echo ""
@echo "Verifying cluster..."
@kubectl cluster-info --context kind-acceptance
@echo "✅ Cluster is ready"
@echo ""
@echo "Installed tools:"
@echo " - kubectl: $$(kubectl version --client --short 2>/dev/null | head -n1 || echo 'installed')"
@echo " - kind: $$(kind version)"
@echo " - helm: $$(helm version --short 2>/dev/null | head -n1 || echo 'installed')"
@echo " - boundary: $$(boundary version 2>/dev/null | head -n1 || echo 'installed')"
@echo ""
@echo "Next steps:"
@echo " - Generate worker config: make worker-config"
@echo " - Install Helm chart and run Helm tests: make acceptance-helm"
@echo " - Run tests: make acceptance-test"
@echo " - Full workflow: make acceptance-full"
@echo " - Cleanup: make acceptance-cleanup"
worker-config:
@echo "================================"
@echo "Generating Worker Configuration"
@echo "================================"
@if [ -z "$$BOUNDARY_ADDR" ]; then \
echo "❌ BOUNDARY_ADDR environment variable is not set"; \
echo ""; \
echo "Please set it to your Boundary controller address:"; \
echo " export BOUNDARY_ADDR=https://your-cluster.boundary.hashicorp.cloud"; \
echo ""; \
exit 1; \
fi
@if [ -z "$$BOUNDARY_LOGIN_NAME" ]; then \
echo "❌ BOUNDARY_LOGIN_NAME environment variable is not set"; \
echo ""; \
echo "Please set it to your Boundary login name:"; \
echo " export BOUNDARY_LOGIN_NAME=admin"; \
echo ""; \
exit 1; \
fi
@if [ -z "$$BOUNDARY_PASSWORD" ]; then \
echo "❌ BOUNDARY_PASSWORD environment variable is not set"; \
echo ""; \
echo "Please set it to your Boundary admin password:"; \
echo " export BOUNDARY_PASSWORD=your-password"; \
echo ""; \
exit 1; \
fi
@if [ -z "$$BOUNDARY_CLUSTER_ID" ]; then \
echo "❌ BOUNDARY_CLUSTER_ID environment variable is not set"; \
echo ""; \
echo "Please set it to your Boundary cluster ID:"; \
echo " export BOUNDARY_CLUSTER_ID=your-cluster-id"; \
echo ""; \
exit 1; \
fi
@echo ""
@echo "Authenticating with Boundary..."
@echo "Boundary Address: $$BOUNDARY_ADDR"
@echo "Login Name: $$BOUNDARY_LOGIN_NAME"
@AUTH_OUT=$$(boundary authenticate password \
-login-name $$BOUNDARY_LOGIN_NAME \
-password env://BOUNDARY_PASSWORD \
-keyring-type=none 2>&1); \
STATUS=$$?; \
if [ $$STATUS -ne 0 ]; then \
echo "❌ Boundary authentication failed"; \
printf '%s\n' "$$AUTH_OUT"; \
exit $$STATUS; \
fi; \
AUTH_TOKEN=$$(printf '%s\n' "$$AUTH_OUT" | awk '/The token is:/ { getline; gsub(/^[[:space:]]+|[[:space:]]+$$/, "", $$0); print $$0; exit }'); \
if [ -z "$$AUTH_TOKEN" ]; then \
echo "❌ Failed to extract auth token from Boundary authenticate output"; \
exit 1; \
fi; \
export AUTH_TOKEN; \
echo "✅ Successfully authenticated with Boundary"; \
echo ""; \
echo "Creating controller-led worker..."; \
TOKEN_OUT=$$(boundary workers create controller-led --token env://AUTH_TOKEN 2>&1); \
STATUS=$$?; \
if [ $$STATUS -ne 0 ]; then \
echo "❌ Failed to create controller-led worker"; \
printf '%s\n' "$$TOKEN_OUT"; \
exit $$STATUS; \
fi; \
ACTIVATION_TOKEN=$$(printf '%s\n' "$$TOKEN_OUT" | awk -F': *' '/Controller-Generated Activation Token:/ { if ($$2 != "") { print $$2; exit } if (getline > 0) { gsub(/^[[:space:]]+|[[:space:]]+$$/, "", $$0); print $$0; exit } }'); \
WORKER_ID=$$(printf '%s\n' "$$TOKEN_OUT" | awk -F': *' '/^ ID:/ { print $$2; exit }'); \
if [ -z "$$ACTIVATION_TOKEN" ]; then \
echo "❌ Failed to extract controller-generated activation token"; \
exit 1; \
fi; \
export ACTIVATION_TOKEN; \
if [ -n "$$WORKER_ID" ]; then \
echo "$$WORKER_ID" > "$${BOUNDARY_WORKER_ID_FILE:-/tmp/boundary-worker-id.txt}"; \
echo "✅ Created worker $$WORKER_ID (id saved for ID-scoped verification & cleanup)"; \
fi; \
echo ""; \
echo "Generating worker configuration from template..."; \
sed -e "s|<activation-token>|$$ACTIVATION_TOKEN|g" -e "s|<cluster-id>|$$BOUNDARY_CLUSTER_ID|g" tests/acceptance/worker-template.hcl > worker.hcl; \
echo "✅ Created worker config"
acceptance-helm:
@echo "============================================"
@echo "Installing Helm Chart in Acceptance Cluster"
@echo "============================================"
@echo ""
@echo "Checking if Helm is installed..."
@command -v helm >/dev/null 2>&1 || (echo "❌ Helm not found. Run 'make acceptance-setup' first"; exit 1)
@if [ ! -f worker.hcl ]; then \
echo "❌ worker.hcl not found. Run 'make worker-config' first"; \
exit 1; \
fi
@echo "✅ Helm is available"
@echo ""
@echo "Installing boundary-worker chart with test values..."
@helm upgrade --install boundary-worker . \
--namespace boundary \
--create-namespace \
--kube-context kind-acceptance \
--set worker.service.proxy.type=NodePort \
--set worker.persistence.recording.enabled=true \
--set worker.persistence.recording.storageClass=standard \
--set worker.persistence.authStorage.enabled=true \
--set worker.persistence.authStorage.storageClass=standard \
--set tls.ops.disabled=true \
--set-file worker.config=worker.hcl \
--timeout 5m
@echo "✅ Helm chart installed successfully"
@echo ""
@echo "Deployed resources:"
@kubectl get all -n boundary --context kind-acceptance
@echo ""
@echo "Waiting for deployment to be ready..."
@kubectl wait --for=condition=available --timeout=5m \
deployment/boundary-worker-deployment \
-n boundary \
--context kind-acceptance
@echo "✅ Deployment is ready"
@echo ""
@echo "Running Helm Tests..."
@echo ""
@echo "Cleaning up stale test pods..."
@kubectl delete pods -n boundary --context kind-acceptance \
-l app.kubernetes.io/component=test \
--field-selector=status.phase=Failed \
--ignore-not-found 2>/dev/null || true
@echo "Running Helm test pods in boundary namespace..."
@helm test boundary-worker \
--namespace boundary \
--kube-context kind-acceptance \
--timeout 10m || true
@echo ""
@echo "Checking test results (controller-connection excluded)..."
@FAILED=$$(kubectl get pods -n boundary --context kind-acceptance \
-l app.kubernetes.io/component=test \
--field-selector=status.phase=Failed \
-o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' 2>/dev/null \
| grep -v "controller-connection" || true); \
if [ -n "$$FAILED" ]; then \
echo "❌ Helm tests failed:"; \
echo "$$FAILED"; \
exit 1; \
fi
@echo "✅ Helm tests passed (controller-connection test excluded)"
@echo ""
@echo "Note: Test pod logs are not displayed as pods are deleted after completion."
@echo "To view logs during test execution, run: kubectl logs -n boundary -l app.kubernetes.io/component=test --follow"
acceptance-test:
@bash tests/acceptance/cluster-smoke-test.sh
@bash tests/acceptance/tcp-target-conn-test.sh
@bash tests/acceptance/cleanup-worker.sh
@echo "✅ All acceptance tests passed!"
@echo ""
# ================================
# OpenShift Acceptance Testing Targets
# ================================
openshift-smoke-test:
@echo "================================"
@echo "OpenShift Worker Chart Smoke Test"
@echo "================================"
@echo ""
@command -v oc >/dev/null 2>&1 || (echo "❌ oc CLI not found. Run: oc login <cluster-url>"; exit 1)
@if [ ! -f worker.hcl ]; then \
echo "❌ worker.hcl not found. Run 'make worker-config' first"; \
exit 1; \
fi
@bash tests/acceptance/openshift-smoke-test.sh
openshift-helm:
@echo "============================================"
@echo "Installing Helm Chart on OpenShift"
@echo "============================================"
@echo ""
@command -v helm >/dev/null 2>&1 || (echo "❌ Helm not found"; exit 1)
@[ -f worker.hcl ] || { echo "❌ worker.hcl not found. Run 'make worker-config' first"; exit 1; }
@echo "Installing boundary-worker chart with tests/acceptance/values.openshift.yaml..."
@EXTRA_ARGS=""; \
if [ -n "$${OCP_STORAGE_CLASS:-}" ]; then \
EXTRA_ARGS="$$EXTRA_ARGS --set worker.persistence.recording.storageClass=$${OCP_STORAGE_CLASS} --set worker.persistence.authStorage.storageClass=$${OCP_STORAGE_CLASS}"; \
fi; \
if [ -n "$${OCP_MEM_REQUEST:-}" ]; then \
EXTRA_ARGS="$$EXTRA_ARGS --set worker.resources.requests.memory=$${OCP_MEM_REQUEST}"; \
fi; \
if [ -n "$${OCP_CPU_REQUEST:-}" ]; then \
EXTRA_ARGS="$$EXTRA_ARGS --set worker.resources.requests.cpu=$${OCP_CPU_REQUEST}"; \
fi; \
if [ -n "$${OCP_MEM_LIMIT:-}" ]; then \
EXTRA_ARGS="$$EXTRA_ARGS --set worker.resources.limits.memory=$${OCP_MEM_LIMIT}"; \
fi; \
if [ -n "$${OCP_CPU_LIMIT:-}" ]; then \
EXTRA_ARGS="$$EXTRA_ARGS --set worker.resources.limits.cpu=$${OCP_CPU_LIMIT}"; \
fi; \
helm upgrade --install boundary-worker . \
--namespace boundary \
--create-namespace \
-f tests/acceptance/values.openshift.yaml \
--set-file worker.config=worker.hcl \
--wait \
--timeout 5m \
$$EXTRA_ARGS
@echo "✅ Helm chart installed on OpenShift"
@echo ""
@oc get all -n boundary
openshift-acceptance-test:
@echo "================================"
@echo "OpenShift Acceptance Test Suite"
@echo "================================"
@echo ""
@command -v oc >/dev/null 2>&1 || (echo "❌ oc CLI not found. Run: oc login <cluster-url>"; exit 1)
@SKIP_HELM_INSTALL=true bash tests/acceptance/openshift-smoke-test.sh
@bash tests/acceptance/openshift-tcp-target-conn-test.sh
@bash tests/acceptance/cleanup-worker.sh
@echo "✅ All OpenShift acceptance tests passed!"
@echo ""
openshift-acceptance-full:
@echo "================================"
@echo "Running Full OpenShift Acceptance Workflow"
@echo "================================"
@echo ""
@$(MAKE) worker-config
@$(MAKE) openshift-helm
@$(MAKE) openshift-acceptance-test
@echo ""
@echo "To cleanup, run: make openshift-acceptance-cleanup"
@echo ""
openshift-acceptance-cleanup:
@echo "================================"
@echo "Cleaning up OpenShift Acceptance"
@echo "================================"
@echo "Cleaning up worker from Boundary cluster..."
@bash tests/acceptance/cleanup-worker.sh || true
@echo ""
@echo "Uninstalling Helm release..."
@helm uninstall boundary-worker --namespace boundary 2>/dev/null && echo "✅ Helm release uninstalled" || echo "⚠️ Helm release not found"
@rm -f worker.hcl
@rm -f /tmp/boundary-worker-id.txt
@echo "✅ OpenShift acceptance cleanup complete"
# ================================
# OpenShift Local (CRC) Targets
# ================================
# Run acceptance tests against a local OpenShift cluster using CRC (OpenShift Local).
# Requires CRC installed and running on your machine: https://developers.redhat.com/products/openshift-local
#
# Usage:
# make crc-full – full workflow (setup → worker-config → install → test)
# make crc-setup – start CRC and configure oc context
# make crc-helm – install the Helm chart on CRC
# make crc-test – run the OpenShift acceptance suite against CRC
# make crc-cleanup – uninstall and stop CRC
# ================================
crc-setup:
@echo "================================"
@echo "Setting up CRC (OpenShift Local)"
@echo "================================"
@echo ""
@command -v crc >/dev/null 2>&1 || (echo "❌ crc not installed. Download from: https://developers.redhat.com/products/openshift-local"; exit 1)
@command -v oc >/dev/null 2>&1 || (echo "❌ oc CLI not found. Run: eval $$(crc oc-env)"; exit 1)
@echo "✅ crc and oc are installed"
@echo ""
@echo "Starting CRC cluster (this may take several minutes)..."
@crc start
@echo ""
@echo "Configuring oc context..."
@eval $$(crc oc-env) && \
KUBEADMIN_PASS=$$(crc console --credentials 2>/dev/null | grep 'kubeadmin' | sed 's/.*-p \([^ ]*\) .*/\1/') && \
oc login -u kubeadmin -p "$$KUBEADMIN_PASS" \
--insecure-skip-tls-verify=true \
https://api.crc.testing:6443
@oc cluster-info
@echo "✅ CRC cluster is ready"
@echo ""
@echo "Next steps:"
@echo " - Generate worker config: make worker-config"
@echo " - Install Helm chart: make crc-helm"
@echo " - Run tests: make crc-test"
@echo " - Full workflow: make crc-full"
crc-helm:
@echo "============================================"
@echo "Installing Helm Chart on CRC"
@echo "============================================"
@echo ""
@command -v helm >/dev/null 2>&1 || (echo "❌ Helm not found"; exit 1)
@if [ ! -f worker.hcl ]; then \
echo "❌ worker.hcl not found. Run 'make worker-config' first"; \
exit 1; \
fi
@echo "Installing boundary-worker chart with tests/acceptance/values.openshift.yaml..."
@helm upgrade --install boundary-worker . \
--namespace boundary \
--create-namespace \
-f tests/acceptance/values.openshift.yaml \
--set worker.persistence.recording.storageClass=crc-csi-hostpath-provisioner \
--set worker.persistence.authStorage.storageClass=crc-csi-hostpath-provisioner \
--set worker.resources.requests.memory=128Mi \
--set worker.resources.requests.cpu=50m \
--set worker.resources.limits.memory=512Mi \
--set worker.resources.limits.cpu=200m \
--set-file worker.config=worker.hcl \
--wait \
--timeout 5m
@echo "✅ Helm chart installed successfully"
@echo ""
@echo "Deployed resources:"
@oc get all -n boundary
@echo ""
@echo "Waiting for deployment to be ready..."
@oc wait --for=condition=available --timeout=5m \
deployment/boundary-worker-deployment \
-n boundary
@echo "✅ Deployment is ready"
crc-test:
@echo "================================"
@echo "CRC OpenShift Acceptance Tests"
@echo "================================"
@echo ""
@command -v oc >/dev/null 2>&1 || (echo "❌ oc CLI not found. Run: eval $$(crc oc-env)"; exit 1)
@SKIP_HELM_INSTALL=true bash tests/acceptance/openshift-smoke-test.sh
@bash tests/acceptance/openshift-tcp-target-conn-test.sh
@bash tests/acceptance/cleanup-worker.sh
@echo "✅ All CRC acceptance tests passed!"
@echo ""
crc-full:
@echo "================================"
@echo "Running Full CRC Workflow"
@echo "================================"
@echo ""
@$(MAKE) crc-setup
@$(MAKE) worker-config
@$(MAKE) crc-helm
@$(MAKE) crc-test
@echo ""
@echo "To cleanup, run: make crc-cleanup"
@echo ""
crc-cleanup:
@echo "================================"
@echo "Cleaning up CRC"
@echo "================================"
@echo "Cleaning up worker from Boundary cluster..."
@bash tests/acceptance/cleanup-worker.sh || true
@echo ""
@echo "Uninstalling Helm release..."
@helm uninstall boundary-worker --namespace boundary 2>/dev/null && echo "✅ Helm release uninstalled" || echo "⚠️ Helm release not found"
@rm -f worker.hcl
@rm -f /tmp/boundary-worker-id.txt
@echo ""
@echo "Stopping CRC cluster..."
@crc stop && echo "✅ CRC cluster stopped" || echo "⚠️ CRC stop failed"
@echo "✅ CRC cleanup complete"
# ================================
# OpenShift MicroShift (CI) Targets
# ================================
# Runs a throwaway MicroShift AIO cluster inside Docker — the same
# pattern KIND uses for Kubernetes acceptance tests.
# No external OCP cluster, CRC, or OCP_SERVER/OCP_TOKEN secrets are needed.
microshift-setup:
@echo "================================"
@echo "Setting up MicroShift (OpenShift CI)"
@echo "================================"
@echo ""
@echo "Checking dependencies..."
@command -v docker >/dev/null 2>&1 || (echo "❌ docker is not installed"; exit 1)
@echo "✅ docker is installed"
@command -v helm >/dev/null 2>&1 || (echo "❌ Helm not found. Run 'make setup-helm' first"; exit 1)
@echo "✅ helm is installed"
@if ! command -v oc >/dev/null 2>&1; then \
echo "Installing oc CLI..."; \
curl -Lo /tmp/oc.tar.gz https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz; \
sudo tar -xzf /tmp/oc.tar.gz -C /usr/local/bin oc; \
rm -f /tmp/oc.tar.gz; \
fi
@echo "✅ oc CLI is installed ($$(oc version --client 2>/dev/null | head -n1))"
@echo ""
@echo "Creating storage loop device and LVM volume group for MicroShift (4 GB)..."
@sudo truncate -s 4G /tmp/microshift-disk.img
@LOOP=$$(sudo losetup --find --show /tmp/microshift-disk.img) && \
echo "$$LOOP" > /tmp/microshift-loop-device && \
echo "✅ Loop device: $$LOOP"
@sudo apt-get install -y --quiet lvm2 2>/dev/null || true
@LOOP_DEV=$$(cat /tmp/microshift-loop-device) && \
sudo pvcreate "$$LOOP_DEV" && \
sudo vgcreate rhel "$$LOOP_DEV" && \
echo "✅ LVM volume group 'rhel' created on $$LOOP_DEV"
@echo "Configuring iptables-legacy (required for MicroShift networking on Ubuntu)..."
@sudo apt-get install -y --quiet iptables 2>/dev/null || true
@sudo update-alternatives --set iptables /usr/sbin/iptables-legacy 2>/dev/null || true
@sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy 2>/dev/null || true
@echo "✅ iptables-legacy configured"
@echo ""
@echo "Configuring CRI-O storage driver (vfs required for overlay-on-overlay CI environments)..."
@printf '[storage]\ndriver = "vfs"\ngraphroot = "/var/lib/containers/storage"\nrunroot = "/run/containers/storage"\n' > /tmp/microshift-storage.conf
@echo "✅ CRI-O storage config created (vfs)"
@echo ""
@# Pinned to MicroShift AIO latest as of 2025-07 — update digest when upgrading
@echo "Starting MicroShift AIO cluster (this may take 3-5 minutes)..."
@HOST_DNS=$$(awk '/^nameserver[[:space:]]/{print $$2; exit}' /run/systemd/resolve/resolv.conf /etc/resolv.conf 2>/dev/null); \
if [ -z "$$HOST_DNS" ] || printf '%s' "$$HOST_DNS" | grep -Eq '^(127\\.|::1$$)'; then HOST_DNS="8.8.8.8"; fi; \
echo "Using MicroShift upstream DNS: $$HOST_DNS"; \
docker run -d \
--name microshift \
--privileged \
--cgroupns=host \
--network host \
--dns "$$HOST_DNS" \
--tmpfs /run \
--tmpfs /tmp \
-v /sys/fs/cgroup:/sys/fs/cgroup:rw \
-v /lib/modules:/lib/modules:ro \
-v /tmp/microshift-storage.conf:/etc/containers/storage.conf:ro \
-v microshift-data:/var/lib/microshift \
quay.io/microshift/microshift-aio@sha256:e5c53f97b43a042e4bdceeccf980bcdf8630ece81cb75f8fd11d7d8564edc832
@echo "Waiting for MicroShift node to be Ready (up to 10 minutes)..."
@i=0; while [ $$i -lt 120 ]; do \
if docker exec microshift kubectl \
--kubeconfig /var/lib/microshift/resources/kubeadmin/kubeconfig \
get nodes --no-headers 2>/dev/null | grep -q ' Ready'; then \
echo "✅ MicroShift node is Ready"; break; \
fi; \
if [ $$(( $$i % 6 )) -eq 0 ]; then \
echo " Container status: $$(docker inspect microshift --format '{{.State.Status}}' 2>/dev/null)"; \
echo " Service status: microshift=$$(docker exec microshift systemctl is-active microshift 2>/dev/null) crio=$$(docker exec microshift systemctl is-active crio 2>/dev/null)"; \
docker exec microshift journalctl -u microshift --no-pager --lines=3 2>/dev/null || true; \
fi; \
echo " waiting... ($$(( $$i * 5 ))s)"; \
sleep 5; i=$$(( $$i + 1 )); \
if [ $$i -eq 120 ]; then \
echo "❌ MicroShift node never became Ready after 10 minutes."; \
echo "--- systemctl status ---"; \
docker exec microshift systemctl status microshift crio --no-pager 2>/dev/null || true; \
echo "--- MicroShift journal ---"; \
docker exec microshift journalctl -u microshift --no-pager --lines=50 2>/dev/null || true; \
echo "--- CRI-O journal ---"; \
docker exec microshift journalctl -u crio --no-pager --lines=30 2>/dev/null || true; \
exit 1; \
fi; \
done
@echo ""
@echo "Configuring kubeconfig..."
@mkdir -p ~/.kube
@docker cp microshift:/var/lib/microshift/resources/kubeadmin/kubeconfig ~/.kube/config
@echo "✅ Kubeconfig configured"
@echo "Waiting for CNI config file in /etc/cni/net.d/..."
@timeout 300 bash -c \
'until docker exec microshift ls /etc/cni/net.d/ 2>/dev/null | grep -qE "\.conf|\.conflist"; do sleep 5; done' \
|| echo "⚠️ CNI config not found; pod networking may not work"
@echo "✅ CNI config file present"
@docker exec microshift ls -la /etc/cni/net.d/ 2>/dev/null || true
@echo "Ensuring pod egress NAT → internet..."
@sudo sysctl -w net.ipv4.ip_forward=1 2>/dev/null || true
@# On Ubuntu 22.04, Docker uses iptables-nft (nftables backend) which runs BEFORE
@# iptables-legacy in the kernel. Docker's FORWARD=DROP lives in nftables, so rules
@# added only to iptables-legacy are silently bypassed. Apply to BOTH backends.
POD_CIDRS=$$(kubectl get nodes -o jsonpath='{range .items[*]}{.spec.podCIDR}{"\n"}{end}' 2>/dev/null | sort -u | tr '\n' ' '); \
[ -n "$$POD_CIDRS" ] || POD_CIDRS="10.42.0.0/16"; \
echo " Pod CIDRs: $$POD_CIDRS"; \
for ipt in iptables iptables-nft; do \
for cidr in $$POD_CIDRS; do \
sudo $$ipt -t nat -C POSTROUTING -s $$cidr ! -d $$cidr -j MASQUERADE 2>/dev/null \
|| sudo $$ipt -t nat -I POSTROUTING 1 -s $$cidr ! -d $$cidr -j MASQUERADE 2>/dev/null \
|| true; \
sudo $$ipt -I FORWARD 1 -s $$cidr -j ACCEPT 2>/dev/null || true; \
sudo $$ipt -I FORWARD 1 -d $$cidr -j ACCEPT 2>/dev/null || true; \
done; \
done
@echo "✅ Pod egress NAT + FORWARD rules applied to both iptables-legacy and iptables-nft"
@echo "Waiting for CoreDNS pods to be Running..."
@timeout 180 bash -c \
'until docker exec microshift kubectl --kubeconfig /var/lib/microshift/resources/kubeadmin/kubeconfig \
get pods -n openshift-dns --no-headers 2>/dev/null | grep "dns-default" | grep -q " Running "; do sleep 5; done' \
|| echo "⚠️ DNS pods not yet Running; continuing"
@echo "✅ DNS pods ready"
@echo "Checking DNS resolution from the MicroShift node..."
@docker exec microshift getent hosts google.com >/dev/null 2>&1 \
&& echo "✅ MicroShift node DNS is working" \
|| echo "⚠️ MicroShift node DNS lookup failed; pod DNS may not resolve external names"
@echo "Waiting for StorageClass topolvm-provisioner..."
@timeout 120 bash -c \
'until kubectl get storageclass topolvm-provisioner >/dev/null 2>&1; do sleep 3; done' \
|| echo "⚠️ topolvm-provisioner not yet available; continuing"
@kubectl cluster-info || true
@echo "✅ MicroShift cluster is ready"
@echo ""
@echo "Next steps:"
@echo " - Generate worker config: make worker-config"
@echo " - Install Helm chart: make microshift-helm"
@echo " - Run tests: make microshift-test"
@echo " - Full workflow: make microshift-full"
microshift-helm:
@echo "============================================"
@echo "Installing Helm Chart on MicroShift"
@echo "============================================"
@echo ""
@command -v helm >/dev/null 2>&1 || (echo "❌ Helm not found"; exit 1)
@[ -f worker.hcl ] || { echo "❌ worker.hcl not found. Run 'make worker-config' first"; exit 1; }
@echo "Injecting Red Hat registry credentials into MicroShift CRI-O..."
@if [ -n "$${RH_REGISTRY_USER:-}" ] && [ -n "$${RH_REGISTRY_TOKEN:-}" ]; then \
AUTH_B64=$$(printf '%s:%s' "$${RH_REGISTRY_USER}" "$${RH_REGISTRY_TOKEN}" | base64 -w0); \
printf '{"auths":{"registry.connect.redhat.com":{"auth":"%s"}}}\n' "$${AUTH_B64}" > /tmp/rh-auth.json; \
docker exec microshift mkdir -p /etc/containers; \
docker cp /tmp/rh-auth.json microshift:/etc/containers/auth.json; \
rm -f /tmp/rh-auth.json; \
echo "✅ CRI-O auth configured for registry.connect.redhat.com"; \
echo "Pre-pulling boundary-enterprise image into CRI-O cache (up to 3 attempts)..."; \
CHART_APP_VERSION=$$(grep '^appVersion:' Chart.yaml | sed 's/appVersion: *//;s/"//g'); \
PULL_IMAGE="registry.connect.redhat.com/hashicorp/boundary-enterprise:$${CHART_APP_VERSION}-ubi"; \
PULL_OK=0; \
for attempt in 1 2 3; do \
echo " attempt $$attempt/3..."; \
if docker exec microshift \
crictl pull \
--creds "$${RH_REGISTRY_USER}:$${RH_REGISTRY_TOKEN}" \
"$$PULL_IMAGE"; then \
PULL_OK=1; break; \
fi; \
echo " pull attempt $$attempt failed, retrying in 10s..."; \
sleep 10; \
done; \
[ "$$PULL_OK" = "1" ] \
&& echo "✅ Image pre-pulled into CRI-O: $$PULL_IMAGE" \
|| { echo "❌ crictl pull failed after 3 attempts — check RH_REGISTRY_USER/RH_REGISTRY_TOKEN"; exit 1; }; \
else \
echo "⚠️ RH_REGISTRY_USER/TOKEN not set — image pull may fail"; \
fi
@echo "Installing boundary-worker chart with tests/acceptance/values.openshift.yaml..."
@helm upgrade --install boundary-worker . \
--namespace boundary \
--create-namespace \
-f tests/acceptance/values.openshift.yaml \
--set worker.persistence.recording.storageClass=topolvm-provisioner \
--set worker.persistence.authStorage.storageClass=topolvm-provisioner \
--set worker.resources.requests.memory=128Mi \
--set worker.resources.requests.cpu=50m \
--set worker.resources.limits.memory=512Mi \
--set worker.resources.limits.cpu=200m \
--set 'openshift.route.proxy.enabled=true' \
--set 'openshift.podSecurityContext.runAsUser=1001' \
--set 'openshift.containerSecurityContext.runAsUser=1001' \
--set-file worker.config=worker.hcl \
--wait \
--timeout 8m \
|| { \
echo "❌ Helm install timed out or failed. Diagnostics:"; \
echo "--- Pod list ---"; \
kubectl get pods -n boundary -o wide 2>/dev/null || true; \
echo "--- Pod events ---"; \
kubectl get events -n boundary --sort-by='.lastTimestamp' 2>/dev/null | tail -20 || true; \
echo "--- Pod describe ---"; \
kubectl describe pods -n boundary 2>/dev/null | tail -40 || true; \
echo "--- CRI-O journal (last 30 lines) ---"; \
docker exec microshift journalctl -u crio --no-pager --lines=30 2>/dev/null || true; \
exit 1; \
}
@echo "✅ Helm chart installed on MicroShift"
@echo ""
@oc get all -n boundary
microshift-test:
@echo "================================"
@echo "MicroShift OpenShift Acceptance Tests"
@echo "================================"
@echo ""
@command -v oc >/dev/null 2>&1 || (echo "❌ oc CLI not found"; exit 1)
@SKIP_HELM_INSTALL=true bash tests/acceptance/openshift-smoke-test.sh