Skip to content

[installer]: move the kots install script into a bash file in Installer #12202

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

Merged
merged 2 commits into from
Sep 1, 2022

Conversation

mrsimonemms
Copy link
Contributor

@mrsimonemms mrsimonemms commented Aug 18, 2022

Description

Moves the bash script in the installer job into the installer image. This is done to make the application more reliable, testable and readable. This makes no fundamental changes to how the job works except for fixing ShellCheck errors and changing all the {{repl }} references to environment variables.

This also improves upon the wording and gives troubleshooting steps in an effort to reduce the (small, but not insignificant) number of "help, my installation-status pod is in an errored state" issues we see raised.

Related Issue(s)

Fixes #12197
Fixes #12259

How to test

Install via KOTS.

I've checked this against all permutations that I can work out (k3s, AKS, EKS, GKE) and works on all.

Release Notes

[installer]: move the kots install script into a bash file in Installer

Documentation

Werft options:

  • /werft with-preview

@mrsimonemms
Copy link
Contributor Author

mrsimonemms commented Aug 18, 2022

/werft run publish-to-kots

👍 started the job as gitpod-build-sje-move-kots-bash-script.8
(with .werft/ from main)

@mrsimonemms mrsimonemms force-pushed the sje/move-kots-bash-script branch 8 times, most recently from 3374e1e to f0b1714 Compare August 19, 2022 14:40
@mrsimonemms mrsimonemms marked this pull request as ready for review August 19, 2022 14:56
@mrsimonemms mrsimonemms requested a review from a team August 19, 2022 14:56
@github-actions github-actions bot added the team: delivery Issue belongs to the self-hosted team label Aug 19, 2022
@mrsimonemms mrsimonemms force-pushed the sje/move-kots-bash-script branch from f0b1714 to a6a3605 Compare August 22, 2022 09:43
@mrsimonemms
Copy link
Contributor Author

/hold this will be release in the September

@mrsimonemms mrsimonemms force-pushed the sje/move-kots-bash-script branch 2 times, most recently from 43fec40 to 4fc43ec Compare August 23, 2022 19:06
@mrsimonemms mrsimonemms requested a review from a team August 23, 2022 21:13
@github-actions github-actions bot added the team: workspace Issue belongs to the Workspace team label Aug 23, 2022
@mrsimonemms mrsimonemms force-pushed the sje/move-kots-bash-script branch 2 times, most recently from 4fc43ec to c2e494d Compare August 24, 2022 13:33
@mrsimonemms mrsimonemms removed the request for review from a team August 24, 2022 13:33
component: gitpod-installer
data:
# General settings
CURSOR: repl{{ Cursor | quote }}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 (idea; non-blocking) Asking Replicated for a generic feature for this


Like this approach a lot.

I wonder if we should ask Replicated whether there is a built-in way to get the whole KOTS config as config map or if not, create a feature request. A template function that returns the whole KOTS config as YAML would probably be good enough.

I think, that creating a generic solution in KOTS should not be that hard for Replicated. It would make our lives much easier to maintain this.

What do you think?

However, that does not block this pull request at all!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is possible to get this as a configmap, which we indeed do in the support bundle.

The problem with this as an approach is the KOTS config will have many sensitive pieces of data (passwords for DB/Registry/Storage etc) which we don't actually need for the Installer, as these are sent into secrets that the Installer then references.

We could of course store this as a secret rather than a configmap, but this would still contain information that we don't actually need for the Installer. I do see the benefit to not having to manage this though, but this then has the danger of thinking we're exposing something that we're not and errors being caused.

I'd propose that, for this PR, we keep it as-is and continue to discuss this subject when doing the general refactoring that we're doing.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd propose that, for this PR, we keep it as-is and continue to discuss this subject when doing the general refactoring that we're doing.

100 % agree.

@mrsimonemms mrsimonemms force-pushed the sje/move-kots-bash-script branch 3 times, most recently from 48c764e to 7214ed1 Compare August 26, 2022 16:31
@mrsimonemms
Copy link
Contributor Author

mrsimonemms commented Aug 26, 2022

/werft run publish-to-kots

👍 started the job as gitpod-build-sje-move-kots-bash-script.26
(with .werft/ from main)

@mrsimonemms
Copy link
Contributor Author

This is ready for test/review. I will leave the "hold" status as think this would benefit from multiple testers/approvers

@Pothulapati Pothulapati self-requested a review August 31, 2022 12:06
Copy link
Contributor

@Pothulapati Pothulapati left a comment

Choose a reason for hiding this comment

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

Actually liking this approach, as it makes the kots -> install config a lot more simpler! The code looks good, will do a another pass with manual testing after which it should be ✅

Great Work! :)

yq e -i ".workspace.runtime.containerdSocket = \"${CONTAINERD_SOCKET_AL}\"" "${CONFIG_FILE}"
fi

echo "Gitpod: Inject the Replicated variables into the config"
Copy link
Contributor

Choose a reason for hiding this comment

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

Definitely not asking in this PR, but a next iteration of this change would be to move all the config settings into a separate script so that we can validate the end config as a pre-flight check right? Should be simple enough and hence solving #12015 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's exactly the next step - good thought

yq e -i ".containerRegistry.privateBaseImageAllowList += \"docker.io\"" "${CONFIG_FILE}"
fi

if [ "${REG_CUSTOM_DOCKER_ENABLED}" = "1" ];
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Should it be called REG_CUSTOM_DOCKER_CONFIG_ENABLED? Would prefer to have CONFIG to be more specific.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've renamed it to REG_DOCKER_CONFIG_ENABLED to that keeps consistency with what I've done elsewhere (take the KOTS config name and captialise it). I've not changed the underlying KOTS config name (it's missing a d) in the expectation that someone could have started using it

echo "Gitpod: configuring external container registry"

# Get the external-container-registry secret so we can merge the external registry and KOTS registry keys
kubectl get secret external-container-registry \
Copy link
Contributor

Choose a reason for hiding this comment

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

:thumsup: Like that this is now routed through a secret, instead of building it here!

fi

echo "Gitpod: Create a Helm template directory"
rm -Rf "${GITPOD_OBJECTS}"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Maybe document somewhere in the file about GITPOD_OBJECTS? 🤔 While its straightforward with other env's as they are input it could be confusing on what kots-install.sh emits.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If it's ok with you, I won't fix in here - this won't be sticking around long as I've already started the next refactor and this probably won't survive. If it does, I'll fix it then

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good!

@mrsimonemms mrsimonemms force-pushed the sje/move-kots-bash-script branch from 7214ed1 to 52bf75f Compare August 31, 2022 19:28
@mrsimonemms mrsimonemms force-pushed the sje/move-kots-bash-script branch from 52bf75f to 2dc3af7 Compare August 31, 2022 19:34
Copy link
Contributor

@Pothulapati Pothulapati left a comment

Choose a reason for hiding this comment

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

✅ from my side. Upgraded my Gitpod instance on AWS to use this version, and all the installer, status and preflight checks worked as expected.

@mrsimonemms
Copy link
Contributor Author

/unhold

@roboquat roboquat merged commit 0510182 into main Sep 1, 2022
@roboquat roboquat deleted the sje/move-kots-bash-script branch September 1, 2022 07:09
@roboquat roboquat added the deployed: workspace Workspace team change is running in production label Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: workspace Workspace team change is running in production release-note size/XXL team: delivery Issue belongs to the self-hosted team team: workspace Issue belongs to the Workspace team
Projects
None yet
4 participants