https://github.com/meta-magic/network-policy
https://github.com/meta-magic/network-policy
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/meta-magic/network-policy
- Owner: meta-magic
- Created: 2019-08-20T05:58:07.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-22T11:45:08.000Z (almost 7 years ago)
- Last Synced: 2025-02-26T14:25:31.918Z (over 1 year ago)
- Size: 3.91 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
For testing purpose we can create a new namespace for networkpolicy...
kubectl create ns policy-demo -------------------------------------> create a namespace
block-np.yml:
It will block the service communication from the pod.
for that:
1) create a pod inside a policy-demo namespace.
kubectl create -f https://raw.githubusercontent.com/meta-magic/kubernetes_workshop/master/yaml/network-policy/pod-np.yml
2) Create the Service.
kubectl expose --namespace=policy-demo pod nginx --port=80
3)Ensure the pod service is accessible.
kubectl run --namespace=policy-demo access --rm -ti --image busybox /bin/sh --------------> create another and login into pod to ns
command to check:
wget -q nginx -O - #---------------> wget the nginx inside the busybox to check here service acccesibilty.
#------------------> You should see a response from nginx
4) apply the policy block-np.yml.
kubectl apply -f block-np.yml
5) verify:
kubectl run --namespace=policy-demo access --rm -ti --image busybox /bin/sh
command to check:
wget -q nginx -O - #---------------> wget the nginx inside the busybox to check here service acccesibilty.
# wget: download timed out