-
Notifications
You must be signed in to change notification settings - Fork 35
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
Merged
pinheadmz
merged 76 commits into
bitcoin-dev-project:main
from
mplsgrant:2024-09-create-kube-configs-stepthru
Oct 8, 2024
Merged
Changes from all commits
Commits
Show all changes
76 commits
Select commit
Hold shift + click to select a range
56bc1c3
constants: make the default namespace "default"
mplsgrant c848848
constants: add `wargames` prefix
mplsgrant 39db0b5
constants: add k8s internal namespaces
mplsgrant 4683dc9
refactor: namespaces.yaml, namespace-defaults.yaml
josibake 305c189
charts: allow users access to services
mplsgrant 61cff4a
charts: add namespace to sa permissions
mplsgrant f34113a
deploy: allow a namespace parameter in `deploy`
josibake bb0e9cb
admin: add create_kubeconfigs func
mplsgrant 542f38a
service_accounts: add sa func to admin section
mplsgrant 4518cc6
namespaces: remove the dir from the `namespaces`
mplsgrant 714eff0
namespaces: flesh out wargames prefix
mplsgrant 2bcf737
status: add namespace to `status`
mplsgrant 527e583
workflow: add test to git workflow
mplsgrant 997ca62
k8s: add ns, sa, and config helper funcs
mplsgrant fc77971
k8s: fix static_client type
mplsgrant ab42fc3
k8s: update getting namespace logic
mplsgrant 0a2bd1a
k8s: ignore internal namespaces
mplsgrant ffdfec2
k8s & control: query all namespaces
mplsgrant b9ebff9
k8s: add optional ns to get_pod_exit_stats
mplsgrant a22cea8
k8s: add optional ns to delete_pod
mplsgrant e2aeecd
k8s: add optional ns to get_edges
mplsgrant 1a25418
k8s: add optional ns to snapshot_bitcoin_datadir
mplsgrant ac11388
k8s: add optional ns to wait_for_init
mplsgrant 9c0f82c
k8s: add optional ns to pod_log
mplsgrant f1d8d5c
k8s: add optional ns to wait_for_pod
mplsgrant 1593cfe
k8s: add optional ns to write_file_to_container
mplsgrant 402ee83
k8s: add namespace to `wait_for_init`
mplsgrant 1ecdcdf
network: add namespace to `network` `_connected`
mplsgrant 6242838
control: use namespace log in `down`
mplsgrant 76897d3
control & test base: prevent hasty `down`s
mplsgrant 159ac61
control: clean up `down` command
mplsgrant 9da42aa
control: add ns to `logs`
mplsgrant cd00478
control: add namespace to `run`
mplsgrant a05e0c7
control: add imports
mplsgrant f0b2d4b
control: ignore logging namespaces
mplsgrant 5100b0a
bitcoin: add ns to `rpc`
mplsgrant 59913cd
bitcoin: add ns to `debug_log` and `grep_logs`
mplsgrant c94c7a3
bitcoin: add ns to `messages` and `get_messages`
mplsgrant 7acf45d
deploy: enable deploying to all user namespaces
mplsgrant ea1827c
test base: add namespace to get_pod_exit_status
mplsgrant 8b6e9da
testing: add e2e namespace/admin test
mplsgrant 3f91d0b
admin.md: add admin documentation
mplsgrant e1c277c
k8s: add `continue` to `wait_for_init`
mplsgrant 2c15b6c
testing: remove mention of minikube
mplsgrant 6709805
tesing: use a temporary directory
mplsgrant 70a736f
admin: update create_kubeconfig description
mplsgrant 809eb5c
admin: spelling nit
mplsgrant 1feed7a
DRY out the namespace check
mplsgrant e40ea68
testing: finish replacing minikube logic
mplsgrant d47073c
ruff get_default_namespace_or
mplsgrant e208c0e
testing: bring service account checking "in house"
mplsgrant 7135973
service_accounts: remove func from `admin` section
mplsgrant 30af65a
admin: make kubeconfig a dict
mplsgrant 5188108
constants: use labels to select pods for `log`
mplsgrant 2bb87ec
rename to `get_namespaces_by_type`
mplsgrant 2cf8292
k8s: add `can_delete_pods` function
mplsgrant d6f4ed3
control: update `down` with `can_delete_pods`
mplsgrant bfc778b
admin.md: update namespace deploy command
mplsgrant ae19f28
bitcoin: make ruff happy
mplsgrant e7dbaf1
k8s: add open/write kubeconfig fn; add K8sError
mplsgrant 5a38e92
constants: remove --create-namespace
mplsgrant 7320758
testing: specify `warnettest` in named items
mplsgrant 4876415
testing: update test to include cleanup
mplsgrant 971afb9
constants: does graph_test.py need --create-namespace?
mplsgrant 506bd58
k8s: get raw config values from kubectl
mplsgrant 02cf9e5
k8s: get cluster from current context
mplsgrant a9239a7
auth: update auth func to avoid flattening
mplsgrant ed5fb00
admin: get raw cluster for auth file
mplsgrant 6ecc017
bitcoin: update `message` to take tank-a.namespace
mplsgrant 21815f0
deploy: fix override path
mplsgrant 1024bcf
`admin.md`: reword deploy documentation
mplsgrant 8024236
removing --create-namespace from constants
m3dwards 82cf687
removing --create-namespace from constants
m3dwards d9b3e1d
gitignore: add kubeconfigs dir
mplsgrant 6f18eb8
k8s: use mv to prevent scenario getting cut off
mplsgrant 424eba8
k8s: add `sync` to make sure the data is written
mplsgrant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ warnet.egg-info | |
.env | ||
dist/ | ||
build/ | ||
**/kubeconfigs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Admin | ||
|
||
## Connect to your cluster | ||
|
||
Ensure you are connected to your cluster because Warnet will use your current configuration to generate configurations for your users. | ||
|
||
```shell | ||
$ warnet status | ||
``` | ||
|
||
Observe that the output of the command matches your cluster. | ||
|
||
## Create an *admin* directory | ||
|
||
```shell | ||
$ mkdir admin | ||
$ cd admin | ||
$ warnet admin init | ||
``` | ||
|
||
Observe that there are now two folders within the *admin* directory: *namespaces* and *networks* | ||
|
||
## The *namespaces* directory | ||
This directory contains a Helm chart named *two_namespaces_two_users*. | ||
|
||
Modify this chart based on the number of teams and users you have. | ||
|
||
Deploy the *two_namespaces_two_users* chart. | ||
|
||
```shell | ||
$ warnet deploy namespaces/two_namespaces_two_users | ||
``` | ||
|
||
Observe that this creates service accounts and namespaces in the cluster: | ||
|
||
```shell | ||
$ kubectl get ns | ||
$ kubectl get sa -A | ||
``` | ||
|
||
### Creating Warnet invites | ||
A Warnet invite is a Kubernetes config file. | ||
|
||
Create invites for each of your users. | ||
|
||
```shell | ||
$ warnet admin create-kubeconfigs | ||
``` | ||
|
||
Observe the *kubeconfigs* directory. It holds invites for each user. | ||
|
||
### Using Warnet invites | ||
Users can connect to your wargame using their invite. | ||
|
||
```shell | ||
$ warnet auth alice-wargames-red-team-kubeconfig | ||
``` | ||
|
||
### Set up a network for your users | ||
Before letting the users into your cluster, make sure to create a network of tanks for them to view. | ||
|
||
|
||
```shell | ||
$ warnet deploy networks/mynet --to-all-users | ||
``` | ||
|
||
Observe that the *wargames-red-team* namespace now has tanks in it. | ||
|
||
**TODO**: What's the logging approach here? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm still pretty worried about the tech debt from this mechanism since it is so ubiquitous in this PR. Hard-coding the k8s namespaces and logging namesapce as well... and forcing the user to use a naming convention... all seems to go against our design principles!
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.
Agree that the prefixes is an anti pattern. I was looking at using namespace labels so they we could do things like
get_namespaces_by_type(WARNET_TANKS)
/get_namespaces_by_type(LOGGING)
/get_namespaces_by_type(ALL)
, etc but that felt like it would take more work to get right. If the tradeoff is we have prefixed namespaces and can use namespaces for Tabconf, vs we don't have namespaces for Tabconf at all, I'm more inclined to proceed as is and have a backlog to refactor to using labels (happy to own following up on that).