Skip to content

Add dev resources to improve local testing capability #4511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 8 additions & 24 deletions doc/development-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ Then we bring up tilt.

Tilt will tell you the url, or hit the space bar and it'll automagically open a browser for you which will show your local cluster and the resources running. You should see 3 things, Tiltfile, dev-weave-gitops, uncategorised.

Goto login with username: dev, password:dev at http://localhost:9001/sign_in
Goto login with username: dev, password:dev at <http://localhost:9001/sign_in>

When you make changes in the code with this setup, you have to wait for k8s to redeploy the updated pod, it isn't lightening instant fast but **it works** to get you going.

Woop! It's working. It'll be empty cos you haven't created any flux objects. You can jump to [
quickly add a sample workload to UI](#quickly-add-a-sample-workload-to-ui).
Woop! It's working. It'll be empty cos you haven't created any flux objects.
You can jump to [quickly add a sample workload to UI](#quickly-add-a-sample-workload-to-ui).

## Frontend optimised development setup

Expand All @@ -58,7 +58,7 @@ Create a kind cluster. We'll do this so we can have a local cluster on our machi

Then we install flux on it.

`$ flux install`
`$ flux install --components-extra="image-reflector-controller,image-automation-controller"`

Then we bring up tilt, without auto-restart enabled (see [the FAQ
entry below](#the-server-keeps-restarting-and-its-annoying)).
Expand All @@ -73,7 +73,7 @@ Then we fire up our frontend server.

`$ yarn start`

Goto login with username: dev, password:dev at http://localhost:4567/sign_in
Goto login with username: dev, password:dev at <http://localhost:4567/sign_in>

Running this setup is what enables JavaScript hot reloading, it does websocket pushing of your code, so you don't even need to refresh!

Expand All @@ -83,31 +83,15 @@ Woop! It's working. It'll be empty cos you haven't created any flux objects. You

To help see some objects in the UI lets create some sample sources, run the following:

```
$ flux create source git podinfo \
--url=https://github.com/stefanprodan/podinfo \
--branch=master \
--interval=30m
```

and then this one:

```
$ flux create kustomization podinfo \
--target-namespace=flux-system \
--source=podinfo \
--path="./kustomize" \
--prune=true \
--interval=5m
```
`$ k apply -f ./tools/dev-resources`

Boom! You'll see our newly created flux objects in the UI.

We use create rather than a flux bootstrap to create because we don't want our tiltfile and flux to start reconciling over each other.

## Other Frontend focussed commands

Lint frontend code with `make ui-lint` - using Prettier (https://prettier.io/) will get you on the right track!
Lint frontend code with `make ui-lint` - using Prettier (<https://prettier.io/>) will get you on the right track!

Run frontend tests with `make ui-test`

Expand Down Expand Up @@ -157,7 +141,7 @@ Then we bring up tilt, passing it the flag `FAST_AND_FURIOUSER`. This tells our

`$ FAST_AND_FURIOUSER=true tilt up`

Goto login with username: dev, password:dev at http://localhost:9001/sign_in
Goto login with username: dev, password:dev at <http://localhost:9001/sign_in>

Woop! It's working? Probably. Maybe. Or you may need to faff around with resolving build steps when you did `make all`.
Good luck!
Expand Down
7 changes: 7 additions & 0 deletions tools/dev-resources/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# dev-resources

This directory contains quickstart resources to help get going with Weave-GitOps

Apply the contents of this directory to your cluster with

`$ k apply -k .`
4 changes: 4 additions & 0 deletions tools/dev-resources/image-policy/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resources:
- podinfo-image-policy.yaml
- podinfo-image-update-automation.yaml
- podinfo-image-repository.yaml
11 changes: 11 additions & 0 deletions tools/dev-resources/image-policy/podinfo-image-policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: image.toolkit.fluxcd.io/v1beta2
kind: ImagePolicy
metadata:
name: podinfo
namespace: flux-system
spec:
imageRepositoryRef:
name: podinfo
policy:
semver:
range: '^6.0.0'
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: image.toolkit.fluxcd.io/v1beta2
kind: ImageRepository
metadata:
name: podinfo
namespace: flux-system
spec:
image: ghcr.io/stefanprodan/podinfo
interval: 5m
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: image.toolkit.fluxcd.io/v1beta2
kind: ImageUpdateAutomation
metadata:
name: flux-system
namespace: flux-system
spec:
interval: 30m
sourceRef:
kind: GitRepository
name: flux-system
git:
checkout:
ref:
branch: main
commit:
author:
email: [email protected]
name: fluxcdbot
messageTemplate: "{{range .Updated.Images}}{{println .}}{{end}}"
push:
branch: main
update:
path: ./clusters/management
strategy: Setters


4 changes: 4 additions & 0 deletions tools/dev-resources/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resources:
- podinfo
- image-policy
- monitoring
2 changes: 2 additions & 0 deletions tools/dev-resources/monitoring/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
resources:
- monitoring.yaml
61 changes: 61 additions & 0 deletions tools/dev-resources/monitoring/monitoring.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
name: flux-monitoring
namespace: flux-system
spec:
interval: 10m0s
ref:
branch: main
url: https://github.com/fluxcd/flux2-monitoring-example
---
apiVersion: v1
kind: Namespace
metadata:
name: monitoring
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: kube-prometheus-stack
namespace: flux-system
spec:
interval: 10m0s
sourceRef:
kind: GitRepository
name: flux-monitoring
path: ./monitoring/controllers/kube-prometheus-stack
prune: true
targetNamespace: monitoring
wait: true
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: loki-stack
namespace: flux-system
spec:
interval: 10m0s
sourceRef:
kind: GitRepository
name: flux-monitoring
path: ./monitoring/controllers/loki-stack
prune: true
targetNamespace: monitoring
wait: true
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: monitoring-config
namespace: flux-system
spec:
interval: 1m0s
sourceRef:
kind: GitRepository
name: flux-monitoring
path: ./monitoring/configs
dependsOn:
- name: kube-prometheus-stack
prune: true
targetNamespace: monitoring
3 changes: 3 additions & 0 deletions tools/dev-resources/podinfo/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resources:
- source.yaml
- kustomize.yaml
14 changes: 14 additions & 0 deletions tools/dev-resources/podinfo/kustomize.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: podinfo
namespace: flux-system
spec:
interval: 5m0s
path: ./kustomize
prune: true
sourceRef:
kind: GitRepository
name: podinfo
targetNamespace: default
11 changes: 11 additions & 0 deletions tools/dev-resources/podinfo/source.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
name: podinfo
namespace: flux-system
spec:
interval: 30m0s
ref:
branch: master
url: https://github.com/stefanprodan/podinfo
Loading