Skip to content

Commit 916790e

Browse files
committed
Update CI and tests for latest fleet versions
Replace deprecated fleet test with fleet apply→target→deploy workflow.This requires a Kubernetes cluster. Add k3d test infrastructure with Fleet CRDs and generated expected output baselines for all 10 examples. The old fleet test -l env=dev/test/prod generated three files even for single-cluster examples. All three were identical (no env-based customizations exist in single-cluster examples). The new pipeline produces only local-output.yaml, which is the actual cluster being targeted.
1 parent 1d1de16 commit 916790e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+54572
-5591
lines changed

.github/workflows/ci-0.5.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

.github/workflows/ci-0.6.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,57 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
fleet_version:
17-
- "v0.8.1"
18-
- "v0.9.0"
17+
- "v0.13.8"
18+
- "latest"
1919

2020
steps:
2121
-
22-
uses: actions/checkout@v3
22+
uses: actions/checkout@v4
2323
with:
2424
fetch-depth: 0
2525
-
26-
uses: actions/cache@v3
26+
name: Resolve Fleet Version
27+
id: resolve-version
28+
run: |
29+
VERSION="${{ matrix.fleet_version }}"
30+
if [ "$VERSION" = "latest" ]; then
31+
VERSION=$(curl -s https://api.github.com/repos/rancher/fleet/releases/latest | jq -r '.tag_name')
32+
fi
33+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
34+
-
35+
uses: actions/cache@v4
2736
id: fleet-cli-cache
2837
with:
2938
path: /home/runner/.local/bin
30-
key: ${{ runner.os }}-fleet-cli-${{ matrix.fleet_version }}
39+
key: ${{ runner.os }}-fleet-cli-${{ steps.resolve-version.outputs.version }}
3140
-
3241
name: Download CLI
3342
if: steps.fleet-cli-cache.outputs.cache-hit != 'true'
3443
run: |
3544
mkdir -p /home/runner/.local/bin
36-
wget -nv "https://github.com/rancher/fleet/releases/download/${{ matrix.fleet_version }}/fleet-linux-amd64"
45+
wget -nv "https://github.com/rancher/fleet/releases/download/${{ steps.resolve-version.outputs.version }}/fleet-linux-amd64"
3746
mv fleet-linux-amd64 /home/runner/.local/bin/fleet
3847
chmod +x /home/runner/.local/bin/fleet
48+
-
49+
name: Set up k3d cluster
50+
run: |
51+
# Install k3d
52+
curl --silent --fail https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=v5.8.3 bash
53+
# Create a minimal cluster (no load balancer needed)
54+
k3d cluster create fleet-test --no-lb --wait --timeout 120s
55+
k3d kubeconfig merge fleet-test --kubeconfig-merge-default
56+
57+
# Install Fleet CRDs for the exact CLI version under test so that
58+
# `kubectl apply` and `fleet target` can use the Cluster CRD.
59+
FLEET_VER="${{ steps.resolve-version.outputs.version }}"
60+
curl -sL "https://github.com/rancher/fleet/releases/download/${FLEET_VER}/fleet-crd-${FLEET_VER#v}.tgz" \
61+
| tar -xz -O fleet-crd/templates/crds.yaml \
62+
| kubectl apply -f -
63+
64+
# Create namespaces and minimal cluster objects for targeting
65+
kubectl create namespace fleet-local
66+
kubectl create namespace fleet-default
67+
kubectl apply -f tests/setup-cluster.yaml
3968
-
4069
name: Test
4170
run: |

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,72 @@ and configure the app differently for each target.
3636

3737
Using downstream clusters with Windows nodes?
3838
Check out the [windows-helm](multi-cluster/windows-helm/) multi-cluster example above.
39+
40+
## Running Tests Locally
41+
42+
The test suite renders every example using the Fleet CLI and compares the output
43+
against committed expected files.
44+
45+
### Prerequisites
46+
47+
- [k3d](https://k3d.io/) v5.8.3 or newer
48+
- `kubectl`
49+
- Fleet CLI — download a release binary from
50+
[fleet releases](https://github.com/rancher/fleet/releases) and put it on
51+
your `PATH`, e.g.:
52+
```bash
53+
FLEET_VERSION=v0.14.3
54+
curl -sL "https://github.com/rancher/fleet/releases/download/${FLEET_VERSION}/fleet-linux-amd64" \
55+
-o ~/.local/bin/fleet && chmod +x ~/.local/bin/fleet
56+
```
57+
58+
### One-time cluster setup
59+
60+
Create a minimal k3d cluster, install Fleet CRDs, and populate the cluster
61+
objects the tests rely on:
62+
63+
```bash
64+
FLEET_VERSION=v0.14.3
65+
66+
# Create cluster
67+
k3d cluster create fleet-test --no-lb --wait --timeout 120s
68+
k3d kubeconfig merge fleet-test --kubeconfig-merge-default
69+
70+
# Install Fleet CRDs (use the same version as your fleet CLI)
71+
curl -sL "https://github.com/rancher/fleet/releases/download/${FLEET_VERSION}/fleet-crd-${FLEET_VERSION#v}.tgz" \
72+
| tar -xz -O fleet-crd/templates/crds.yaml \
73+
| kubectl apply -f -
74+
75+
# Create namespaces and cluster objects
76+
kubectl create namespace fleet-local
77+
kubectl create namespace fleet-default
78+
kubectl apply -f tests/setup-cluster.yaml
79+
```
80+
81+
The cluster can be reused across test runs and deleted afterwards with
82+
`k3d cluster delete fleet-test`.
83+
84+
### Running the tests
85+
86+
```bash
87+
tests/test.sh
88+
```
89+
90+
The script runs `fleet apply`, `fleet target`, and `fleet deploy -d` for each
91+
example and compares the rendered output against the files in `tests/expected/`.
92+
93+
### Updating expected files
94+
95+
When an example or the Fleet CLI changes the rendered output, regenerate the
96+
expected files by running the tests once until they fail on the `diff` step,
97+
then copy the fresh output into `expected/`:
98+
99+
```bash
100+
# Run once — will fail at the diff step but generate the new output
101+
tests/test.sh || true
102+
103+
# Accept the new output as the expected baseline
104+
cp -r tests/output/* tests/expected/
105+
# or selectively: cp tests/output/multi-cluster/kustomize/dev-output.yaml \
106+
# tests/expected/multi-cluster/kustomize/dev-output.yaml
107+
```

tests/expected/multi-cluster/helm-external/bundle.yaml

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ metadata:
66
name: test
77
namespace: fleet-default
88
spec:
9-
correctDrift: {}
109
helm:
1110
chart: https://github.com/rancher/fleet-examples/releases/download/example/guestbook-0.0.1.tgz
12-
ignore: {}
1311
namespace: fleet-mc-helm-external-example
1412
resources:
1513
- content: |
@@ -206,65 +204,29 @@ spec:
206204
env: prod
207205
```
208206
name: README.md
209-
- content: |
210-
namespace: fleet-mc-helm-external-example
211-
helm:
212-
chart: https://github.com/rancher/fleet-examples/releases/download/example/guestbook-0.0.1.tgz
213-
targetCustomizations:
214-
- name: dev
215-
helm:
216-
values:
217-
replication: false
218-
clusterSelector:
219-
matchLabels:
220-
env: dev
221-
222-
- name: test
223-
helm:
224-
values:
225-
replicas: 3
226-
clusterSelector:
227-
matchLabels:
228-
env: test
229-
230-
- name: prod
231-
helm:
232-
values:
233-
serviceType: LoadBalancer
234-
replicas: 3
235-
clusterSelector:
236-
matchLabels:
237-
env: prod
238-
name: fleet.yaml
239207
targets:
240208
- clusterSelector:
241209
matchLabels:
242210
env: dev
243-
correctDrift: {}
244211
helm:
245212
chart: https://github.com/rancher/fleet-examples/releases/download/example/guestbook-0.0.1.tgz
246213
values:
247214
replication: false
248-
ignore: {}
249215
name: dev
250216
- clusterSelector:
251217
matchLabels:
252218
env: test
253-
correctDrift: {}
254219
helm:
255220
chart: https://github.com/rancher/fleet-examples/releases/download/example/guestbook-0.0.1.tgz
256221
values:
257222
replicas: 3
258-
ignore: {}
259223
name: test
260224
- clusterSelector:
261225
matchLabels:
262226
env: prod
263-
correctDrift: {}
264227
helm:
265228
chart: https://github.com/rancher/fleet-examples/releases/download/example/guestbook-0.0.1.tgz
266229
values:
267230
replicas: 3
268231
serviceType: LoadBalancer
269-
ignore: {}
270232
name: prod

0 commit comments

Comments
 (0)