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 Helm chart image #12

Merged
merged 8 commits into from
Dec 28, 2023
Merged
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
31 changes: 28 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,31 @@ jobs:
platforms: linux/amd64
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/cost-manager:${{ env.BRANCH == 'main' && 'latest' || env.BRANCH }}
# https://docs.docker.com/build/ci/github-actions/cache/#registry-cache
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/cost-manager:buildcache
cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/cost-manager:buildcache,mode=max
# https://docs.docker.com/build/ci/github-actions/cache/#github-cache
cache-from: type=gha
cache-to: type=gha,mode=max
kind:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: azure/setup-helm@v3
with:
version: v3.12.1
- run: |
helm lint --strict ./charts/cost-manager
- uses: helm/[email protected]
- name: Install CRDs
run: |
kubectl apply -f https://raw.githubusercontent.com/kubernetes/autoscaler/5469d7912072c1070eedc680c89e27d46b8f4f82/vertical-pod-autoscaler/deploy/vpa-v1-crd-gen.yaml
- name: Install cost-manager
# Use bash shell to set pipefail option:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell
shell: bash
run: |
kubectl create namespace cost-manager
helm template ./charts/cost-manager \
-n cost-manager \
--set iam.gcp.serviceAccount=cost-manager@example.iam.gserviceaccount.com \
--set vpa.enabled=true | kubectl apply -f -
kubectl wait --for=condition=Available=true deployment/cost-manager -n cost-manager --timeout=10m
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ your cluster must be running at least one on-demand node pool and at least one s

## Quickstart

When using spot-migrator on GCP, cost-manager requires the
[roles/compute.instanceAdmin](https://cloud.google.com/iam/docs/understanding-roles#compute.instanceAdmin)
role to delete compute instances from GKE managed instance groups.

cost-manager can be run locally:

```sh
Expand All @@ -44,21 +48,16 @@ cost-manager can be run locally:
make run
```

Alternatively, you can run cost-manager within a Kubernetes cluster:
Alternatively, you can run cost-manager within a GKE Kubernetes cluster with [Workload
Identity](https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity) enabled:

```sh
# Build the Docker image
make image
REPOSITORY=""
docker tag cost-manager "$REPOSITORY"
docker push "$REPOSITORY"
# GCP service account bound to the roles/compute.instanceAdmin role
GCP_SERVICE_ACCOUNT_EMAIL_ADDRESS="[email protected]"
kubectl create namespace cost-manager --dry-run=client -o yaml | kubectl apply -f
helm template ./charts/cost-manager \
-n cost-manager \
--set image.repository="$REPOSITORY" \
--set iam.gcpServiceAccount="$GCP_SERVICE_ACCOUNT_EMAIL_ADDRESS" \
--set iam.gcp.serviceAccount="$GCP_SERVICE_ACCOUNT_EMAIL_ADDRESS" \
--set vpa.enabled=true | kubectl apply -f -
```

Expand Down
4 changes: 2 additions & 2 deletions charts/cost-manager/templates/service-account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: ServiceAccount
metadata:
name: cost-manager
namespace: {{ .Release.Namespace }}
{{- if .Values.iam.gcpServiceAccount }}
{{- if .Values.iam.gcp.serviceAccount }}
annotations:
iam.gke.io/gcp-service-account: {{ .Values.iam.gcpServiceAccount }}
iam.gke.io/gcp-service-account: {{ .Values.iam.gcp.serviceAccount }}
{{- end }}
8 changes: 5 additions & 3 deletions charts/cost-manager/values.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
image:
pullPolicy: IfNotPresent
repository: docker.io/hsbc/cost-manager
# TODO(dippynark): Use HSBC Docker Hub repository
repository: docker.io/dippynark/cost-manager
tag: latest

# Specify GCP Workload Identity service account email address bound to the
# roles/compute.instanceAdmin role to allow instance deletion:
# roles/compute.instanceAdmin role to allow compute instance deletion:
# https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity
iam:
gcpServiceAccount: ""
gcp:
serviceAccount: ""

# Create VPA to vertically autoscale cost-manager:
# https://cloud.google.com/kubernetes-engine/docs/concepts/verticalpodautoscaler
Expand Down