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

Using team namespaces: Kubeconfig Step Thru #616

Conversation

mplsgrant
Copy link
Collaborator

@mplsgrant mplsgrant commented Sep 24, 2024

I've created this as an extension on #598. It includes

  • some light admin documentation
  • an update to user permissions
  • an updated deploy function to create tanks in a specific namespace and "--to-all-users"
  • an updated down function that asks before nuking a whole wargame (and a "--force" to not bother asking)
  • e2e test
  • handling of namespace throughout many other functions: status, logs, etc
  • connecting nodes across namespaces using dns: tank-0003.wargames-blue-team.svc.cluster.local
  • fix to continue checking the init container if at first it can't be found
  • solves namespaces destroy needs to target wargames namespaces #618

@bdp-DrahtBot
Copy link
Collaborator

bdp-DrahtBot commented Sep 24, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

No conflicts as of last run.

@mplsgrant
Copy link
Collaborator Author

@josibake Made my changes in this Stepthru pull. The prefix logic in #598 wasn't working like I wanted.
I plan to look into this again Fri afternoon.

@josibake
Copy link
Collaborator

Nice, took a brief look and this looks good! I think the prefix approach is fine, and then we can revisit in a follow up a more comprehensive approach based on labels/annotations, which would remove the need for any sort of naming convention in our namespaces.

@mplsgrant mplsgrant force-pushed the 2024-09-create-kube-configs-stepthru branch 4 times, most recently from c92bb66 to 6f5264b Compare September 30, 2024 17:47
@mplsgrant mplsgrant marked this pull request as ready for review October 1, 2024 06:45
@mplsgrant mplsgrant force-pushed the 2024-09-create-kube-configs-stepthru branch from 966363b to dc39367 Compare October 1, 2024 07:26
@mplsgrant mplsgrant changed the title Kubeconfig Step Thru Using team namespaces: Kubeconfig Step Thru Oct 1, 2024
@josibake
Copy link
Collaborator

josibake commented Oct 1, 2024

Did a walk through of the commits, looks good. I think it would be helpful to squash the commits into logical groups, e.g., one commit for adding the ns option to the cli arguments, one commit for all of the namespace prefix logic, etc. I found it a bit confusing to step through each commit where later commits were re-editing lines of code that had already been touched.

Alternatively, people can just review the files, but given the scope of the PR I think logical commits would be helpful.

@mplsgrant mplsgrant force-pushed the 2024-09-create-kube-configs-stepthru branch 2 times, most recently from 822f0c8 to 531e436 Compare October 1, 2024 18:10
@mplsgrant
Copy link
Collaborator Author

@josibake Updated the commit structure as you suggested.

@mplsgrant mplsgrant force-pushed the 2024-09-create-kube-configs-stepthru branch 5 times, most recently from 41c6727 to 0dbeac8 Compare October 2, 2024 14:51
@mplsgrant
Copy link
Collaborator Author

@josibake This PR is looking good I think. Added a flag to deploy so that we can easily deploy the network to multiply namespaces at once.

@mplsgrant mplsgrant force-pushed the 2024-09-create-kube-configs-stepthru branch from 0dbeac8 to fa08a48 Compare October 2, 2024 17:50
@mplsgrant
Copy link
Collaborator Author

rebased on main

Copy link
Contributor

@pinheadmz pinheadmz left a comment

Choose a reason for hiding this comment

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

ok this is a lot, i breezed through each commit and added one comment. going to focus on test and docs next

namespace: {namespace}
user: {sa}
current-context: {sa}-{namespace}
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

might be cleaner to implement as a dict and then use yaml.dump()

Copy link
Collaborator Author

@mplsgrant mplsgrant Oct 3, 2024

Choose a reason for hiding this comment

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

Fixed here: f50dcf8 "admin: make kubeconfig a dict"

Comment on lines 43 to 44
if not namespace:
namespace = get_default_namespace()
Copy link
Contributor

Choose a reason for hiding this comment

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

i wonder if the repetition of this can be smoothed out with a function decorator like @needs_namespace that can be applied to all relevant commands

Copy link
Collaborator Author

@mplsgrant mplsgrant Oct 3, 2024

Choose a reason for hiding this comment

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

Fixed here: 2a906e2 "DRY out the namespace check"

mplsgrant and others added 26 commits October 7, 2024 19:25
`get_namespaces_by_prefix` is now renamed to `get_namespaces_by_type` in anticipation of using
labels in the future.
We use this to check if the current user can delete pods.
We want to back out early if the user is not able to bring down the network
The K8sError allows us to easily handle one single error that crops up from functions that life in
k8s.py. Right now I just have it implemented in the open/write kubeconfig functions.
We use this following to check for the scenario file:

          while [ ! -f /shared/archive.pyz ]; do
            echo "Waiting for /shared/archive.pyz to exist..."
            sleep 2
          done

I suspect this may cut off longer-running copy commands. Using mv we make sure all the data is
copied over, and then we `mv` the file into place.
@mplsgrant mplsgrant force-pushed the 2024-09-create-kube-configs-stepthru branch from f35c0c4 to 424eba8 Compare October 8, 2024 00:25
@mplsgrant
Copy link
Collaborator Author

rebased on main

@pinheadmz pinheadmz merged commit 26ca399 into bitcoin-dev-project:main Oct 8, 2024
11 checks passed
@mplsgrant mplsgrant deleted the 2024-09-create-kube-configs-stepthru branch October 8, 2024 02:14
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.

5 participants