Skip to content
This repository has been archived by the owner on Oct 11, 2022. It is now read-only.

Commit

Permalink
Add TAP resources and update README
Browse files Browse the repository at this point in the history
  • Loading branch information
trisberg committed Jan 4, 2022
1 parent 692730c commit 57fb4b3
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 117 deletions.
66 changes: 66 additions & 0 deletions DEPLOYING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Deploying to Kubernetes

> NOTE: The provided `config/workload.yaml` file uses the Git URL for this sample. When you want to modify the source, you must push the code to your own Git repository and then update the `spec.source.git` information in the `config/workload.yaml` file.
## Deploying to Kubernetes as a TAP workload with Tilt

You can containerize this template app and deploy it as a Tanzu Application Platform (TAP) workload.
You need to have TAP installed on your cluster.
See the [VMware Tanzu Application Platform documentation](https://docs.vmware.com/en/VMware-Tanzu-Application-Platform/index.html) for details.

We have included a `Tiltfile` file to make this easier when deploying to a cluster.

For best results use Tilt version v0.23.2 or later. You can install Tilt by following these instructions: https://docs.tilt.dev/install.html

To set up the deployment environment set the CURRENT_CONTEXT environment variable.

Set CURRENT_CONTEXT using:

```
export CURRENT_CONTEXT=$(kubectl config current-context)
```

To build and deploy the app run:

```
tilt up
```

and follow the instructions (hitting space bar brings up the Tilt interface in your browser).

To uninstall the app run:

```
tilt down
```

## Accessing the app deployed to your cluster

If you don't have `curl` installed it can be installed using downloads here: https://curl.se/download.html

Determine the URL to use for the accessing the app by running:

```
tanzu apps workload get node-express
```

To access the deployed app open the URL shown in your browser.

This depends on the TAP installation having DNS configured for the Knative ingress.

## Deploying to Kubernetes as a TAP workload with Tanzu CLI

When you are done developing your app, you can simply deploy it using:

```
tanzu apps workload apply -f config/workload.yaml
```

If you would like deploy the code from your local working directory you can use the following command:

```
tanzu apps workload create node-express -f config/workload.yaml \
--local-path . \
--source-image <REPOSITORY-PREFIX>/node-express-source \
--type web
```
15 changes: 15 additions & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
allow_k8s_contexts(os.getenv("CURRENT_CONTEXT", default='kind-kind'))

NAMESPACE = os.getenv("NAMESPACE", default='default')

k8s_custom_deploy(
'node-express',
apply_cmd="tanzu apps workload apply -f config/workload.yaml " +
" --namespace " + NAMESPACE +
" --yes >/dev/null" +
" && kubectl get workload node-express --namespace " + NAMESPACE + " -o yaml",
delete_cmd="tanzu apps workload delete -f config/workload.yaml --namespace " + NAMESPACE + " --yes",
deps=['package.json', 'server.js'],
)

k8s_resource('node-express', extra_pod_selectors=[{'serving.knative.dev/service': 'node-express'}])
34 changes: 16 additions & 18 deletions accelerator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,43 @@ accelerator:

# options for the UI
options:
- name: projectDescription
label: Description
display: true
defaultValue: ''
- name: includeK8s
label: "Include kubernetes resources?"
- name: includeTap
label: "Include TAP deployment resources?"
inputType: checkbox
dataType: boolean
defaultValue: true
required: true

engine:
merge:
- include: [ "**" ]
exclude: [ "kubernetes/**", "README.md", "k8s.md", "skaffold.md" ]
exclude: [ "package.json", "config/**", "catalog/**", "README.md", "DEPLOYING.md", "TILTFILE" ]
- include: [ "package.json" ]
chain:
- type: ReplaceText
substitutions:
- text: node-express
with: "#artifactId"
- text: accelerator-description
with: "#projectDescription"
- include: [ "kubernetes/deployment.yml", "kubernetes/service.yml" ]
condition: "#includeK8s"
- include: [ "config/workload.yaml" ]
condition: "#includeTap"
chain:
- type: ReplaceText
substitutions:
- text: node-express
with: "#artifactId"
- include: [ "kubernetes/skaffold.yml" ]
condition: "#includeK8s"
- include: [ "catalog/catalog-info.yaml" ]
condition: "#includeTap"
chain:
- type: ReplaceText
substitutions:
- text: node-express
with: "#artifactId"
- include: [ "Tiltfile" ]
condition: "#includeTap"
chain:
- type: ReplaceText
substitutions:
- text: node-express
with: "#artifactId"
- type: RewritePath
rewriteTo: "#filename"
- name: README
type: Combo
onConflict: Append
Expand All @@ -57,8 +55,8 @@ engine:
substitutions:
- text: node-express
with: "#artifactId"
- include: ["k8s.md"]
condition: "#includeK8s"
- include: [ "DEPLOYING.md" ]
condition: "#includeTap"
chain:
- type: ReplaceText
substitutions:
Expand Down
16 changes: 16 additions & 0 deletions catalog/catalog-info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: node-express
description: Node Express Sample App
tags:
- app-accelerator
- node
- express
- tanzu
annotations:
'backstage.io/kubernetes-label-selector': 'app.kubernetes.io/part-of=node-express'
spec:
type: service
lifecycle: experimental
owner: default-team
4 changes: 1 addition & 3 deletions config/workload.yml → config/workload.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
---
apiVersion: carto.run/v1alpha1
kind: Workload
metadata:
creationTimestamp: null
name: node-express
namespace: default
labels:
Expand All @@ -13,4 +11,4 @@ spec:
git:
ref:
branch: main
url: https://github.com/sample-accelerators/node-express
url: https://github.com/sample-accelerators/node-express.git
27 changes: 0 additions & 27 deletions k8s.md

This file was deleted.

35 changes: 0 additions & 35 deletions kubernetes/deployment.yml

This file was deleted.

12 changes: 0 additions & 12 deletions kubernetes/service.yml

This file was deleted.

22 changes: 0 additions & 22 deletions kubernetes/skaffold.yml

This file was deleted.

0 comments on commit 57fb4b3

Please sign in to comment.