-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ROX-24553: Possibility to add additional VPA recommenders (#1888)
- Loading branch information
Showing
35 changed files
with
2,570 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
fleetshard/pkg/central/charts/data/rhacs-vertical-pod-autoscaler/Chart.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: v2 | ||
name: rhacs-vertical-pod-autoscaler | ||
description: A Helm chart for Kubernetes | ||
type: application | ||
version: 0.0.0 | ||
appVersion: "0.0.0" |
58 changes: 58 additions & 0 deletions
58
fleetshard/pkg/central/charts/data/rhacs-vertical-pod-autoscaler/templates/proxy-config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: proxy-config | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
app.kubernetes.io/name: "rhacs-vpa-recommender" | ||
app.kubernetes.io/instance: {{ $.Release.Name | quote }} | ||
app.kubernetes.io/version: {{ $.Chart.AppVersion | quote }} | ||
app.kubernetes.io/managed-by: {{ $.Release.Service | quote }} | ||
helm.sh/chart: "{{ $.Chart.Name }}-{{ $.Chart.Version | replace "+" "_"}}" | ||
meta.helm.sh/release-name: {{ $.Release.Name | quote }} | ||
meta.helm.sh/release-namespace: {{ $.Release.Namespace | quote }} | ||
data: | ||
server.js: | | ||
/** | ||
* On openshift, prometheus has a kube-rbac-proxy that requires a token to access the metrics endpoint. | ||
* VerticalPodAutoscaler recommenders don't support a token-based authentication. | ||
* This proxy is a simple http server that forwards requests to the prometheus metrics endpoint with the token. | ||
**/ | ||
const http = require('http'); | ||
const https = require('https'); | ||
const fs = require('fs'); | ||
const os = require('os'); | ||
const TOKEN_PATH = process.env.TOKEN_PATH || '/var/run/secrets/kubernetes.io/serviceaccount/token' | ||
const UPSTREAM_PROTOCOL = process.env.UPSTREAM_PROTOCOL || 'http' | ||
const UPSTREAM_HOST = process.env.UPSTREAM_HOST | ||
const UPSTREAM_PORT = process.env.UPSTREAM_PORT | ||
const LISTEN_PORT = process.env.LISTEN_PORT || "9000" | ||
function onRequest(req, res) { | ||
const secret = fs.readFileSync(TOKEN_PATH, 'utf8'); | ||
const options = { | ||
hostname: UPSTREAM_HOST, | ||
port: UPSTREAM_PORT, | ||
path: req.url, | ||
method: req.method, | ||
protocol: UPSTREAM_PROTOCOL + ':', | ||
headers: { | ||
...req.headers, | ||
'authorization': 'Bearer ' + secret, | ||
'host': UPSTREAM_HOST | ||
}, | ||
changeOrigin: true | ||
}; | ||
const fn = options.protocol === 'https:' ? https : http; | ||
const proxy = fn.request(options, function (r) { | ||
res.writeHead(r.statusCode, r.headers); | ||
r.pipe(res, {end: true}); | ||
}); | ||
req.pipe(proxy, {end: true}); | ||
} | ||
http.createServer(onRequest).listen(LISTEN_PORT, '0.0.0.0'); | ||
console.log('Proxying on port 9000') |
Oops, something went wrong.