Skip to content

Commit

Permalink
Merge pull request #2 from appvia/update-readme
Browse files Browse the repository at this point in the history
Update readme, add sample app definition
  • Loading branch information
mrsheepuk authored Dec 15, 2023
2 parents 84de9bc + f4a5e0f commit fdad2c8
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 9 deletions.
50 changes: 41 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,55 @@
# wf-example-app
An example app to demonstrate using Wayfinder for PR previews and deployment

To use this example, generate an access token in your workspace and add as a secret:
An example app to demonstrate using Wayfinder for ephemeral PR previews and deploying to a
long-lived environment on merge.

The main branch of this repository deploys to https://ui-prod-wfexam9lvp.demo.wayfinder.run/

## Using the example

### 1. Create the app in Wayfinder

Create an application in your workspace in Wayfinder. To get going quickly, edit the manifests in
the app folder, then apply to your workspace:

```
wf use workspace wsp1
wf apply -f ./app
```

### 2. Create an access token to permit GitHub access to your workspace

Create an access token in your workspace and add as a GitHub secret for your repository:
```
wf use workspace ws1
wf create workspaceaccesstoken wf-example-app-ghactions --reset-token --show-token | gh secret set WAYFINDER_TOKEN -R appvia/wf-example-app -a actions
wf create workspaceaccesstoken wf-example-app-ghactions --show-token | gh secret set WAYFINDER_TOKEN -R appvia/wf-example-app -a actions
```

Permission the token:
* Add cluster.deployment on an existing cluster to host the PR environments (e.g. demo-envs) - note the name of the cluster
* Add workspace.appdeployer and workspace.appmanager roles
### 3. Create a cluster to host your PR previews and live environments

If you don't already have a cluster in your workspace that you wish to use, create a cluster
choosing an appropriate plan.

Note the name of the cluster, we'll need it below.

### 4. Permission the access token to use this cluster

Configure other variables, adjust the values as appropriate for your app, environment, and PR preview cluster:
* Add workspace.appdeployer and workspace.appmanager roles - this allows the token to create
ephemeral environments and deploy to them.
* Add cluster.deployment on the cluster you wish to host the PR preview environments. This allows
the token to deploy to any environment on the PR preview cluster.
* Add namespace.deployment on the cluster namespace you wish to host the long-lived 'prod'
environment (not needed if using the same cluster as above)
* Add cluster.deployment.readonly on the cluster you wish to host the long-lived 'prod' environment
(not needed if using the same cluster as above)

### 5. Configure supporting variables in GitHub for the workflows:

Adjusting as needed for your application, create variables for the workflow:
```
gh variable set WAYFINDER_WORKSPACE -r appvia/wf-example-app --body ws1
gh variable set WAYFINDER_SERVER -r appvia/wf-example-app --body https://api-wayfinder.myorg.io
gh variable set APP_NAME -r appvia/wf-example-app --body wfexampleapp
gh variable set APP_COMPONENT_NAME -r appvia/wf-example-app --body ui
gh variable set PR_PREVIEW_CLUSTER -r appvia/wf-example-app --body demo-envs
gh variable set LIVE_ENV_NAME -r appvia/wf-example-app --body prod
```
```
7 changes: 7 additions & 0 deletions app/01-app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: app.appvia.io/v2beta1
kind: Application
metadata:
name: wfexampleapp
spec:
cloud: azure
name: wfexampleapp
22 changes: 22 additions & 0 deletions app/02-appcomponent-ui.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: app.appvia.io/v2beta1
kind: AppComponent
metadata:
name: wfexampleapp-ui
spec:
application: wfexampleapp
container:
containers:
- image: ghcr.io/appvia/wf-example-app/wfexample
name: container-1
ports:
- containerPort: 8080
name: ui
protocol: TCP
expose:
container: container-1
port: 8080
replicas: 1
tls: true
key: ui
name: ui
type: Container

0 comments on commit fdad2c8

Please sign in to comment.