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

DM-43555: Add phalanx environment install command #3165

Merged
merged 7 commits into from
Apr 9, 2024
Merged

Conversation

rra
Copy link
Member

@rra rra commented Apr 4, 2024

Port the installer/install.sh script to Python as the new phalanx environment install command. Add a strongly worded confirmation message before proceeding, which can be overrriden with a command line flag for CI testing.

Expand the Helm storage layer and add Argo CD and Kubernetes storage layers to support the installer. Use kubectl rather than the Python Kubernetes libraries to manipulate Kubernetes objects, since it's simpler and more straightforward for the type of actions the installer needs to take.

Introduce a new way of passing around Vault credentials, and support authenticating to Vault with an AppRole, at least in the context of the installer. (The secrets and vault commands still require tokens.)

Remove the old installer and switch GitHub Actions CI over to the new command.

@rra rra force-pushed the tickets/DM-43555 branch 11 times, most recently from 3b6d7bc to fac80f8 Compare April 4, 2024 19:22
@rra rra marked this pull request as ready for review April 4, 2024 19:37
@athornton athornton self-assigned this Apr 4, 2024
@rra rra force-pushed the tickets/DM-43555 branch 2 times, most recently from 9d578cb to 6652978 Compare April 5, 2024 21:38
Copy link
Member

@athornton athornton left a comment

Choose a reason for hiding this comment

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

LGTM.

I have some questions about "can we make this a shared library" around the Command class mostly, and...while I am certainly not someone who should throw stones about just shelling out via Command or its moral equivalent (git versus GitPython in particular), your kubectl driver feels like, except for waiting for rollouts, it's stuff we already have in Safir.

docs/applications/vault-secrets-operator/bootstrap.rst Outdated Show resolved Hide resolved
docs/applications/vault-secrets-operator/bootstrap.rst Outdated Show resolved Hide resolved
docs/applications/vault-secrets-operator/bootstrap.rst Outdated Show resolved Hide resolved
src/phalanx/github.py Outdated Show resolved Hide resolved
src/phalanx/storage/command.py Outdated Show resolved Hide resolved
if not origin.url:
raise GitRemoteError('Remote "origin" has no URL')

# If the URL is not an https URL, accept a few forms of github.com
Copy link
Member

Choose a reason for hiding this comment

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

Nice. Also something that probably ought to be lifted into a shared library.


# Prompt the user unless they specifically said not to.
if not force_noninteractive:
print(_INSTALL_WARNING.format(environment=environment))
Copy link
Member

Choose a reason for hiding this comment

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

I don't know if click.confirm will let you do this, and maybe it's being TOO aggressive...

...but given my tendency to speed through installers without thinking about them, I feel like it might be a good idea to generate a nonce -- maybe the classical six-digit random PIN -- display it, and make the user type it or at least copy-paste it, rather than just "y-Return".

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm going to merge this in its current form, but I added to my to-do list determining the current configured Kubernetes cluster and displaying that as part of the prompt to make it easier for people to realize when they're pointing to the wrong cluster.

__all__ = ["KubernetesStorage"]


class KubernetesStorage:
Copy link
Member

Choose a reason for hiding this comment

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

On the one hand, simpler...but on the other hand it feels like we already HAVE a lot of it mocked out for testing if we were using the Safir driver like we do in the Nublado controller. I mean...we already have secrets and namespaces in there, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, the thing we don't have is waiting for a rollout to complete. I don't think that's a trivial thing to implement with timeout and error handling, etc., and we're doing everything else with command-line tools (Helm and Argo CD), so it didn't seem worth the effort to reimplement it in Python.

The testing code isn't that useful for Phalanx since Phalanx already tests the installer with a good integration test, making unit tests (particularly of this stuff) fairly pointless.

rra added 4 commits April 9, 2024 08:26
Port the installer/install.sh script to Python as the new phalanx
environment install command. Add a strongly worded confirmation
message before proceeding, which can be overrriden with a command
line flag for CI testing.

Expand the Helm storage layer and add Argo CD and Kubernetes
storage layers to support the installer. Use kubectl rather than
the Python Kubernetes libraries to manipulate Kubernetes objects,
since it's simpler and more straightforward for the type of actions
the installer needs to take.

Introduce a new way of passing around Vault credentials, and support
authenticating to Vault with an AppRole, at least in the context of
the installer. (The secrets and vault commands still require tokens.)

Remove the old installer and switch GitHub Actions CI over to the
new command.
Remove documentation for the old install script and document the
new installation process. Fix an ordering problem in the documentation
for how to set up a new environment by putting assembly of the
configuration for that environment before setting up secrets management.
Be a bit clearer about how the secret for vault-secrets-operator
is created.
Add better explanations of the GitHub-specific output code and the
command execution layer.
Wait for a minute instead of 30 seconds for the sync of each
infrastructure application.
@rra rra added this pull request to the merge queue Apr 9, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 9, 2024
When running in the merge queue, we do fall back on Git operations
to determine the current branch. Return the branch name, not a
Head object.
@rra rra enabled auto-merge April 9, 2024 20:13
We're still getting timeouts in GitHub Actions. Increase the
timeouts for Helm and Argo CD operations even further.
@rra rra added this pull request to the merge queue Apr 9, 2024
Merged via the queue into main with commit cfaf06f Apr 9, 2024
6 checks passed
@rra rra deleted the tickets/DM-43555 branch April 9, 2024 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants