Skip to content

Commit

Permalink
get kubecost deployment into shoot working
Browse files Browse the repository at this point in the history
  • Loading branch information
phyrog committed Sep 27, 2024
1 parent 1ab7af1 commit ff1cbb7
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 82 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ get-debug-command:

.PHONEY: generate-kubecost
generate-kubecost:
@helm template kubecost cost-analyzer --repo https://kubecost.github.io/cost-analyzer/ -n kubecost -f kubecost/values.yaml --create-namespace --no-hooks > kubecost/kubecost.yaml
@helm template kubecost cost-analyzer --repo https://kubecost.github.io/cost-analyzer/ -n kube-system -f kubecost/values.yaml --no-hooks > kubecost/kubecost.yaml
21 changes: 20 additions & 1 deletion kubecost/kubecost.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,28 @@ type KubeCostConfig struct {
ApiKey string `yaml:"api_key"`
}

var grafanaOverlay string = `#@ load("@ytt:overlay", "overlay")
#@overlay/match by=overlay.subset({"metadata": {"name": "external-grafana-config-map"}})
#@overlay/remove
`

var pvcOverlay string = `#@ load("@ytt:overlay", "overlay")
#@overlay/match by=overlay.subset({"kind": "PersistentVolumeClaim"}), expects="1+"
---
metadata:
#@overlay/match missing_ok=True
annotations:
resources.gardener.cloud/ignore: "true"
`

var labelsOverlay string = `#@ load("@ytt:overlay", "overlay")
#@overlay/match by=overlay.all , expects="1+"
#@overlay/match by=overlay.all, expects="1+"
---
metadata:
#@overlay/match missing_ok=True
labels:
#@overlay/match missing_ok=True
app.kubernetes.io/managed-by: gardener-extension-shoot-kubecost
Expand All @@ -42,6 +59,8 @@ func Render(config KubeCostConfig) []byte {

var files []*yttfiles.File
files = append(files, templateAsFile("manifest.yaml", manifest))
files = append(files, templateAsFile("grafana.yaml", grafanaOverlay))
files = append(files, templateAsFile("pvc.yaml", pvcOverlay))
files = append(files, templateAsFile("api-key.yaml", kubeCostTokenOverlay(config.ApiKey)))
files = append(files, templateAsFile("labels.yaml", labelsOverlay))
inputs := yttcmd.Input{Files: yttfiles.NewSortedFiles(files)}
Expand Down
Loading

0 comments on commit ff1cbb7

Please sign in to comment.