Environment
.env
(view on GitHub)
:
TEST=testtest
score.yaml
(view on GitHub)
:
apiVersion: score.dev/v1b1
metadata:
name: my-workload
containers:
my-container:
image: busybox
command: ["/bin/sh"]
args: ["-c", "while true; do echo $TEST; cat /file.txt; sleep 5; done"]
variables:
TEST: ${resources.env.TEST}
files:
- target: /file.txt
mode: "0644"
content: "${resources.env.TEST} in file.\n"
resources:
env:
type: environment
10-env.provisioners.yaml
(view on GitHub)
:
- uri: cmd://python3#dotenv
type: environment
description: Loads environment variables from a local .env file.
args:
- -c
- |
import json
with open('.env') as f:
content = f.read().strip()
env_map = dict([x.split("=",1) for x in content.strip().splitlines()])
print(json.dumps({"resource_outputs": env_map}))
README.md
(view on GitHub)
:
Prerequisites:
- Have `python` installed, this provisioner is using Python to load the `.env` file.
Initialize your local workspace, by importing a specific community provisioner:
score-commpose 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.
Get the provisioners definition:
score-compose provisioners list
Generate the platform specific manifests:
score-commpose generate score.yaml
See the resource outputs:
score-commpose resources list
You can run the following command on each resource listed with the previous command to get their outputs
:
score-commpose resources get-outputs
Deploy the generated manifests:
docker compose up -d
See the running containers:
docker ps
10-env.provisioners.yaml
(view on GitHub)
:
- uri: cmd://python3#dotenv
type: environment
description: Loads environment variables from a local .env file.
args:
- -c
- |
import json
with open('.env') as f:
content = f.read().strip()
env_map = dict([x.split("=",1) for x in content.strip().splitlines()])
print(json.dumps({"resource_outputs": env_map}))
README.md
(view on GitHub)
:
Prerequisites:
- Have `python` installed, this provisioner is using Python to load the `.env` file.
Initialize your local workspace, by importing a specific community provisioner:
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.
Get the provisioners definition:
score-k8s provisioners list
Generate the platform specific manifests:
score-k8s generate score.yaml
See the resource outputs:
score-k8s resources list
You can run the following command on each resource listed with the previous command to get their outputs
:
score-k8s resources get-outputs
Deploy the generated manifests:
kubectl apply -f manifests.yaml
See the running containers:
kubectl get all