Skip to content

Commit 7198787

Browse files
Tabs for score-compose and score-k8s in Examples (#189)
Signed-off-by: Mathieu Benoit <mathieu-benoit@hotmail.fr>
1 parent 3671cb0 commit 7198787

16 files changed

Lines changed: 1854 additions & 1788 deletions

assets/scss/_content.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,9 @@
144144
font-weight: $font-regular;
145145
font-size: $font-body-sm;
146146
}
147+
148+
.mermaid {
149+
display: flex;
150+
justify-content: center;
151+
margin: 10px 0px 25px 0px
152+
}

content/en/docs/examples/backstage.md

Lines changed: 7 additions & 331 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ flowchart TD
1818
backstage-workload-->postgres[(PostgreSQL)]
1919
```
2020

21-
## 1. `score.yaml`
21+
## Score file
2222

2323
Open your IDE and paste in the following `score.yaml` file, which describes a simple web server exposed via a DNS that queries a PostgreSQL database on each request. The demo code can be found [here](https://github.com/mathieu-benoit/deploy-backstage-with-score).
2424

@@ -64,338 +64,14 @@ resources:
6464
port: 7007
6565
```
6666
67-
From here, we will now see how you can deploy this exact same Score file:
67+
## Deployment with `score-compose` and `score-k8s`
6868

69-
- Either with [`score-compose`](#2-score-compose)
70-
- Or with [`score-k8s`](#3-score-k8s)
69+
From here, we will now see how to deploy this exact same Score file with either with `score-compose` or with `score-k8s`:
7170

72-
## 2. `score-compose`
73-
74-
To begin, follow the [installation instructions](/docs/score-implementation/score-compose/installation) to install the latest version of `score-compose`.
75-
76-
### `init`
77-
78-
Initialize your current `score-compose` workspace, run the following command in your terminal:
79-
80-
```bash
81-
score-compose init --no-sample \
82-
--provisioners https://raw.githubusercontent.com/score-spec/community-provisioners/refs/heads/main/dns/score-compose/10-dns-with-url.provisioners.yaml
83-
```
84-
85-
The `init` command will create the `.score-compose` directory with the [default resource provisioners]({{< relref "/docs/score-implementation/score-compose/resources-provisioners/" >}}) available. We are also importing one external file to support the `dns` dependencies: [`dns` provisioner](https://github.com/score-spec/community-provisioners/blob/main/service/score-compose/10-dns-with-url.provisioners.yaml).
86-
87-
You can see the resource provisioners available by running this command:
88-
89-
```bash
90-
score-compose provisioners list
91-
```
92-
93-
The Score file example illustrated uses three resource types: `postgres-instance`, `dns` and `route`.
94-
95-
```none
96-
+-------------------+-------+------------------+--------------------------------+---------------------------------+
97-
| TYPE | CLASS | PARAMS | OUTPUTS | DESCRIPTION |
98-
+-------------------+-------+------------------+--------------------------------+---------------------------------+
99-
| dns | (any) | | host, url | Outputs a *.localhost domain as |
100-
| | | | | the hostname and associated URL |
101-
| | | | | in http on port 8080 |
102-
+-------------------+-------+------------------+--------------------------------+---------------------------------+
103-
| postgres-instance | (any) | | host, password, port, username | Provisions a dedicated |
104-
| | | | | PostgreSQL instance |
105-
+-------------------+-------+------------------+--------------------------------+---------------------------------+
106-
| route | (any) | host, path, port | | Provisions an Ingress route on |
107-
| | | | | a shared Nginx instance |
108-
+-------------------+-------+------------------+--------------------------------+---------------------------------+
109-
```
110-
111-
### `generate`
112-
113-
Convert the `score.yaml` file into a runnable `compose.yaml`, run the following command in your terminal:
114-
115-
```bash
116-
score-compose generate score.yaml --image ghcr.io/mathieu-benoit/backstage:latest
117-
```
118-
119-
The `generate` command will add the input `score.yaml` workload with a particular container image to the `.score-compose/state.yaml` state file and generate the output `compose.yaml`.
120-
121-
If you want to build the container image when this `compose.yaml` will be deployed, you can run this `generate` command with the `--build` parameter instead:
122-
123-
```bash
124-
score-compose generate score.yaml --build 'main={"context":".","tags":["backstage:local"]}'
125-
```
126-
127-
See the generated `compose.yaml` by running this command:
128-
129-
```bash
130-
cat compose.yaml
131-
```
132-
133-
If you make any modifications to the `score.yaml` file, run `score-compose generate score.yaml` to regenerate the output `compose.yaml`.
134-
135-
### `resources`
136-
137-
Get the information of the resources dependencies of the workload, run the following command:
138-
139-
```bash
140-
score-compose resources list
141-
```
142-
143-
```none
144-
+----------------------------------------+--------------------------------+
145-
| UID | OUTPUTS |
146-
+----------------------------------------+--------------------------------+
147-
| dns.default#backstage.dns | host, url |
148-
+----------------------------------------+--------------------------------+
149-
| postgres-instance.default#backstage.pg | host, password, port, username |
150-
+----------------------------------------+--------------------------------+
151-
| route.default#backstage.route | |
152-
+----------------------------------------+--------------------------------+
153-
```
154-
155-
At this stage, we can already see the value of the `dns` resource generated:
156-
157-
```bash
158-
score-compose resources get-outputs dns.default#backstage.dns
159-
```
160-
161-
```none
162-
{
163-
"host": "dnsjdtv57.localhost",
164-
"url": "http://dnsjdtv57.localhost:8080"
165-
}
166-
```
167-
168-
Same for the `postgres-instance` resource:
169-
170-
```bash
171-
score-compose resources get-outputs postgres-instance.default#backstage.pg
172-
```
173-
174-
```none
175-
{
176-
"host": "pg-OuoTNo",
177-
"password": "REDACTED",
178-
"port": 5432,
179-
"username": "REDACTED"
180-
}
181-
```
182-
183-
### `docker compose`
184-
185-
Run `docker compose up` to execute the generated `compose.yaml` file:
186-
187-
```bash
188-
docker compose up -d
189-
```
190-
191-
```none
192-
[+] Running 4/4
193-
✔ Container deploy-backstage-with-score-pg-OuoTNo-1 Healthy
194-
✔ Container deploy-backstage-with-score-wait-for-resources-1 Exited
195-
✔ Container deploy-backstage-with-score-routing-6uaxax-1 Started
196-
✔ Container deploy-backstage-with-score-backstage-backstage-1 Started
197-
```
198-
199-
### `docker ps`
200-
201-
See the running containers:
202-
203-
```bash
204-
docker ps
205-
```
206-
207-
```none
208-
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
209-
9b2ff62333ff ghcr.io/mathieu-benoit/backstage:latest "node packages/backe…" 5 hours ago Up 5 hours deploy-backstage-with-score-backstage-backstage-1
210-
4b1203acbf41 mirror.gcr.io/postgres:17-alpine "docker-entrypoint.s…" 5 hours ago Up 5 hours (healthy) 5432/tcp deploy-backstage-with-score-pg-mwgmNx-1
211-
716b626ad841 mirror.gcr.io/nginx:1-alpine "/docker-entrypoint.…" 5 hours ago Up 5 hours 0.0.0.0:8080->80/tcp, [::]:8080->80/tcp deploy-backstage-with-score-routing-idouo7-1
212-
```
213-
214-
### `curl localhost:8080`
215-
216-
Test the running container, run the following command:
217-
218-
```bash
219-
curl localhost:8080 -H "Host: dnsjdtv57.localhost"
220-
```
221-
222-
```none
223-
...
224-
<title>Scaffolded Backstage App</title>
225-
...
226-
```
227-
228-
Congrats! You’ve successfully deploy, with the `score-compose` implementation, a sample containerized Backstage workload talking to PostgreSQL and exposed via a DNS. You provisioned them through Docker, without writing the Docker Compose file by yourself.
229-
230-
## 3. `score-k8s`
231-
232-
To begin, follow the [installation instructions](/docs/score-implementation/score-k8s/installation) to install the latest version of `score-k8s`.
233-
234-
### `init`
235-
236-
Initialize your current `score-k8s` workspace, run the following command in your terminal:
237-
238-
```bash
239-
score-k8s init --no-sample \
240-
--provisioners https://raw.githubusercontent.com/score-spec/community-provisioners/refs/heads/main/dns/score-k8s/10-dns-with-url.provisioners.yaml
241-
```
242-
243-
The `init` command will create the `.score-k8s` directory with the [default resource provisioners]({{< relref "/docs/score-implementation/score-k8s/resources-provisioners/" >}}) available. We are also importing one external file to support the `dns` dependencies: [`dns` provisioner](https://github.com/score-spec/community-provisioners/blob/main/service/score-k8s/10-dns-with-url.provisioners.yaml).
244-
245-
You can see the resource provisioners available by running this command:
246-
247-
```bash
248-
score-k8s provisioners list
249-
```
250-
251-
The Score file example illustrated uses three resource types: `postgres-instance`, `dns` and `route`.
252-
253-
```none
254-
+-------------------+-------+------------------+--------------------------------+---------------------------------+
255-
| TYPE | CLASS | PARAMS | OUTPUTS | DESCRIPTION |
256-
+-------------------+-------+------------------+--------------------------------+---------------------------------+
257-
| dns | (any) | | host, url | Outputs a *.localhost domain as |
258-
| | | | | the hostname and associated URL |
259-
| | | | | in http on port 80 |
260-
+-------------------+-------+------------------+--------------------------------+---------------------------------+
261-
| postgres-instance | (any) | | host, password, port, username | Provisions a dedicated |
262-
| | | | | PostgreSQL instance |
263-
+-------------------+-------+------------------+--------------------------------+---------------------------------+
264-
| route | (any) | host, path, port | | Provisions an Ingress route on |
265-
| | | | | a shared Nginx instance |
266-
+-------------------+-------+------------------+--------------------------------+---------------------------------+
267-
```
268-
269-
### `generate`
270-
271-
Convert the `score.yaml` file into a runnable `manifests.yaml`, run the following command in your terminal:
272-
273-
```bash
274-
score-k8s generate score.yaml --image ghcr.io/mathieu-benoit/backstage:latest
275-
```
276-
277-
The `generate` command will add the input `score.yaml` workload with a particular container image to the `.score-k8s/state.yaml` state file and generate the output `manifests.yaml`.
278-
279-
See the generated `manifests.yaml` by running this command:
280-
281-
```bash
282-
cat manifests.yaml
283-
```
284-
285-
If you make any modifications to the `score.yaml` file, run `score-k8s generate score.yaml` to regenerate the output `manifests.yaml`.
286-
287-
### `resources`
288-
289-
Get the information of the resources dependencies of the workload, run the following command:
290-
291-
```bash
292-
score-k8s resources list
293-
```
294-
295-
```none
296-
+----------------------------------------+--------------------------------+
297-
| UID | OUTPUTS |
298-
+----------------------------------------+--------------------------------+
299-
| dns.default#backstage.dns | host, url |
300-
+----------------------------------------+--------------------------------+
301-
| postgres-instance.default#backstage.pg | host, password, port, username |
302-
+----------------------------------------+--------------------------------+
303-
| route.default#backstage.route | |
304-
+----------------------------------------+--------------------------------+
305-
```
306-
307-
At this stage, we can already see the value of the `dns` resource generated:
308-
309-
```bash
310-
score-k8s resources get-outputs dns.default#backstage.dns
311-
```
312-
313-
```none
314-
{
315-
"host": "dnsnocrke.localhost",
316-
"url": "http://dnsnocrke.localhost:80"
317-
}
318-
```
319-
320-
Same for the `postgres-instance` resource:
321-
322-
```bash
323-
score-k8s resources get-outputs postgres-instance.default#backstage.pg
324-
```
325-
326-
```none
327-
{
328-
"host": "pg-backstage-d7058793",
329-
"password": "REDACTED",
330-
"port": 5432,
331-
"username": "REDACTED"
332-
}
333-
```
334-
335-
### `kubectl apply`
336-
337-
_Here you will need to have access to a Kubernetes cluster to execute the following commands. You can follow [these instructions](/docs/how-to/score-k8s/kind-cluster/) if you want to set up a Kind cluster._
338-
339-
Run `kubectl apply` to execute the generated `manifests.yaml` file:
340-
341-
```bash
342-
kubectl apply -f manifests.yaml
343-
```
344-
345-
```none
346-
secret/pg-backstage-d7058793 created
347-
statefulset.apps/pg-backstage-d7058793 created
348-
service/pg-backstage-d7058793 created
349-
httproute.gateway.networking.k8s.io/route-backstage-76d19d47 created
350-
service/backstage created
351-
deployment.apps/backstage created
352-
```
353-
354-
### `kubectl get all`
355-
356-
See the running containers:
357-
358-
```bash
359-
kubectl get all,httproute
360-
```
361-
362-
```none
363-
NAME READY STATUS RESTARTS AGE
364-
pod/backstage-7667f68bf9-vnlw9 1/1 Running 0 37s
365-
pod/pg-backstage-d7058793-0 1/1 Running 0 37s
366-
367-
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
368-
service/backstage ClusterIP 10.96.146.148 <none> 7007/TCP 37s
369-
service/pg-backstage-d7058793 ClusterIP 10.96.21.104 <none> 5432/TCP 37s
370-
371-
NAME READY UP-TO-DATE AVAILABLE AGE
372-
deployment.apps/backstage 1/1 1 1 37s
373-
374-
NAME DESIRED CURRENT READY AGE
375-
replicaset.apps/backstage-7667f68bf9 1 1 1 37s
376-
377-
NAME READY AGE
378-
statefulset.apps/pg-backstage-d7058793 1/1 37s
379-
380-
NAME HOSTNAMES AGE
381-
httproute.gateway.networking.k8s.io/route-backstage-76d19d47 ["dnsnocrke.localhost"] 37s
382-
```
383-
384-
### `curl localhost`
385-
386-
Test the running container, run the following command:
387-
388-
```bash
389-
curl localhost -H "Host: dnsnocrke.localhost"
390-
```
391-
392-
```none
393-
...
394-
<title>Scaffolded Backstage App</title>
395-
...
396-
```
397-
398-
Congrats! You’ve successfully deploy, with the `score-k8s` implementation, a sample containerized Backstage workload talking to PostgreSQL and exposed via a DNS. You provisioned them through `kubectl`, without writing the Kubernetes manifests file by yourself.
71+
{{< tabs name="deployments">}}
72+
{{< tab name="score-compose" include="./included/backstage-score-compose.md" />}}
73+
{{< tab name="score-k8s" include="./included/backstage-score-k8s.md" />}}
74+
{{< /tabs >}}
39975

40076
## Next steps
40177

0 commit comments

Comments
 (0)