Skip to content

Commit 44b8797

Browse files
committed
Fix getting-started guide and network traffic plugin wrappers
- Update getting-started.md to use full paths for YAML files from repo root - Fix kubeconfig references to use kubeplus-saas-provider.json (actual file created) - Add CRD wait step before creating HelloWorldService instances - Fix kubectl-allow-network-traffic and kubectl-deny-network-traffic wrappers to properly handle -k flag by reordering arguments for argparse compatibility - Add -k flag back to allow/deny commands in getting-started guide This allows users to run all commands from the repository root without needing to change directories, and ensures the -k flag works correctly as documented in kubectl-kubeplus-commands help text.
1 parent 51ab076 commit 44b8797

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

examples/getting-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ kubectl create -f examples/multitenancy/hello-world/hs2.yaml --kubeconfig=kubepl
192192
In some scenarios, you might want to enable controlled communication between instances running in different namespaces. KubePlus provides a custom kubectl plugin for this purpose. To allow bi-directional traffic between the two HelloWorldService instances (deployed in namespaces `hs1` and `hs2`), run:
193193

194194
```sh
195-
kubectl allow network traffic hs1 hs2
195+
kubectl allow network traffic hs1 hs2 -k kubeplus-saas-provider.json
196196
```
197197

198198
```sh
@@ -216,7 +216,7 @@ The connection should be allowed
216216
To deny the traffic between namespace
217217

218218
```sh
219-
kubectl deny network traffic hs1 hs2
219+
kubectl deny network traffic hs1 hs2 -k kubeplus-saas-provider.json
220220
```
221221

222222
```sh

plugins/kubectl-allow-network-traffic

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,20 @@
22

33
source utils.sh # if you have common utility functions; else remove this line
44

5-
# This wrapper passes all arguments to our Python script.
6-
python3 "$KUBEPLUS_HOME/plugins/network_traffic.py" allow "$@"
5+
# Usage (as advertised in kubectl-kubeplus-commands):
6+
# kubectl allow network traffic <ns1> <ns2> [-k <kubeconfig>]
7+
#
8+
# kubectl will translate that to the plugin name:
9+
# kubectl-allow-network-traffic <ns1> <ns2> [-k <kubeconfig>]
10+
#
11+
# Here we:
12+
# - Take the first two positional args as namespaces
13+
# - Pass any remaining args (e.g. -k <kubeconfig>) as global options
14+
# - Reorder so global options come before the subcommand for argparse
15+
16+
ns1="$1"
17+
ns2="$2"
18+
shift 2
19+
20+
# "$@" now contains any remaining flags (e.g. -k kubeplus-saas-provider.json)
21+
python3 "$KUBEPLUS_HOME/plugins/network_traffic.py" "$@" allow "$ns1" "$ns2"

plugins/kubectl-deny-network-traffic

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,20 @@
22

33
source utils.sh # if you have common utility functions; else remove this line
44

5-
# This wrapper passes all arguments to our Python script.
6-
python3 "$KUBEPLUS_HOME/plugins/network_traffic.py" deny "$@"
5+
# Usage (as advertised in kubectl-kubeplus-commands):
6+
# kubectl deny network traffic <ns1> <ns2> [-k <kubeconfig>]
7+
#
8+
# kubectl will translate that to the plugin name:
9+
# kubectl-deny-network-traffic <ns1> <ns2> [-k <kubeconfig>]
10+
#
11+
# Here we:
12+
# - Take the first two positional args as namespaces
13+
# - Pass any remaining args (e.g. -k <kubeconfig>) as global options
14+
# - Reorder so global options come before the subcommand for argparse
15+
16+
ns1="$1"
17+
ns2="$2"
18+
shift 2
19+
20+
# "$@" now contains any remaining flags (e.g. -k kubeplus-saas-provider.json)
21+
python3 "$KUBEPLUS_HOME/plugins/network_traffic.py" "$@" deny "$ns1" "$ns2"

0 commit comments

Comments
 (0)