Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: "gcp-pubsub-emulator"
draft: false
mermaid: true
type: examples
source: "community"
implementation: "score-compose"
resourceType: "gcp-pubsub-emulator"
provisionerType: "template"
flavor: "gcp"
excerpt: ''
description: 'Generates a Google Cloud Pub/Sub Emulator service for local development.'
expectedOutputs:
- host
- port
- project_id
- emulator_host
supportedParams:
- project_id
hasMore: false

---

{{% resource-provisioner-content description="Generates a Google Cloud Pub/Sub Emulator service for local development." type="gcp-pubsub-emulator" supportedParams="project_id" expectedOutputs="host,port,project_id,emulator_host" %}}

{{% example-file filename="10-gcp-pubsub-emulator.provisioners.yaml" dir="resource-provisioners/community/gcp-pubsub-emulator/score-compose" githubUrl="https://github.com/score-spec/community-provisioners/blob/main" %}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
title: "Gcp Pubsub Emulator"
draft: false
mermaid: true
type: examples
excerpt: ''
hasMore: false
parent: "Community Provisioners"
flavor: "Resources"

---

{{% example-file filename="score.yaml" dir="score/resources/community-provisioners/gcp-pubsub-emulator" githubUrl="https://github.com/score-spec/community-provisioners/blob/main" %}}

{{< tabs >}}
{{% tab name="score-compose" %}}
{{% example-file filename="10-gcp-pubsub-emulator.provisioners.yaml" dir="score/resources/community-provisioners/gcp-pubsub-emulator/score-compose" githubUrl="https://github.com/score-spec/community-provisioners/blob/main" %}}

---

Initialize your local workspace, by importing a specific community provisioner:

```bash
score-compose init --provisioners REPLACE-ME-WITH-ACTUAL-PROVISIONER-FILE-URL.yaml
```

_Note: you need to replace `REPLACE-ME-WITH-ACTUAL-PROVISIONER-FILE-URL.yaml` by the actual provisioner file you want to use and import. More information [here](https://docs.score.dev/docs/score-implementation/score-compose/resources-provisioners/#install-provisioner-files)._

Get the provisioners definition:

```bash
score-compose provisioners list
```

Generate the platform specific manifests:

```bash
score-compose generate score.yaml
```

See the resource outputs:

```bash
score-compose resources list
```

You can run the following command on each resource listed with the previous command to get their `outputs`:

```bash
score-compose resources get-outputs
```

Deploy the generated manifests:

```bash
docker compose up -d
```

See the running containers:

```bash
docker ps
```

{{%/ tab %}}
{{% tab name="score-k8s" %}}
Initialize your local workspace, by importing a specific community provisioner:

```bash
score-k8s init --provisioners REPLACE-ME-WITH-ACTUAL-PROVISIONER-FILE-URL.yaml
```

_Note: you need to replace `REPLACE-ME-WITH-ACTUAL-PROVISIONER-FILE-URL.yaml` by the actual provisioner file you want to use and import. More information [here](https://docs.score.dev/docs/score-implementation/score-k8s/resources-provisioners/#install-provisioner-files)._

Get the provisioners definition:

```bash
score-k8s provisioners list
```

Generate the platform specific manifests:

```bash
score-k8s generate score.yaml
```

See the resource outputs:

```bash
score-k8s resources list
```

You can run the following command on each resource listed with the previous command to get their `outputs`:

```bash
score-k8s resources get-outputs
```

Deploy the generated manifests:

```bash
kubectl apply -f manifests.yaml
```

See the running containers:

```bash
kubectl get all
```

{{%/ tab %}}
{{< /tabs >}}
2 changes: 2 additions & 0 deletions data/examplesMeta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ resource-provisioners:
- endpoint
- environment
- example-provisioner-resource
- gcp-pubsub-emulator
- horizontal-pod-autoscaler
- kafka-topic
- llm-model
Expand Down Expand Up @@ -44,6 +45,7 @@ resource-provisioners:
- endpoint-with-microcks-cli
- example-provisioner
- foo
- gcp
- helm-template-redis
- helm-upgrade-redis
- ingress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,41 @@
mkdir install-more-tools
cd install-more-tools

# score-compose
SCORE_COMPOSE_VERSION=$(curl -sL https://api.github.com/repos/score-spec/score-compose/releases/latest | jq -r .tag_name)
wget https://github.com/score-spec/score-compose/releases/download/${SCORE_COMPOSE_VERSION}/score-compose_${SCORE_COMPOSE_VERSION}_linux_amd64.tar.gz
tar -xvf score-compose_${SCORE_COMPOSE_VERSION}_linux_amd64.tar.gz
chmod +x score-compose
sudo mv score-compose /usr/local/bin

# score-k8s
SCORE_K8S_VERSION=$(curl -sL https://api.github.com/repos/score-spec/score-k8s/releases/latest | jq -r .tag_name)
wget https://github.com/score-spec/score-k8s/releases/download/${SCORE_K8S_VERSION}/score-k8s_${SCORE_K8S_VERSION}_linux_amd64.tar.gz
tar -xvf score-k8s_${SCORE_K8S_VERSION}_linux_amd64.tar.gz
chmod +x score-k8s
sudo mv score-k8s /usr/local/bin

# kind
KIND_VERSION=$(curl -sL https://api.github.com/repos/kubernetes-sigs/kind/releases/latest | jq -r .tag_name)
curl -Lo ./kind https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind

# yq
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq
sudo chmod +x /usr/bin/yq

# docker model-plugin
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-model-plugin
docker model list

cd ..
rm -rf install-more-tools
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ score-compose init --provisioners https://raw.githubusercontent.com/score-spec/c
| 10-dns-with-url.provisioners.yaml | `dns` | (any) | (none) | `host`, `url` | Outputs a `*.localhost` domain as the hostname and associated URL in http on port `8080`.
| 10-endpoint-with-microcks.provisioners.yaml | `endpoint` | (any) | `port`, `openapi_file`, `openapi_title` | `url` | Outputs an endpoint URL for connecting to an other workload (a Microcks mock is generated if not found).
| 10-env.provisioners.yaml | `environment` | (any) | (none) | (none) | Loads environment variables from a local `.env` file.
| 10-gcp-pubsub-emulator.provisioners.yaml | `gcp-pubsub-emulator` | (any) | `project_id` | `host`, `port`, `project_id`, `emulator_host` | Generates a Google Cloud Pub/Sub Emulator service for local development.
| 10-hpa.provisioners.yaml | `horizontal-pod-autoscaler` | (any) | (none) | (none) | Generates an empty object because HPA is not supported in Docker Compose.
| 10-dmr-llm-model-via-curl-cmd.provisioners.yaml | `llm-model` | (any) | `model` | `model`, `url`, `api-key` | Runs `curl` to download the model with the Docker Model Runner (DMR).
| 10-dmr-llm-model-via-curl-service.provisioners.yaml | `llm-model` | (any) | `model` | `model`, `url`, `api-key` | Generates a `curl` service downloading the model with the Docker Model Runner (DMR).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# GCP Pub/Sub Emulator provisioner
# For local development and testing without connecting to real GCP
- uri: template://community-provisioners/gcp-pubsub-emulator
type: gcp-pubsub-emulator
description: Generates a Google Cloud Pub/Sub Emulator service for local development.
supported_params:
- project_id
init: |
port: 8085
randomServiceName: pubsub-emulator-{{ randAlphaNum 6 | lower }}
defaultProjectId: test-project-{{ randAlphaNum 6 | lower }}
state: |
serviceName: {{ dig "serviceName" .Init.randomServiceName .State | quote }}
projectId: {{ dig "projectId" (.Params.project_id | default .Init.defaultProjectId) .State | quote }}
outputs: |
host: {{ .State.serviceName }}
port: {{ .Init.port }}
project_id: {{ .State.projectId }}
emulator_host: {{ .State.serviceName }}:{{ .Init.port }}
expected_outputs:
- host
- port
- project_id
- emulator_host
services: |
{{ .State.serviceName }}:
labels:
dev.score.compose.res.uid: {{ .Uid }}
image: gcr.io/google.com/cloudsdktool/google-cloud-cli:emulators
command:
- gcloud
- beta
- emulators
- pubsub
- start
- --host-port=0.0.0.0:{{ .Init.port }}
- --project={{ .State.projectId }}
restart: always
info_logs: |
- "{{ .Uid }}: Pub/Sub Emulator is running at {{ .State.serviceName }}:{{ .Init.port }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: score.dev/v1b1
metadata:
name: my-workload
containers:
my-container:
image: busybox
command: ["/bin/sh"]
args: ["-c", "while true; do echo $PUBSUB_EMULATOR_HOST; sleep 5; done"]
variables:
PUBSUB_HOST: "${resources.pubsub.host}"
PUBSUB_PORT: "${resources.pubsub.port}"
PUBSUB_PROJECT_ID: "${resources.pubsub.project_id}"
PUBSUB_EMULATOR_HOST: "${resources.pubsub.emulator_host}"
resources:
pubsub:
type: gcp-pubsub-emulator
params:
project_id: my-test-project
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,41 @@
mkdir install-more-tools
cd install-more-tools

# score-compose
SCORE_COMPOSE_VERSION=$(curl -sL https://api.github.com/repos/score-spec/score-compose/releases/latest | jq -r .tag_name)
wget https://github.com/score-spec/score-compose/releases/download/${SCORE_COMPOSE_VERSION}/score-compose_${SCORE_COMPOSE_VERSION}_linux_amd64.tar.gz
tar -xvf score-compose_${SCORE_COMPOSE_VERSION}_linux_amd64.tar.gz
chmod +x score-compose
sudo mv score-compose /usr/local/bin

# score-k8s
SCORE_K8S_VERSION=$(curl -sL https://api.github.com/repos/score-spec/score-k8s/releases/latest | jq -r .tag_name)
wget https://github.com/score-spec/score-k8s/releases/download/${SCORE_K8S_VERSION}/score-k8s_${SCORE_K8S_VERSION}_linux_amd64.tar.gz
tar -xvf score-k8s_${SCORE_K8S_VERSION}_linux_amd64.tar.gz
chmod +x score-k8s
sudo mv score-k8s /usr/local/bin

# kind
KIND_VERSION=$(curl -sL https://api.github.com/repos/kubernetes-sigs/kind/releases/latest | jq -r .tag_name)
curl -Lo ./kind https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind

# yq
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq
sudo chmod +x /usr/bin/yq

# docker model-plugin
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-model-plugin
docker model list

cd ..
rm -rf install-more-tools
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ score-compose init --provisioners https://raw.githubusercontent.com/score-spec/c
| 10-dns-with-url.provisioners.yaml | `dns` | (any) | (none) | `host`, `url` | Outputs a `*.localhost` domain as the hostname and associated URL in http on port `8080`.
| 10-endpoint-with-microcks.provisioners.yaml | `endpoint` | (any) | `port`, `openapi_file`, `openapi_title` | `url` | Outputs an endpoint URL for connecting to an other workload (a Microcks mock is generated if not found).
| 10-env.provisioners.yaml | `environment` | (any) | (none) | (none) | Loads environment variables from a local `.env` file.
| 10-gcp-pubsub-emulator.provisioners.yaml | `gcp-pubsub-emulator` | (any) | `project_id` | `host`, `port`, `project_id`, `emulator_host` | Generates a Google Cloud Pub/Sub Emulator service for local development.
| 10-hpa.provisioners.yaml | `horizontal-pod-autoscaler` | (any) | (none) | (none) | Generates an empty object because HPA is not supported in Docker Compose.
| 10-dmr-llm-model-via-curl-cmd.provisioners.yaml | `llm-model` | (any) | `model` | `model`, `url`, `api-key` | Runs `curl` to download the model with the Docker Model Runner (DMR).
| 10-dmr-llm-model-via-curl-service.provisioners.yaml | `llm-model` | (any) | `model` | `model`, `url`, `api-key` | Generates a `curl` service downloading the model with the Docker Model Runner (DMR).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# GCP Pub/Sub Emulator provisioner
# For local development and testing without connecting to real GCP
- uri: template://community-provisioners/gcp-pubsub-emulator
type: gcp-pubsub-emulator
description: Generates a Google Cloud Pub/Sub Emulator service for local development.
supported_params:
- project_id
init: |
port: 8085
randomServiceName: pubsub-emulator-{{ randAlphaNum 6 | lower }}
defaultProjectId: test-project-{{ randAlphaNum 6 | lower }}
state: |
serviceName: {{ dig "serviceName" .Init.randomServiceName .State | quote }}
projectId: {{ dig "projectId" (.Params.project_id | default .Init.defaultProjectId) .State | quote }}
outputs: |
host: {{ .State.serviceName }}
port: {{ .Init.port }}
project_id: {{ .State.projectId }}
emulator_host: {{ .State.serviceName }}:{{ .Init.port }}
expected_outputs:
- host
- port
- project_id
- emulator_host
services: |
{{ .State.serviceName }}:
labels:
dev.score.compose.res.uid: {{ .Uid }}
image: gcr.io/google.com/cloudsdktool/google-cloud-cli:emulators
command:
- gcloud
- beta
- emulators
- pubsub
- start
- --host-port=0.0.0.0:{{ .Init.port }}
- --project={{ .State.projectId }}
restart: always
info_logs: |
- "{{ .Uid }}: Pub/Sub Emulator is running at {{ .State.serviceName }}:{{ .Init.port }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: score.dev/v1b1
metadata:
name: my-workload
containers:
my-container:
image: busybox
command: ["/bin/sh"]
args: ["-c", "while true; do echo $PUBSUB_EMULATOR_HOST; sleep 5; done"]
variables:
PUBSUB_HOST: "${resources.pubsub.host}"
PUBSUB_PORT: "${resources.pubsub.port}"
PUBSUB_PROJECT_ID: "${resources.pubsub.project_id}"
PUBSUB_EMULATOR_HOST: "${resources.pubsub.emulator_host}"
resources:
pubsub:
type: gcp-pubsub-emulator
params:
project_id: my-test-project