This is an excercise where you configure security between pods.
- create a project called
network-policy
- create two deployments/apps (
hello
,test
) with the same image
oc new-app --name hello --image quay.io/redhattraining/hello-world-nginx
oc new-app --name test --image quay.io/redhattraining/hello-world-nginx
- expose the hello service
❯ oc expose service/hello
route.route.openshift.io/hello exposed
❯ curl hello-network-policy.apps-crc.testing
<html>
<body>
<h1>Hello, world from nginx!</h1>
</body>
</html>
-
get wide output from pods,services,routes to get internal pod IP address and cluster IP addresses
-
Access the
hello
pod from thetest
pod usinghello
's pod and cluster IP -
create a second project called
different-project
and deploy the same image with the app namesample-app
❯ oc new-project different-project
Now using project "different-project" on server "https://api.crc.testing:6443".
❯ oc new-app --name sample-app --image quay.io/redhattraining/hello-world-nginx
-
access the
hello
pod from thesample-app
pod via pod and cluster IP -
switch back to
network-policy
project and create a "deny-all" network policy -
test to make sure the pods cant access one another in the project (
test
trying to connect tohello
pod and network IP) -
validate pod from
different-project
can no longer accessnetwork-policy/hello
-
switch back to
network-policy
project and create a policy that will allowdifferent-project/sample-app
to access pods -
create lable
network=different-project
for projectdifferent-project
-
access the
hello
pod from thesample-app
pod via pod and cluster IP