Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

helayoty
Copy link

Pull Request

Issue Number: (Link to Github Issue or Azure Dev Ops Task/Story)

Summary

One sentence summary of PR

Changes

  • List of comprehensive changes

Checklist

  • Local Tests Passing?
  • CICD and Pipeline Tests Passing?
  • Added any new Tests?
  • Documentation Updates Made?
  • Are there any API Changes? If yes, please describe below.
  • This is not a breaking change. If it is, please describe it below.

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.

Please follow
GitHub's suggested syntax
to link Pull Requests to Issues via keywords

This PR Closes #<issue_number>

Signed-off-by: Heba Elayoty <[email protected]>
@YaSuenag
Copy link
Contributor

I think this PR should happen after deploying 4-release.yml in the plan, but I want you to ask that this example still aims to deploy to AKS? I think it is more useful if it is general, and we can be so because Helm is not only for AKS.

@helayoty
Copy link
Author

I think this PR should happen after deploying 4-release.yml in the plan, but I want you to ask that this example still aims to deploy to AKS? I think it is more useful if it is general, and we can be so because Helm is not only for AKS.

Nothing related to AKS in this PR.

samples/helm-deploy/values.yaml Outdated Show resolved Hide resolved
samples/helm-deploy/values.yaml Outdated Show resolved Hide resolved
samples/helm-deploy/values.yaml Outdated Show resolved Hide resolved
Comment on lines +27 to +30
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
Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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).

samples/helm-deploy/templates/deployment.yaml Outdated Show resolved Hide resolved
- 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be 80?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not necessary

Copy link
Contributor

@YaSuenag YaSuenag Jun 17, 2023

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.

@helayoty helayoty force-pushed the helm-update branch 2 times, most recently from be044b7 to df4a3c6 Compare June 16, 2023 19:52
Signed-off-by: Heba Elayoty <[email protected]>
Signed-off-by: Heba Elayoty <[email protected]>
@helayoty helayoty requested a review from YaSuenag June 16, 2023 20:14
Comment on lines +27 to +30
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
Copy link
Contributor

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.

Comment on lines +11 to +12
- port: {{ .Values.service.port }}
targetPort: api-server-port
Copy link
Contributor

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?

Comment on lines +13 to +15
auth:
username: username
password: password
Copy link
Contributor

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.

Copy link
Contributor

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 }}
Copy link
Contributor

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/

Comment on lines +7 to +31
## 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
```
Copy link
Contributor

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
Copy link
Contributor

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.

Comment on lines +70 to +72
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`.
Copy link
Contributor

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
Copy link
Contributor

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/
Copy link
Contributor

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.

@Willmish
Copy link
Collaborator

Thanks for contiuing to work on this!
@helayoty can you look at @YaSuenag comments + review?

@vaughanknight
Copy link
Contributor

@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?

Copy link
Contributor

@YaSuenag YaSuenag left a 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.

Comment on lines +7 to +32
## 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
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## 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
```

Comment on lines +66 to +69
In the `serviceAccount` section, ensure that

- The `name` field is set to the name of the helm chart from `Chart.yaml`.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
containerPort: 7031
containerPort: 80

ports:
- name: api-server-port
containerPort: 7031

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
namespace: {{ .Values.namespace }}
namespace: {{ .Release.namespace }}

@YaSuenag
Copy link
Contributor

YaSuenag commented Aug 5, 2023

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 helm command when you use Helm v3.8.0 or later: https://helm.sh/docs/topics/registries/

You can set appsettings.json as a Secret resource, and deploy CASDK.

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

helm install casdk -n carbon-aware-sdk --create-namespace oci://ghcr.io/yasuenag/charts/carbon-aware-sdk --values casdk-values.yaml

@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

@danuw
Copy link
Collaborator

danuw commented Aug 5, 2023

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

@YaSuenag
Copy link
Contributor

YaSuenag commented Aug 6, 2023

@helayoty Can I take over this PR? I'll create new one from my side if you are ok.

@YaSuenag YaSuenag mentioned this pull request Aug 8, 2023
6 tasks
@YaSuenag
Copy link
Contributor

YaSuenag commented Aug 8, 2023

Thanks @helayoty for giving +1 emoji! I've created new PR. It's appreciated if you can review.

#381

And also this PR should be closed, I think.

@helayoty helayoty closed this Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants