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

[SDO-2649] Kubernetes Optimizer Project #103

Closed
wants to merge 70 commits into from
Closed
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
5a066d0
Add Controller Helm chart and add it as dependency
gm-cht Oct 4, 2023
8bce2f2
Dependent helm chart optinal
gm-cht Oct 10, 2023
19f325b
Configure CronJob
gm-cht Oct 13, 2023
acb0230
Add CRD permissions
gm-cht Oct 16, 2023
1b0cb7c
Change image name
gm-cht Oct 16, 2023
02ef1d3
Update version to get a new chart
gm-cht Oct 16, 2023
6cb0cff
Add chapi token as secret
gm-cht Oct 16, 2023
fc44d64
Move to including the built chart as dependency.
gm-cht Oct 16, 2023
411d2c8
add cron schedule
gm-cht Oct 17, 2023
db51661
Update tgz file dependency path
gm-cht Oct 17, 2023
f0c4bb9
Fix helm
gm-cht Oct 17, 2023
423821f
Update Chart version
gm-cht Oct 17, 2023
efa7ceb
revert change to release.yml
gm-cht Oct 17, 2023
60193dc
Some fixes
gm-cht Oct 17, 2023
197d433
package controller helm
gm-cht Oct 18, 2023
f50700e
Add helm chart instead of tgz file
gm-cht Oct 18, 2023
fa8fd4a
Fix image repo and name of controller
gm-cht Oct 18, 2023
8eb061a
Update gitignore and github actions
gm-cht Oct 18, 2023
7c60635
Add new commands to Notes
gm-cht Oct 18, 2023
b593ab1
Re-add github action for this branch
gm-cht Oct 18, 2023
31a55fe
Update version to get PR build passing
gm-cht Oct 18, 2023
7ddb78e
Fix version number of controller image
gm-cht Oct 18, 2023
d2dd2c9
Fix Cron Job
gm-cht Oct 19, 2023
8e02f86
Fix parameter name
gm-cht Oct 19, 2023
5b09c25
Add Spring Profile parameter
gm-cht Oct 19, 2023
187af4d
Update controller image registry
gm-cht Oct 19, 2023
bbe43fc
Update path of controller helm chart. Remove subchart
gm-cht Oct 19, 2023
7292c25
Update controller version
gm-cht Oct 19, 2023
3867720
Generate correct 5.1.0-alpha chart
gm-cht Oct 20, 2023
da4f915
5.1.1-alpha chart
gm-cht Oct 20, 2023
c58b4f2
Regenrate helm for 0.2.0 controller
gm-cht Oct 20, 2023
5ba759a
Generate helm for 1.0.0-beta version of controller
gm-cht Oct 20, 2023
53ddb2c
5.1.0-alpha for 0.2.0-beta controller
gm-cht Oct 20, 2023
824bb38
5.2.0-alpha for 1.0.0-beta version of controller
gm-cht Oct 20, 2023
8c3b593
chapiToken to chapiKey.
gm-cht Oct 20, 2023
1b29659
Better name for cronJob pod
gm-cht Oct 20, 2023
7fa3c48
Add ClusterRole. Fix some yaml syntax issues in values.yaml
gm-cht Oct 20, 2023
3972a60
Fixed YAML syntax on values.yaml
gm-cht Oct 20, 2023
cbbddaa
Add Getting CRDs permission
gm-cht Oct 20, 2023
1b41fcf
Add create permissions to serviceAccount. Also make these permissions…
gm-cht Oct 20, 2023
de7e6b7
Squashed commit of the following:
gm-cht Oct 20, 2023
4500812
Merge branch 'main' into gmudumbai/sdo-2649-k8s-optimizer
gm-cht Oct 20, 2023
a43249e
Fixes due to merge
gm-cht Oct 23, 2023
8247611
Fix english
gm-cht Oct 23, 2023
485fae9
Move registry to `kubernetes-optimization`
gm-cht Oct 23, 2023
988a36e
Remove Image tags from being overridden in main chart
gm-cht Oct 23, 2023
b2fc51f
Change imagePullPolicy
gm-cht Oct 25, 2023
9c18deb
Update permissions
gm-cht Oct 25, 2023
14c2074
Set default requests and limits for optimizer agent.
gm-cht Oct 30, 2023
1c21afc
Beta Version release
gm-cht Oct 31, 2023
e76377a
Fix ReadMe
gm-cht Nov 1, 2023
64854f6
Fixed Notes
gm-cht Nov 1, 2023
13d9428
Minor Chart version change
gm-cht Nov 1, 2023
03c2529
Add better checks for cluster_name
gm-cht Nov 13, 2023
6253cd7
Merge branch 'main' into gmudumbai/sdo-2649-k8s-optimizer
gm-cht Nov 13, 2023
b7337cd
Change clusterName check to minimum 3 characters and minInterval to 1…
gm-cht Nov 14, 2023
3b47c17
Update Optimization controller to 1.0.2-beta
gm-cht Nov 27, 2023
d13e30f
Merge branch 'main' into gmudumbai/sdo-2649-k8s-optimizer
gm-cht Dec 12, 2023
6160189
Merge branch 'main' into gmudumbai/sdo-2649-k8s-optimizer
gm-cht Dec 14, 2023
741386b
k8s-optimizer-1.0.0-beta
gm-cht Jan 2, 2024
80d20df
Fix optimizer version to 1.1.0
gm-cht Jan 2, 2024
e785c9e
Merge branch 'main' into gmudumbai/sdo-2649-k8s-optimizer
gm-cht Jan 25, 2024
cb826cf
Hardcode Optimizer Agent Image to 1.0.0-18
gm-cht Jan 29, 2024
d052fc2
Update Optimizer Agent to 1.0.0-19
gm-cht Jan 31, 2024
1e87155
Update to Controller 1.1.1 & Increase CPU/Mem of optimizer and Contro…
gm-cht Feb 1, 2024
b630e7c
Update Optimizer Agent to 1.0.0-20 (#115)
kscherme Feb 20, 2024
3951fd3
Merge branch 'main' into gmudumbai/sdo-2649-k8s-optimizer
gm-cht Mar 11, 2024
23f17f9
[SDO-2961] Update controller dependency to JFrog repo (#120)
kscherme May 28, 2024
92790c6
set branch releases as not latest
kscherme Jun 4, 2024
a08a3b4
update releaser version
kscherme Jun 4, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- gmudumbai/sdo-2649-k8s-optimizer

jobs:
release:
Expand Down
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Use the helm chart to deploy the CloudHealth Collector into each [Kubernetes](ht
- Helm 3.0+
- CloudHealth API Token

## Installing the Chart
## Installing the Collector Chart

To install the chart with the release name `cloudhealth-collector`, run the following command:

Expand All @@ -36,7 +36,7 @@ To install the chart with the release name `cloudhealth-collector` in a particul

```console
$ helm repo add cloudhealth https://cloudhealth.github.io/helm/
$ helm install cloudhealth-collector -n <target_namespace> --set apiToken=<Unique Customer API Token>,clusterName=<Cluster Name>,chtRegion=<Cloudhealth Region> cloudhealth/cloudhealth-collector
$ helm install cloudhealth-collector -n <target_namespace> --create-namespace --set apiToken=<Unique Customer API Token>,clusterName=<Cluster Name>,chtRegion=<Cloudhealth Region> cloudhealth/cloudhealth-collector
```

The `apiToken` is required for `cloudhealth-collector` to work and should be either set while running helm install command as in the example above or in a secret object with the following data structure:
Expand All @@ -49,6 +49,22 @@ These commands deploy the CloudHealth Collector on the Kubernetes cluster in the

> **Tip**: List all releases using `helm list`

## Installing the Collector & Optimizer Chart

To install the chart with the release name `cloudhealth-collector-optimizer`, run the following command:
gm-cht marked this conversation as resolved.
Show resolved Hide resolved
gm-cht marked this conversation as resolved.
Show resolved Hide resolved

```console
$ helm repo add cloudhealth https://cloudhealth.github.io/helm/
$ helm install cloudhealth-collector-optimizer --set apiToken=<Unique Customer API Token>,clusterName=<Cluster Name>,chtRegion=<Cloudhealth Region>,optimizer.enabled=true,chapiKey=<CloudHealth API Key> cloudhealth/cloudhealth-collector
```

To install the chart with the release name `cloudhealth-collector-optimizer` in a particular namespace `<target_namespace>`, run the following commands:
gm-cht marked this conversation as resolved.
Show resolved Hide resolved

```console
$ helm repo add cloudhealth https://cloudhealth.github.io/helm/
$ helm install cloudhealth-collector-optimizer -n <target_namespace> --create-namespace --set apiToken=<Unique Customer API Token>,clusterName=<Cluster Name>,chtRegion=<Cloudhealth Region>,optimizer.enabled=true,chapiKey=<CloudHealth API Key> cloudhealth/cloudhealth-collector
```

## Updating the Chart

To update an existing release to the latest version of the chart, run the following command:
Expand Down
9 changes: 7 additions & 2 deletions charts/cloudhealth-collector/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@

apiVersion: v2
name: cloudhealth-collector

Choose a reason for hiding this comment

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

Should the name change now (to something like cloudhealth-collector-and-optimizer)?

Copy link
Contributor Author

@gm-cht gm-cht Oct 23, 2023

Choose a reason for hiding this comment

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

Did not change this to keep the workflow and instructions the same for customers who are using only collector.

If and when we change this:
since the repo itself is called cloudhealth i prefer changing the helm chart to kubernetes-collector.
I prefer this command: helm install kubernetes-collector .... cloudhealth/kubernetes-collector to helm install cloudhealth-collector ....... cloudhealth/cloudhealth-collector.

Don't think we want to change the helm chart name without a wider discussion and announcement. Having optimizer in the name might also warrant discussion given most of our customers will be collector only customers.

description: A Helm chart for CloudHealth's Kubernetes Collector Agent
description: A Helm chart for CloudHealth's Kubernetes Collector and Optimizer Agent
type: application
version: 4.2.0
version: 5.5.0-beta
kscherme marked this conversation as resolved.
Show resolved Hide resolved
appVersion: "5.1.0"
dependencies:
- name: k8s-optimization
repository: oci://projects.registry.vmware.com/kubernetes-optimization
version: 1.0.0-beta
condition: optimizer.enabled
home: https://cloudhealth.vmware.com/
icon: https://d1fto35gcfffzn.cloudfront.net/images/Tanzu-Logomark.svg
sources:
Expand Down
5 changes: 5 additions & 0 deletions charts/cloudhealth-collector/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,8 @@ upload_k8s_state_v2 --verbose --endpoint http://<your_ip_address>:9292
helm install cloudhealth-collector --debug --dry-run --set apiToken=$CHT_API_TOKEN,clusterName=$CHT_CLUSTER_NAME,chtRegion=$CHT_REGION,image.repository=latest-libs-06-13-3,image.pullPolicy=Never --set devArgs="\['upload_k8s_state_v2'\,'--verbose'\,'--endpoint'\,'http://<your_ip_address>:9292'\]",podSecurityContext.fsGroup=2000,containerSecurityContext.readOnlyRootFilesystem=true,containerSecurityContext.runAsNonRoot=true,containerSecurityContext.runAsUser=1000,containerSecurityContext.capabilities.drop={ALL} ./cloudhealth-collector-1.1.3.tgz

helm install cloudhealth-collector --debug --dry-run --set apiToken=$CHT_API_TOKEN,clusterName=$CHT_CLUSTER_NAME,chtRegion=$CHT_REGION,image.repository=latest-libs-06-13-3,image.pullPolicy=Never --set devArgs="\['upload_k8s_state_v2'\,'--verbose'\,'--endpoint'\,'http://<your_ip_address>:9292'\]" --set "customEnvVars[0].name=ENV4" --set "customEnvVars[0].value=VALUE4" --set serviceAccount.name=sample_service_account ./cloudhealth-collector-1.1.2.tgz

NEW ALPHA IMAGE INSTRUCTIONS:
helm install cloudhealth-collector --debug --dry-run -n cloudhealth --set optimizer.enabled=true,optimizer.chapiKey=xyzabc,clusterName=test-cluster,apiToken=tttyyy cloudhealth/cloudhealth-collector --version 5.0.6-alpha

helm install cloudhealth-collector --debug --dry-run -n cloudhealth --set clusterName=test-cluster,apiToken=tttyyy cloudhealth/cloudhealth-collector --version 5.0.6-alpha
kscherme marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 15 additions & 0 deletions charts/cloudhealth-collector/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,18 @@ Create the name of the secrets to use
{{- define "cloudhealth-collector.secretName" -}}
{{- default .Values.secretName }}
{{- end }}

{{/*
Create the name for CH Optimizer Agent
*/}}
{{- define "cloudhealth-optimizer-agent.name" -}}
{{- default .Values.optimizer.name }}
{{- end }}

{{/*
CH Optimizer Agent Selector labels
*/}}
{{- define "cloudhealth-optimizer-agent.selectorLabels" -}}
app.kubernetes.io/name: {{ include "cloudhealth-optimizer-agent.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
11 changes: 11 additions & 0 deletions charts/cloudhealth-collector/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,14 @@ rules:
- apiGroups: ["batch"]
resources: ["cronjobs", "jobs"]
verbs: ["get", "list"]
{{- if .Values.optimizer.enabled }}
- apiGroups: ["cloudhealth.containers.com"]
resources: ["rz-recommendation-settings"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
- apiGroups: ["apiextensions.k8s.io"]
resources: ["customresourcedefinitions"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
- apiGroups: ["k8so.vmware.com"]
resources: ["optimizationrecommendations"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
{{- end }}
4 changes: 2 additions & 2 deletions charts/cloudhealth-collector/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default "latest" }}"
kscherme marked this conversation as resolved.
Show resolved Hide resolved
imagePullPolicy: {{ .Values.image.pullPolicy }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
Expand Down Expand Up @@ -61,7 +61,7 @@ spec:
name: {{ include "cloudhealth-collector.secretName" . }}
key: apiToken
- name: CHT_CLUSTER_NAME
value: {{.Values.clusterName | required "A valid clusterName required!" | quote }}
value: {{.Values.clusterName | required "A valid clusterName is required!" | quote }}
- name: CHT_REGION
value: {{.Values.chtRegion | default "us-east-1" }}
- name: CHT_INTERVAL
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{{- /*
Copyright 2023 VMware, Inc.
SPDX-License-Identifier: Apache-2.0
*/}}

{{- if .Values.optimizer.enabled }}
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "cloudhealth-optimizer-agent.name" . }}
labels:
{{- include "cloudhealth-collector.labels" . | nindent 4 }}
{{- with .Values.deployAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
schedule: "0 12 * * *"
jobTemplate:
spec:
template:
spec:
serviceAccountName: {{ include "cloudhealth-collector.serviceAccountName" . }}
containers:
- name: {{ include "cloudhealth-optimizer-agent.name" . }}
env:
- name: CHAPI_KEY
valueFrom:
secretKeyRef:
name: {{ include "cloudhealth-collector.secretName" . }}
key: chapiKey
- name: CHT_CLUSTER_NAME
value: {{.Values.clusterName | required "A valid clusterName is required!" | quote }}
- name: CHT_REGION
value: {{.Values.chtRegion | default "us-east-1" }}
- name: SPRING_PROFILES_ACTIVE
value: {{.Values.optimizer.springProfile | default "prod" }}
image: "{{ .Values.optimizer.image.repository }}:{{ .Values.optimizer.image.tag | default "latest" }}"
imagePullPolicy: {{ .Values.optimizer.image.pullPolicy }}
resources:
{{- toYaml .Values.optimizer.resources | nindent 14 }}

{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
restartPolicy: OnFailure
{{- end }}
5 changes: 4 additions & 1 deletion charts/cloudhealth-collector/templates/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ metadata:
type: Opaque
data:
apiToken: {{ .Values.apiToken | b64enc | quote }}
{{- end }}
{{- if .Values.optimizer.enabled }}
chapiKey: {{ .Values.optimizer.chapiKey | b64enc | quote }}
{{- end }}
{{- end }}
55 changes: 47 additions & 8 deletions charts/cloudhealth-collector/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,15 @@ deployAnnotations: {}

podAnnotations: {}

podSecurityContext: {
podSecurityContext:
runAsNonRoot: true
}

containerSecurityContext: {
allowPrivilegeEscalation: false,
readOnlyRootFilesystem: true,
runAsNonRoot: true,
capabilities: {drop: [all]}
}
containerSecurityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop: [all]

resources:
limits:
Expand All @@ -85,3 +84,43 @@ devArgs: |
['upload_k8s_state_v4', '--verbose']

customEnvVars: []

optimizer:
enabled: false
name: cloudhealth-optimizer-agent
springProfile: prod
image:
repository: cloudhealth/cloudhealth-optimizer-agent
tag: "latest"
# Set to automatically create secret, or create a secret with the name specified by the 'secretName' parameter
chapiKey: ""
resources:
limits:
cpu: 1000m
memory: 512Mi
requests:
cpu: 250m
memory: 128Mi

k8s-optimization:
fullnameOverride: cloudhealth-optimization
controllerManager:
kubeRbacProxy:
resources:
limits:
cpu: 500m
memory: 128Mi
requests:
cpu: 100m
memory: 64Mi
manager:
resources:
limits:
cpu: 500m
memory: 128Mi
requests:
cpu: 250m
memory: 64Mi
replicas: 1
serviceAccount:
annotations: {}
6 changes: 6 additions & 0 deletions cloudhealth-collector-image-docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ The agent has been verified against:

All versions before June 20, 2022 have been deprecated.

## [1398] - 2023-10-23

### Added

* The collector docker image now supports multiple regions(us-east-1 & us-east-2). optional parameter `chtRegion` added. Default: `us-east-1`

## [1360] - 2023-07-19

### Added
Expand Down