Skip to content

Commit f45d7dc

Browse files
Suggestions 2023-07-18 (UffizziCloud#53)
* README suggestions * Split k8s resources into their own manifest files. * Rename a lot of things. * Reduce. * Change images in manifests/ to be "fail safe" without kustomize. * Copy changes in README and comments and workflow summary output * correct shell syntax error. * Change hostnames for Ingresses. * correct mount point for postgres
1 parent 9c92aaa commit f45d7dc

13 files changed

+90
-90
lines changed

.github/workflows/uffizzi.yml

+43-32
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ permissions:
1212
jobs:
1313
# Job to build-push vote image
1414
build-vote:
15-
name: Build and Push `vote`
15+
name: Build and Push `vote` Image
1616
runs-on: ubuntu-latest
1717
if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }}
1818
outputs:
@@ -40,7 +40,7 @@ jobs:
4040

4141
# Job to build-push worker image
4242
build-worker:
43-
name: Build and Push `worker`
43+
name: Build and Push `worker` Image
4444
runs-on: ubuntu-latest
4545
if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }}
4646
outputs:
@@ -68,7 +68,7 @@ jobs:
6868

6969
# Job to build-push result image
7070
build-result:
71-
name: Build and Push `result`
71+
name: Build and Push `result` Image
7272
runs-on: ubuntu-latest
7373
if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }}
7474
outputs:
@@ -94,7 +94,8 @@ jobs:
9494
labels: ${{ steps.meta.outputs.labels }}
9595
context: ./result
9696

97-
uffizzi-cluster-setup:
97+
uffizzi-cluster:
98+
name: Deploy to Uffizzi Virtual Cluster
9899
needs:
99100
- build-vote
100101
- build-worker
@@ -106,7 +107,7 @@ jobs:
106107
uses: actions/checkout@v3
107108

108109
# Identify comment to be updated
109-
- name: Find comment for deployment URL
110+
- name: Find comment for Ephemeral Environment
110111
uses: peter-evans/find-comment@v2
111112
id: find-comment
112113
with:
@@ -132,47 +133,59 @@ jobs:
132133
Download the Uffizzi CLI to interact with the upcoming virtual cluster
133134
https://docs.uffizzi.com/install
134135
edit-mode: replace
135-
136-
- if: ${{ github.event.action != 'closed' }}
137-
name: Setup ucluster
136+
137+
- name: Connect to Virtual Cluster
138138
uses: UffizziCloud/cluster-action@main
139139
with:
140-
action: create
141140
cluster-name: pr-${{ github.event.pull_request.number }}
142-
server: https://app.uffizzi.com
143141

144-
- name: Kustomize and apply
142+
- name: Kustomize and Apply Manifests
145143
run: |
146-
kustomize edit set image vote-image=${{ needs.build-vote.outputs.tags }}
147-
kustomize edit set image result-image=${{ needs.build-result.outputs.tags }}
148-
kustomize edit set image worker-image=${{ needs.build-worker.outputs.tags }}
149-
echo "`pwd`"
150-
echo "`ls`"
151-
kustomize build . | kubectl apply --kubeconfig ./kubeconfig -f -
144+
# Change the image name to those just built and pushed.
145+
kustomize edit set image dockersamples/examplevotingapp_vote=${{ needs.build-vote.outputs.tags }}
146+
kustomize edit set image dockersamples/examplevotingapp_result=${{ needs.build-result.outputs.tags }}
147+
kustomize edit set image dockersamples/examplevotingapp_worker=${{ needs.build-worker.outputs.tags }}
148+
149+
if [[ ${RUNNER_DEBUG} == 1 ]]; then
150+
cat kustomization.yaml
151+
echo "`pwd`"
152+
echo "`ls`"
153+
fi
154+
155+
# Apply kustomized manifests to virtual cluster.
156+
kubectl apply --kustomize . --kubeconfig ./kubeconfig
157+
158+
# Imperatively create Ingress resources for the two HTTP endpoints.
159+
export VOTE_HOST="pr-${{ github.event.number }}-${GITHUB_REPOSITORY_ID}-vote.uclusters.app.qa-gke.uffizzi.com"
160+
export RESULT_HOST="pr-${{ github.event.number }}-${GITHUB_REPOSITORY_ID}-result.uclusters.app.qa-gke.uffizzi.com"
152161
153162
if kubectl get ingress vote-${{ github.event.number }} --kubeconfig kubeconfig >/dev/null 2>&1; then
154163
echo "Ingress vote-${{ github.event.number }} already exists"
155-
156164
else
157165
kubectl create ingress vote-${{ github.event.number }} \
158166
--class=nginx \
159-
--rule="pr-${{ github.event.number }}-vote.app.qa-gke.uffizzi.com/*=vote:5000" \
167+
--rule="${VOTE_HOST}/*=vote:5000" \
160168
--kubeconfig kubeconfig
161169
fi
162170
163171
if kubectl get ingress result-${{ github.event.number }} --kubeconfig kubeconfig >/dev/null 2>&1; then
164172
echo "Ingress result-${{ github.event.number }} already exists"
165-
166-
else
173+
else
167174
kubectl create ingress result-${{ github.event.number }} \
168175
--class=nginx \
169-
--rule="pr-${{ github.event.number }}-result.app.qa-gke.uffizzi.com/*=result:5001" \
176+
--rule="${RESULT_HOST}/*=result:5001" \
170177
--kubeconfig kubeconfig
171178
fi
172179
173-
echo "Access the vote endpoint at \`pr-${{ github.event.number }}-vote.app.qa-gke.uffizzi.com\`." | tee --append $GITHUB_STEP_SUMMARY
174-
echo "Access the result endpoint at \`pr-${{ github.event.number }}-result.app.qa-gke.uffizzi.com\`." | tee --append $GITHUB_STEP_SUMMARY
175-
180+
if [[ ${RUNNER_DEBUG} == 1 ]]; then
181+
kubectl get all --kubeconfig ./kubeconfig
182+
fi
183+
184+
echo "Access the vote endpoint at https://${VOTE_HOST}"
185+
echo "Access the result endpoint at https://${RESULT_HOST}"
186+
echo "Access the \`vote\` endpoint at [\`${VOTE_HOST}\`.](https://${VOTE_HOST})" >> $GITHUB_STEP_SUMMARY
187+
echo "Access the \`result\` endpoint at [\`${RESULT_HOST}\`](${RESULT_HOST})." >> $GITHUB_STEP_SUMMARY
188+
176189
- name: Create or Update Comment with Deployment URL
177190
uses: peter-evans/create-or-update-comment@v2
178191
with:
@@ -186,29 +199,28 @@ jobs:
186199
187200
1. Download and install the Uffizzi CLI from https://docs.uffizzi.com/install
188201
2. Login to Uffizzi: `uffizzi login`
189-
3a. Update your kubeconfig: `uffizzi cluster update-kubeconfig --name pr-${{ github.event.pull_request.number }}`. This command will update your local kubeconfig.
202+
3a. Update your kubeconfig: `uffizzi cluster update-kubeconfig --name pr-${{ github.event.pull_request.number }}`. This command will update your local `~/.kube/config`.
190203
If you want to provide an alternate location follow 3b (the next step) instead.
191204
3b. Update your kubeconfig: `uffizzi cluster update-kubeconfig --name pr-${{ github.event.pull_request.number }} --kubeconfig=[KUBECONFIG]`, replacing `[KUBECONFIG]` with the path to your kubeconfig file.
192-
After updating your kubeconfig, you can manage your cluster with `kubectl`.
205+
After updating your kubeconfig, you can manage your cluster with `kubectl`, `kustomize`, `helm`, and other tools that use kubeconfig files: `kubectl get namespace --kubeconfig [KUBECONFIG]`
193206
194207
Access the vote endpoint at https://pr-${{ github.event.number }}-vote.app.qa-gke.uffizzi.com
195208
Access the result endpoint at https://pr-${{ github.event.number }}-result.app.qa-gke.uffizzi.com
196209
197210
edit-mode: replace
198211

199-
uffizzi-cluster-delete:
212+
uffizzi-cluster-delete:
200213
if: ${{ github.event_name == 'pull_request' && github.event.action == 'closed' }}
201214
runs-on: ubuntu-latest
202215
steps:
203-
- name: Delete ucluster
216+
- name: Delete Virtual Cluster
204217
uses: UffizziCloud/cluster-action@main
205218
with:
206219
action: delete
207220
cluster-name: pr-${{ github.event.pull_request.number }}
208-
server: https://app.uffizzi.com
209221

210222
# Identify comment to be updated
211-
- name: Find comment for deployment URL
223+
- name: Find comment for Ephemeral Environment
212224
uses: peter-evans/find-comment@v2
213225
id: find-comment
214226
with:
@@ -219,7 +231,6 @@ jobs:
219231

220232
- name: Update Comment with Deletion
221233
uses: peter-evans/create-or-update-comment@v2
222-
if: ${{ github.event.action == 'closed' }}
223234
with:
224235
comment-id: ${{ steps.find-comment.outputs.comment-id }}
225236
issue-number: ${{ github.event.pull_request.number }}

README.md

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# Uffizzi Quickstart for Kubernetes (~ 1 minute)
22

3-
Go from pull request to Uffizzi Ephemeral Environment in less than one minute. This quickstart will create a virtual Kubernetes cluster on Uffizzi Cloud and deploy a sample microservices application from this repository. Once created, you can connect to the cluster with the Uffizzi CLI, then manage the cluster via Kubectl. You can clean up the cluster by closing the pull request or manually deleting it via the Uffizzi CLI.
3+
Go from pull request to Uffizzi Ephemeral Environment in less than one minute. This quickstart will create a virtual Kubernetes cluster on Uffizzi Cloud and deploy a sample microservices application from this repository. Once created, you can connect to the cluster with the Uffizzi CLI, then manage the cluster via `kubectl`, `kustomize`, `helm`, and other tools. You can clean up the cluster by closing the pull request or manually deleting it via the Uffizzi CLI.
44

5-
### 1. Fork the `quickstart_k8s` repo
5+
### 1. Fork this `quickstart-k8s` repo
6+
7+
[https://github.com/UffizziCloud/quickstart-k8s/fork](https://github.com/UffizziCloud/quickstart-k8s/fork)
68

79
⚠️ Be sure to <ins>**uncheck**</ins> the option **Copy the `main` branch only**.
810

9-
This ensures that the `try-uffizzi` branch will be included in your fork.
11+
This ensures that the `try-uffizzi` branch will be included in your fork.
1012

1113
### 2. Enable GitHub Actions workflows for your fork
1214

@@ -23,7 +25,7 @@ Once the action is finished running, check the pull request comments section to
2325

2426
<img src="https://github.com/UffizziCloud/quickstart-k8s/blob/readme/images/comment.png" width="800">
2527

26-
### 5. Access the vote and result endpoints
28+
### 5. Access the `vote` and `result` HTTP services
2729

2830
Additionally, the app endpoints can be found on the action summary page. Under the Actions section of the forked repository, open up the latest completed action. Within the completed action, open up the summary section. Copy and paste the vote and result endpoints within the action summary
2931

@@ -38,7 +40,7 @@ The PR will trigger a [GitHub Actions workflow](.github/workflows/uffizzi-cluste
3840

3941
### Configuration
4042

41-
Ephemeral Environments are configured with [Kubernetes manifests](kustomization.yaml) that describe the application components and a [GitHub Actions workflow](.github/workflows/uffizzi-cluster.yaml) that includes a series of jobs triggered by a `pull_request` event and subsequent `push` events:
43+
Ephemeral Environments are configured with [Kubernetes manifests](manifests/) that describe the application components and a [GitHub Actions workflow](.github/workflows/uffizzi-cluster.yaml) that includes a series of jobs triggered by a `pull_request` event and subsequent `push` events:
4244

4345
1. [Build and push the voting-app images](https://github.com/UffizziCloud/quickstart-k8s/blob/fc27d539d98fd602039a4259cafe9dd2ccf65dc5/.github/workflows/reusable.yml#L11C1-L90C28)
4446
2. [Create the Uffizzi cluster using the uffizzi-cli](https://github.com/UffizziCloud/quickstart-k8s/blob/fc27d539d98fd602039a4259cafe9dd2ccf65dc5/.github/workflows/reusable.yml#L92C1-L102C22)
@@ -61,8 +63,8 @@ The application defined by this repo allows users to vote for dogs or cats and s
6163

6264
<img src="https://user-images.githubusercontent.com/7218230/192601868-562b705f-bf39-4eb8-a554-2a0738bd8ecf.png" width="400">
6365

64-
* **voting-app** - A frontend web app in [Python](/vote) that lets you vote between two options
65-
* **redis** - A [Redis](https://hub.docker.com/_/redis/) queue that collects new votes
66-
* **worker** - A [.NET Core](/worker/src/Worker) worker that consumes votes and stores them in...
67-
* **db** - A [PostgreSQL](https://hub.docker.com/_/postgres/) database backed by a Docker volume
68-
* **result-app** - A [Node.js](/result) web app that shows the results of the voting in real time
66+
* `voting` - A frontend web app in [Python](/vote) that lets you vote between two options
67+
* `redis` - A [Redis](https://hub.docker.com/_/redis/) queue that collects new votes
68+
* `worker` - A [.NET Core](/worker/src/Worker) worker that consumes votes and stores them in...
69+
* `db` - A [PostgreSQL](https://hub.docker.com/_/postgres/) database backed by a Docker volume
70+
* `result` - A [Node.js](/result) web app that shows the results of the voting in real time

kustomization.yaml

+11-18
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11
apiVersion: kustomize.config.k8s.io/v1beta1
22
kind: Kustomization
33
resources:
4-
- manifests/db-deployment.yaml
5-
- manifests/db-service.yaml
6-
- manifests/redis-deployment.yaml
7-
- manifests/redis-service.yaml
8-
- manifests/result-deployment.yaml
9-
- manifests/result-service.yaml
10-
- manifests/vote-deployment.yaml
11-
- manifests/vote-service.yaml
12-
- manifests/worker-deployment.yaml
13-
14-
15-
images:
16-
- name: result-image
17-
newName: dockersamples/examplevotingapp_result
18-
- name: vote-image
19-
newName: dockersamples/examplevotingapp_vote
20-
- name: worker-image
21-
newName: dockersamples/examplevotingapp_worker
4+
- manifests/db-deployment.yaml
5+
- manifests/db-persistentvolumeclaim.yaml
6+
- manifests/db-service.yaml
7+
- manifests/redis-deployment.yaml
8+
- manifests/redis-persistentvolumeclaim.yaml
9+
- manifests/redis-service.yaml
10+
- manifests/result-deployment.yaml
11+
- manifests/result-service.yaml
12+
- manifests/vote-deployment.yaml
13+
- manifests/vote-service.yaml
14+
- manifests/worker-deployment.yaml

manifests/db-deployment.yaml

+1-12
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,9 @@ spec:
2626
- containerPort: 5432
2727
name: postgres
2828
volumeMounts:
29-
- mountPath: /var/lib/postgresql/data
29+
- mountPath: /var/lib/postgresql
3030
name: db-data
3131
volumes:
3232
- name: db-data
3333
persistentVolumeClaim:
3434
claimName: db-pv-claim
35-
---
36-
apiVersion: v1
37-
kind: PersistentVolumeClaim
38-
metadata:
39-
name: db-pv-claim
40-
spec:
41-
accessModes:
42-
- ReadWriteOnce
43-
resources:
44-
requests:
45-
storage: 1Gi
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
name: db-pv-claim
5+
spec:
6+
accessModes:
7+
- ReadWriteOnce
8+
resources:
9+
requests:
10+
storage: 1Gi

manifests/db-service.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ spec:
1212
targetPort: 5432
1313
selector:
1414
app: db
15-

manifests/redis-deployment.yaml

-11
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,3 @@ spec:
2727
- name: redis-data
2828
persistentVolumeClaim:
2929
claimName: redis-pv-claim
30-
---
31-
apiVersion: v1
32-
kind: PersistentVolumeClaim
33-
metadata:
34-
name: redis-pv-claim
35-
spec:
36-
accessModes:
37-
- ReadWriteOnce
38-
resources:
39-
requests:
40-
storage: 1Gi
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
name: redis-pv-claim
5+
spec:
6+
accessModes:
7+
- ReadWriteOnce
8+
resources:
9+
requests:
10+
storage: 1Gi

manifests/redis-service.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ spec:
1212
targetPort: 6379
1313
selector:
1414
app: redis
15-

manifests/result-deployment.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ spec:
1515
app: result
1616
spec:
1717
containers:
18-
- image: result-image
18+
- image: dockersamples/examplevotingapp_result
1919
name: result
2020
ports:
2121
- containerPort: 80

manifests/vote-deployment.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ spec:
1515
app: vote
1616
spec:
1717
containers:
18-
- image: vote-image
18+
- image: dockersamples/examplevotingapp_vote
1919
name: vote
2020
ports:
2121
- containerPort: 80

manifests/vote-service.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ spec:
1212
targetPort: 80
1313
selector:
1414
app: vote
15-

manifests/worker-deployment.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@ spec:
1515
app: worker
1616
spec:
1717
containers:
18-
- image: worker-image
18+
- image: dockersamples/examplevotingapp_worker
1919
name: worker
20-

0 commit comments

Comments
 (0)