Skip to content

Commit c2da180

Browse files
network traffic plugin changes and getting started with network isolation
1 parent 4e1a59d commit c2da180

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

examples/getting-started.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,31 @@ In some scenarios, you might want to enable controlled communication between ins
179179
kubectl allow network traffic hs1 hs2 -k provider.conf
180180
```
181181

182+
```sh
183+
# Test connectivity from hs1 to hs2 using the IP
184+
kubectl exec -it $HELLOWORLD_POD_HS1 -n hs1 --kubeconfig=provider.conf -- curl $HS2_POD_IP:5000
185+
186+
# Test connectivity from hs2 to hs1 using the IP
187+
kubectl exec -it $HELLOWORLD_POD_HS2 -n hs2 --kubeconfig=provider.conf -- curl $HS1_POD_IP:5000
188+
```
189+
190+
The connection should be allowed
191+
192+
182193
To deny the traffic between namespace
183194

184195
```sh
185196
kubectl deny network traffic hs1 hs2 -k provider.conf
186197
```
187198

199+
```sh
200+
# Test connectivity from hs1 to hs2 using the IP
201+
kubectl exec -it $HELLOWORLD_POD_HS1 -n hs1 --kubeconfig=provider.conf -- curl $HS2_POD_IP:5000
202+
203+
# Test connectivity from hs2 to hs1 using the IP
204+
kubectl exec -it $HELLOWORLD_POD_HS2 -n hs2 --kubeconfig=provider.conf -- curl $HS1_POD_IP:5000
205+
```
206+
188207
You should see that each policy’s ingress section now includes a rule that uses a namespaceSelector matching the other namespace (using the label `kubernetes.io/metadata.name`).
189208

190209
## Clean Up

plugins/kubectl-kubeplus-commands

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ print_help () {
2020
echo " kubectl license create"
2121
echo " kubectl license get"
2222
echo " kubectl license delete"
23-
echo " kubectl allow network <ns1> <ns2> [-k <kubeconfig>]"
23+
echo " kubectl allow network traffic <ns1> <ns2> [-k <kubeconfig>]"
2424
echo " Allows bidirectional network traffic between the two namespaces"
2525
echo " by adding ingress rules for the 'restrict-cross-ns-traffic' NetworkPolicy"
2626
echo " in both namespaces."
27-
echo " kubectl deny network <ns1> <ns2> [-k <kubeconfig>]"
27+
echo " kubectl deny network traffic <ns1> <ns2> [-k <kubeconfig>]"
2828
echo " Denies bidirectional network traffic between the two namespaces"
2929
echo " by removing the specific ingress rules that allow cross-namespace traffic"
3030
echo " from the 'restrict-cross-ns-traffic' NetworkPolicy."

plugins/network_traffic.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,6 @@ def do_deny(ns1, ns2, kubeconfig):
157157
sys.exit(1)
158158

159159
def main():
160-
# If the first argument is not 'allow' or 'deny', infer it from the executable name.
161-
valid_commands = {"allow", "deny"}
162-
if len(sys.argv) > 1 and sys.argv[1] not in valid_commands:
163-
prog = os.path.basename(sys.argv[0]).lower()
164-
if "deny" in prog:
165-
sys.argv.insert(1, "deny")
166-
elif "allow" in prog:
167-
sys.argv.insert(1, "allow")
168160

169161
parser = argparse.ArgumentParser(
170162
description="Manage bidirectional NetworkPolicy rules for cross-namespace traffic."

0 commit comments

Comments
 (0)