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 all 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
6 changes: 4 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Release Charts
on:
push:
branches:
- main
- gmudumbai/sdo-2649-k8s-optimizer

jobs:
release:
Expand All @@ -22,6 +22,8 @@ jobs:
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Run chart-releaser
uses: helm/[email protected]
uses: helm/[email protected]
with:
mark_as_latest: false
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
18 changes: 17 additions & 1 deletion 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` in a particular namespace `<target_namespace>` (create if it does not exist), run the following commands:

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` in the `default` namespace, run the following commands:

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

To install the chart with the release name `cloudhealth-collector-optimizer` in a specified namespace `<target_namespace>`, run the following commands:

```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>,chtEndpointPrefix=<Cloudhealth Endpoint Prefix>,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.6.1
version: 6.0.0-beta
appVersion: "7.0.0"
dependencies:
- name: k8s-optimization
repository: oci://projects.packages.broadcom.com/kubernetes-optimization
version: 1.1.1
condition: optimizer.enabled
home: https://cloudhealth.vmware.com/
icon: https://d1fto35gcfffzn.cloudfront.net/images/Tanzu-Logomark.svg
sources:
Expand Down
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 @@ -25,3 +25,14 @@ rules:
- apiGroups: ["networking.k8s.io"]
resources: ["ingresses"]
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 }}
2 changes: 1 addition & 1 deletion charts/cloudhealth-collector/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,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
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_ENDPOINT_PREFIX
value: {{.Values.chtEndpointPrefix | default "use1" }}
- 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 @@ -16,4 +16,7 @@ data:
{{- if .Values.proxy.sslCert }}
certPassword: {{ .Values.proxy.certPassword | quote }}
{{- end }}
{{- end }}
{{- if .Values.optimizer.enabled }}
chapiKey: {{ .Values.optimizer.chapiKey | b64enc | quote }}
{{- end }}
{{- end }}
4 changes: 2 additions & 2 deletions charts/cloudhealth-collector/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
},
"clusterName": {
"type": "string",
"pattern": "^.{1,255}$"
"pattern": "^[a-z0-9-_.]{3,255}$"
},
"chtEndpointPrefix": {
"type": "string",
"pattern": "^(use1|preprod.test)$"
},
"collectionIntervalSecs": {
"type": "integer",
"minimum": 900
"minimum": 600
},
"jvmMemory": {
"type": "string"
Expand Down
55 changes: 47 additions & 8 deletions charts/cloudhealth-collector/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,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]

proxy:
sslCert: false
Expand Down Expand Up @@ -96,3 +95,43 @@ devArgs: |
['upload_k8s_state_v4', '--verbose']

customEnvVars: []

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

k8s-optimization:
fullnameOverride: cloudhealth-optimization
controllerManager:
kubeRbacProxy:
resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 100m
memory: 256Mi
manager:
resources:
limits:
cpu: 1000m
memory: 2048Mi
requests:
cpu: 500m
memory: 512Mi
replicas: 1
serviceAccount:
annotations: {}
Loading