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

.werft: Refactoring to use constant kubeconfig files instead of overrides #9016

Merged
merged 9 commits into from
Apr 1, 2022

Conversation

ArthurSens
Copy link
Contributor

@ArthurSens ArthurSens commented Mar 30, 2022

Description

This PR refactors the whole deployment job so all interactions with any cluster have to be made with the appropriate kubeconfig file explicit set. This is being done because we've been constantly overriding kubecontexts throughout the job's logic and we've got to a point where it is super confusing to know what is being applied where.

It is a huge change and too much effort to review only looking at the changes. I'm making sure it works by starting multiple jobs using different configurations and checking if Gitpod runs and is able to start workspaces afterwards.

Related Issue(s)

Fixes #8997

How to test

  • Start a preview on core-dev with Helm. Workspaces start.
  • Start a preview on core-dev with Installer. Workspaces start.
  • Start a preview on Harvester. Workspaces start.

Release Notes

NONE

Signed-off-by: ArthurSens <arthursens2005@gmail.com>
Signed-off-by: ArthurSens <arthursens2005@gmail.com>
Signed-off-by: ArthurSens <arthursens2005@gmail.com>
Signed-off-by: ArthurSens <arthursens2005@gmail.com>
@ArthurSens
Copy link
Contributor Author

ArthurSens commented Mar 30, 2022

/werft run with-vm

👍 started the job as gitpod-build-arthursens-refactor-deploy-to-preview-8997.8

EDIT: This got stuck and timed-out, I'm looking into it

mads-hartmann
mads-hartmann previously approved these changes Mar 30, 2022
Copy link
Contributor

@mads-hartmann mads-hartmann left a comment

Choose a reason for hiding this comment

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

This is really impressive Arthur 👏 I left a few comments, but I don't think either of them are blocking. The biggest one is about quoting the paths we pass to exec. As we have full control over the paths in our source code I don't think it's worth making the change but I'll leave it up to you to decide.

I added the blocked label so you can test all the various scenarios.

.werft/jobs/build/prepare.ts Outdated Show resolved Hide resolved
@@ -7,7 +7,7 @@ import * as fs from 'fs';
* Monitoring satellite deployment bits
*/
export class InstallMonitoringSatelliteParams {
Copy link
Contributor

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.

}

async function ensureCorrectInstallationOrder(namespace: string, checkNodeExporterStatus: boolean){
async function ensureCorrectInstallationOrder(kubeconfig: string, namespace: string, checkNodeExporterStatus: boolean){
Copy link
Contributor

Choose a reason for hiding this comment

The 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 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

@@ -99,18 +99,18 @@ export async function deployToPreviewEnvironment(werft: Werft, jobConfig: JobCon
withVM,
};

exec(`kubectl --namespace keys get secret host-key -o yaml > /workspace/host-key.yaml`)
exec(`kubectl --kubeconfig ${CORE_DEV_KUBECONFIG_PATH} --namespace keys get secret host-key -o yaml > /workspace/host-key.yaml`)
Copy link
Contributor

Choose a reason for hiding this comment

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

To be on the 100% safe side it would be nicest to quote the path, so it is --kubeconfig "${CORE_DEV_KUBECONFIG_PATH}". This goes for all of the places where we are using a path in an exec call

Signed-off-by: ArthurSens <arthursens2005@gmail.com>
@ArthurSens ArthurSens changed the title Arthursens/refactor deploy to preview 8997 .werft: Refactoring to use constant kubeconfig files instead of overrides Mar 31, 2022
@ArthurSens ArthurSens marked this pull request as draft March 31, 2022 08:14
@ArthurSens
Copy link
Contributor Author

ArthurSens commented Mar 31, 2022

/werft run with-vm

👍 started the job as gitpod-build-arthursens-refactor-deploy-to-preview-8997.27

EDIT: Problems copying certificates from core-dev to the preview on k3s

Signed-off-by: ArthurSens <arthursens2005@gmail.com>
@ArthurSens
Copy link
Contributor Author

/werft run with-vm

@ArthurSens
Copy link
Contributor Author

ArthurSens commented Mar 31, 2022

/werft run with-helm

👍 started the job as gitpod-build-arthursens-refactor-deploy-to-preview-8997.32

EDIT: Failed to clean previous installer installation prior to deploy with helm

Signed-off-by: ArthurSens <arthursens2005@gmail.com>
@ArthurSens
Copy link
Contributor Author

ArthurSens commented Mar 31, 2022

/werft run with-clean-slate-deployment

👍 started the job as gitpod-build-arthursens-refactor-deploy-to-preview-8997.35

Signed-off-by: ArthurSens <arthursens2005@gmail.com>
@ArthurSens
Copy link
Contributor Author

ArthurSens commented Mar 31, 2022

/werft run with-clean-slate-deployment with-helm

👍 started the job as gitpod-build-arthursens-refactor-deploy-to-preview-8997.37

@ArthurSens
Copy link
Contributor Author

ArthurSens commented Mar 31, 2022

Oh damn, I spent way too much time trying to understand how my changes could have made helm to fail, but it is also failing in main 🥲

@ArthurSens
Copy link
Contributor Author

ArthurSens commented Mar 31, 2022

/werft run with-clean-slate-deployment

👍 started the job as gitpod-build-arthursens-refactor-deploy-to-preview-8997.38

@ArthurSens ArthurSens marked this pull request as ready for review March 31, 2022 13:50
@ArthurSens ArthurSens requested a review from a team March 31, 2022 13:51
@ArthurSens
Copy link
Contributor Author

ArthurSens commented Mar 31, 2022

Tested with installer on both core-dev and Harvester, worked fine. Helm was a failure 🙅, but, after testing on main, looks like helm is currently broken everywhere :/

…redentials

Signed-off-by: ArthurSens <arthursens2005@gmail.com>
@ArthurSens ArthurSens requested a review from a team March 31, 2022 16:22
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Mar 31, 2022
@ArthurSens
Copy link
Contributor Author

ArthurSens commented Mar 31, 2022

/werft run with-helm

👍 started the job as gitpod-build-arthursens-refactor-deploy-to-preview-8997.41

@ArthurSens
Copy link
Contributor Author

Sorry team-webapp, I'm just cherrypicking Janx's commit to test a deployment with Helm, I'll drop the commit afterwards

@ArthurSens ArthurSens force-pushed the arthursens/refactor-deploy-to-preview-8997 branch from 8586719 to 540ada2 Compare April 1, 2022 09:05
@ArthurSens ArthurSens removed the request for review from a team April 1, 2022 09:05
@roboquat roboquat merged commit 3fc52d3 into main Apr 1, 2022
@roboquat roboquat deleted the arthursens/refactor-deploy-to-preview-8997 branch April 1, 2022 09:14
@roboquat roboquat added the deployed: webapp Meta team change is running in production label Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production release-note-none size/XL team: devx team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor deploy-to-preview job to set explicit kubectx
4 participants