-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support of the environment
resource?
#24
Comments
@mathieu-benoit at the community meeting last week we discussed the following: Until we have a clear idea of how to interpret "environment" in score-k8s (possibly a configmap?) we'd recommend users to implement custom resource provisioners based on their use case. The suggestion was to update the error message and make this more clear. For example
Curious to hear what you think! |
@sujaya-sys I've tried implementing this with a custom provisioner and failed. shared_state:
environment: develop then tried loading a file with the same name - uri: cmd://bash
type: environment
args:
- -c
- |
echo '{"resource_outputs":{'
while IFS=': ' read -r key value; do
echo "\"$key\": \"$value\""
done < {{ .Shared.environment }}.env
echo '},"manifests":[]}'
Sadly doesn't work, surprisingly because there is no templating in How would you recommend to implement this? |
@astromechza any chance you could have a quick look at this and provide some guidance here? Thanks so much! |
@maxstepanov to setup a custom
You should not need to modify state.yaml 🤔 What was the goal with the I don't think we should support templating in the cmd provisioners because it's a security concern. It allows values in the Score workload to change what binaries and arguments are executed rather than the ones intended by the team providing the custom provisioners file. |
@astromechza i was trying to implement loading of environment variables from files, Should In case of a CMD provider route how would it figure out which file to read? Is there a way to pass it via cli? |
The guidance is that you create an environment-specific provisioners file, like: develop.provisioners.yaml
Or if you want to cat a file on disk
where develop.env contains
Then you use your target environment to add a different |
Thank you for the guidance. First option is no go for us. Not gonna force
developers to write provisioners. The second option is feasible.
This issue seems to be a documentation issue since there is no intent to
support environment resource out of the box.
…On Wed, Sep 4, 2024, 20:14 Ben Meier ***@***.***> wrote:
The guidance is that you create an environment-specific provisioners file,
like:
develop.provisioners.yaml
- uri: template://develop-env
type: environment
outputs:
KEY: VALUE
KEY2: VALUE2
Or if you want to cat a file on disk
- uri: cmd://bash
type: environment
args:
- -c
- "cat ./develop.env"
where develop.env contains
{"resource_outputs":{
"KEY": "VALUE",
"KEY2": "VALUE2"
}}
Then you use your target environment to add a different
ENV.provisioners.yaml file into the .score-k8s/ directory.
—
Reply to this email directly, view it on GitHub
<#24 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAESDHZ6YWZVC7ZDEOOWWNLZU45VTAVCNFSM6AAAAABLQ2JAH2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRZGU4TEMZUHA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@maxstepanov unfortunately there is no default behavior here that works for everyone, so a custom environment provisioner is necessary. It only needs to be written once, and installed as part of your score init process. Here's a working example that loads a .env file:
So I run score-k8s init and copy the content into a custom-provisioner file. (I'm working on a quick install flag here now). |
environment
resource?environment
resource?
@astromechza how to handle the following situation. I'm using Here is my - uri: template://custom/pubsubtopic
type: pubsubtopic
init: |
{{ if not .Params.name }}{{ fail "params.name must be specified" }}{{ end }}
state: |
{{ if not .State.name }}
name: "{{ .Shared.environment }}-{{ .Params.name }}-{{ randAlpha 6 | lower }}"
{{ else }}
name: "{{ .State.name }}"
{{ end }}
outputs: |
name: "{{ .State.name }}"
manifests: |
- apiVersion: pubsub.cnrm.cloud.google.com/v1beta1
kind: PubSubTopic
metadata:
name: "{{ .State.name }}" Is there a better way? |
@maxstepanov generally your provisioners define the environment, so you'd pull in different provisioners based on your environment. In Humanitec for example, they can use "matching criteria" to link different provisioners based on the environment. Humanitec also supports hierarchical provisioners, so resources can refer to the outputs of other resources. |
@astromechza thank you. it's much clearer now.
That was kinda my next question. Support for shared resources between workloads. Basically using outputs of resources from a different workload in the same state. I guess this is for separate issue. |
If doing this:
Getting this error:
While it's supported by
score-compose
by default: https://github.com/score-spec/score-compose/blob/main/internal/provisioners/envprov/envprov.go.The text was updated successfully, but these errors were encountered: