-
Notifications
You must be signed in to change notification settings - Fork 99
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
feat: Update the helm chart #333
Conversation
Signed-off-by: Heba Elayoty <[email protected]>
I think this PR should happen after deploying |
Nothing related to AKS in this PR. |
command: | ||
- sh | ||
- -c | ||
- cd /app && sed "s/username/{{ .Values.image.auth.username }}/" -i appsettings.json && sed "s/password/{{ .Values.image.auth.password }}/" -i appsettings.json && dotnet CarbonAware.WebApi.dll |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
command
is needed? WebAPI container has ENTRYPOINT
.
For configuration, we should support environment value and/or JSON in deployment.yaml.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This command to inject the username and password into appsettings.json
. This file doesn't support env variable afaik.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can set username and account through environment variable: https://github.com/Green-Software-Foundation/carbon-aware-sdk/blob/dev/docs/quickstart.md#setting-up-the-web-api
Otherwise we should use ConfigMap here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to use Secret
to store credentials. So it is better approach to have both secrets and configmap (as JSON).
- cd /app && sed "s/username/{{ .Values.image.auth.username }}/" -i appsettings.json && sed "s/password/{{ .Values.image.auth.password }}/" -i appsettings.json && dotnet CarbonAware.WebApi.dll | ||
ports: | ||
- name: api-server-port | ||
containerPort: 7031 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be 80
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is 7031 for? I believe WebAPI container will expose 80, and it should be set as containerPort.
be044b7
to
df4a3c6
Compare
Signed-off-by: Heba Elayoty <[email protected]>
Signed-off-by: Heba Elayoty <[email protected]>
command: | ||
- sh | ||
- -c | ||
- cd /app && sed "s/username/{{ .Values.image.auth.username }}/" -i appsettings.json && sed "s/password/{{ .Values.image.auth.password }}/" -i appsettings.json && dotnet CarbonAware.WebApi.dll |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can set username and account through environment variable: https://github.com/Green-Software-Foundation/carbon-aware-sdk/blob/dev/docs/quickstart.md#setting-up-the-web-api
Otherwise we should use ConfigMap here.
- port: {{ .Values.service.port }} | ||
targetPort: api-server-port |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you want to specify the port what the user want to expose in values.yaml, and also it should be so. Thus api-server-port
should be set to port
, and also .Values.service,.port
should be set to targetPort
?
auth: | ||
username: username | ||
password: password |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should consider other parameters (e.g. data source) if we can set them via environment variables and/or ConfigMap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This YAML is no longer needed.
kind: Deployment | ||
metadata: | ||
name: {{ include "carbon-aware-sdk.fullname" . }} | ||
namespace: {{ .Values.namespace }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use .Release.namespace
rather than the value from values.yaml. https://helm.sh/docs/chart_template_guide/builtin_objects/
## Push an image to the Docker registry | ||
|
||
The following steps illustrates how to push a webservice image in order to be | ||
deployed in Kubernetes clsuter. | ||
|
||
1. Build an image using the following | ||
[Dockerfile](.../../../../src/CarbonAware.WebApi/src/Dockerfile) | ||
|
||
```sh | ||
cd <Dockerfile path> | ||
docker build -t <registry>/myapp:v1 . | ||
``` | ||
|
||
1. Login into docker using the username and password credentials that are needed in | ||
order to push. | ||
|
||
```sh | ||
docker login | ||
``` | ||
|
||
1. Push to Docker registry | ||
|
||
```sh | ||
docker push <registry>/myapp:v1 | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section is not needed because default values.yaml refers container image from GitHub Container Registry.
Set the `nameOverride` and `fullNameOverride` fields to make it easier to | ||
reference your helm chart, and ensure they are not the same. | ||
|
||
In the `serviceAccount` section, ensure that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
serviceAccount
is no longer needed.
In the `monitorConfig` section, you will need to adjust the `liveness` and | ||
`readiness` that the helm chart will ping to ensure the sdk is ready. As a | ||
default, you should set the path to `/health`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is monitorConfig
? Liveness / Startup probe should be set into the deployment yaml.
In `Chart.yaml`, we won't need to make any changes but make note of the chart | ||
`name`, as you will need to reference it in commands later on. | ||
|
||
### Values.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should guide account settings for data source.
To install your helm chart, you should run | ||
|
||
```bash | ||
helm install carbon-aware ./samples/helm-deploy/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is better to good with -n <namespace>
and --create-namespace
. IMHO carbon-aware-sdk
is good for namespace.
@YaSuenag - are you able to fork the source branch helayoty:helm-update and add your changes, and do a separate PR for those updates please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some changes as a suggestion. Please apply if you are ok, then I will try to send PR for your branch because some files will be added/removed.
## Push an image to the Docker registry | ||
|
||
The following steps illustrates how to push a webservice image in order to be | ||
deployed in Kubernetes clsuter. | ||
|
||
1. Build an image using the following | ||
[Dockerfile](.../../../../src/CarbonAware.WebApi/src/Dockerfile) | ||
|
||
```sh | ||
cd <Dockerfile path> | ||
docker build -t <registry>/myapp:v1 . | ||
``` | ||
|
||
1. Login into docker using the username and password credentials that are needed in | ||
order to push. | ||
|
||
```sh | ||
docker login | ||
``` | ||
|
||
1. Push to Docker registry | ||
|
||
```sh | ||
docker push <registry>/myapp:v1 | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## Push an image to the Docker registry | |
The following steps illustrates how to push a webservice image in order to be | |
deployed in Kubernetes clsuter. | |
1. Build an image using the following | |
[Dockerfile](.../../../../src/CarbonAware.WebApi/src/Dockerfile) | |
```sh | |
cd <Dockerfile path> | |
docker build -t <registry>/myapp:v1 . | |
``` | |
1. Login into docker using the username and password credentials that are needed in | |
order to push. | |
```sh | |
docker login | |
``` | |
1. Push to Docker registry | |
```sh | |
docker push <registry>/myapp:v1 | |
``` |
In the `serviceAccount` section, ensure that | ||
|
||
- The `name` field is set to the name of the helm chart from `Chart.yaml`. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the `serviceAccount` section, ensure that | |
- The `name` field is set to the name of the helm chart from `Chart.yaml`. |
To install your helm chart, you should run | ||
|
||
```bash | ||
helm install carbon-aware ./samples/helm-deploy/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
helm install carbon-aware ./samples/helm-deploy/ | |
helm install -n carbon-aware-sdk --create-namespace carbon-aware ./samples/helm-deploy/ |
kind: Deployment | ||
metadata: | ||
name: {{ include "carbon-aware-sdk.fullname" . }} | ||
namespace: {{ .Values.namespace }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
namespace: {{ .Values.namespace }} | |
namespace: {{ .Release.namespace }} |
- cd /app && sed "s/username/{{ .Values.image.auth.username }}/" -i appsettings.json && sed "s/password/{{ .Values.image.auth.password }}/" -i appsettings.json && dotnet CarbonAware.WebApi.dll | ||
ports: | ||
- name: api-server-port | ||
containerPort: 7031 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
containerPort: 7031 | |
containerPort: 80 |
ports: | ||
- name: api-server-port | ||
containerPort: 7031 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
startupProbe: | |
httpGet: | |
path: /health | |
port: 80 | |
failureThreshold: 10 | |
periodSeconds: 5 | |
livenessProbe: | |
httpGet: | |
path: /health | |
port: 80 | |
periodSeconds: 30 |
kind: Service | ||
metadata: | ||
name: carbon-aware-sdk | ||
namespace: {{ .Values.namespace }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
namespace: {{ .Values.namespace }} | |
namespace: {{ .Release.namespace }} |
I think Helm chart for CASDK should be official artifact, not an example, and also it should be published for the user can install it via Helm. So I'd like to propose the chart and GHA workflow to publish it as a container. How about it? dev...YaSuenag:carbon-aware-sdk:dev-helm This branch would publish Helm chart to GitHub container registry, so you can pull it as a chart via You can set values.yaml image:
tag: v1.1.0
appsettings: |-
{
"DataSources": {
"EmissionsDataSource": "WattTime",
"ForecastDataSource": "WattTime",
"Configurations": {
"WattTime": {
"Type": "WattTime",
"Username": "username",
"Password": "password",
"BaseURL": "https://api2.watttime.org/v2/"
}
}
}
} Install command
@vaughanknight @Willmish @danuw Can you agree with publishing Helm chart container from GitHub container registry of CASDK? I believe it can help the user who want to use the SDK on Kubernetes. My Helm chart repo is here: https://github.com/YaSuenag/carbon-aware-sdk/pkgs/container/charts%2Fcarbon-aware-sdk |
Sounds great! Would love to test this too if we can find time to connect. Fyi I cant make it Tuesday morning so I will connect directly Thank you yasumasa |
@helayoty Can I take over this PR? I'll create new one from my side if you are ok. |
Pull Request
Issue Number: (Link to Github Issue or Azure Dev Ops Task/Story)
Summary
One sentence summary of PR
Changes
Checklist
Are there API Changes?
If yes, what are the expected API Changes? Please link to an API-Comparison
workflow with the API Diff.
Is this a breaking change?
If yes, what workflow does this break?
Anything else?
Other comments, collaborators, etc.
This PR Closes #<issue_number>