-
Notifications
You must be signed in to change notification settings - Fork 1.3k
.werft: Refactoring to use constant kubeconfig files instead of overrides #9016
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
Changes from all commits
a2c59bc
41f9366
ea745b6
eb173bd
c649382
bd1d2f2
21d9638
71ec9ab
540ada2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
export const GCLOUD_SERVICE_ACCOUNT_PATH = "/mnt/secrets/gcp-sa/service-account.json"; | ||
export const CORE_DEV_KUBECONFIG_PATH = "/workspace/gitpod/kubeconfigs/core-dev"; | ||
export const HARVESTER_KUBECONFIG_PATH = "/workspace/gitpod/kubeconfigs/harvester"; | ||
export const PREVIEW_K3S_KUBECONFIG_PATH = "/workspace/gitpod/kubeconfigs/k3s"; |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ import * as fs from 'fs'; | |
* Monitoring satellite deployment bits | ||
*/ | ||
export class InstallMonitoringSatelliteParams { | ||
pathToKubeConfig: string | ||
kubeconfigPath: string | ||
satelliteNamespace: string | ||
clusterName: string | ||
nodeExporterPort: number | ||
|
@@ -76,39 +76,39 @@ export async function installMonitoringSatellite(params: InstallMonitoringSatell | |
|
||
// The correct kubectl context should already be configured prior to this step | ||
// Only checks node-exporter readiness for harvester | ||
ensureCorrectInstallationOrder(params.satelliteNamespace, params.withVM) | ||
ensureCorrectInstallationOrder(params.kubeconfigPath, params.satelliteNamespace, params.withVM) | ||
} | ||
|
||
async function ensureCorrectInstallationOrder(namespace: string, checkNodeExporterStatus: boolean){ | ||
async function ensureCorrectInstallationOrder(kubeconfig: string, namespace: string, checkNodeExporterStatus: boolean){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For this file you could have exposed a single class and then have all the functions as public/private methods. That way you wouldn't need to pass the kubeconfig around. I don't think it's worth doing now, just as inspiration for future refactoring if you're feeling like it 😉 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that definitely crossed my mind while doing this, maybe its worth raising an issue to refactor this later |
||
const werft = getGlobalWerftInstance() | ||
|
||
werft.log(sliceName, 'installing monitoring-satellite') | ||
exec('cd observability && hack/deploy-satellite.sh', {slice: sliceName}) | ||
exec(`cd observability && hack/deploy-satellite.sh --kubeconfig ${kubeconfig}`, {slice: sliceName}) | ||
|
||
deployGitpodServiceMonitors() | ||
checkReadiness(namespace, checkNodeExporterStatus) | ||
deployGitpodServiceMonitors(kubeconfig) | ||
checkReadiness(kubeconfig, namespace, checkNodeExporterStatus) | ||
} | ||
|
||
async function checkReadiness(namespace: string, checkNodeExporterStatus: boolean) { | ||
async function checkReadiness(kubeconfig: string, namespace: string, checkNodeExporterStatus: boolean) { | ||
// For some reason prometheus' statefulset always take quite some time to get created | ||
// Therefore we wait a couple of seconds | ||
exec(`sleep 30 && kubectl rollout status -n ${namespace} statefulset prometheus-k8s`, {slice: sliceName, async: true}) | ||
exec(`kubectl rollout status -n ${namespace} deployment grafana`, {slice: sliceName, async: true}) | ||
exec(`kubectl rollout status -n ${namespace} deployment kube-state-metrics`, {slice: sliceName, async: true}) | ||
exec(`kubectl rollout status -n ${namespace} deployment otel-collector`, {slice: sliceName, async: true}) | ||
exec(`sleep 30 && kubectl --kubeconfig ${kubeconfig} rollout status -n ${namespace} statefulset prometheus-k8s`, {slice: sliceName, async: true}) | ||
exec(`kubectl --kubeconfig ${kubeconfig} rollout status -n ${namespace} deployment grafana`, {slice: sliceName, async: true}) | ||
exec(`kubectl --kubeconfig ${kubeconfig} rollout status -n ${namespace} deployment kube-state-metrics`, {slice: sliceName, async: true}) | ||
exec(`kubectl --kubeconfig ${kubeconfig} rollout status -n ${namespace} deployment otel-collector`, {slice: sliceName, async: true}) | ||
|
||
// core-dev is just too unstable for node-exporter | ||
// we don't guarantee that it will run at all | ||
if(checkNodeExporterStatus) { | ||
exec(`kubectl rollout status -n ${namespace} daemonset node-exporter`, {slice: sliceName, async: true}) | ||
exec(`kubectl --kubeconfig ${kubeconfig} rollout status -n ${namespace} daemonset node-exporter`, {slice: sliceName, async: true}) | ||
} | ||
} | ||
|
||
async function deployGitpodServiceMonitors() { | ||
async function deployGitpodServiceMonitors(kubeconfig: string) { | ||
const werft = getGlobalWerftInstance() | ||
|
||
werft.log(sliceName, 'installing gitpod ServiceMonitor resources') | ||
exec('kubectl apply -f observability/monitoring-satellite/manifests/gitpod/', {silent: true}) | ||
exec(`kubectl --kubeconfig ${kubeconfig} apply -f observability/monitoring-satellite/manifests/gitpod/`, {silent: true}) | ||
} | ||
|
||
function postProcessManifests() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would have been nicer to just have as a
type
instead of class.