From the course: Certified Kubernetes Administrator (CKA) Cert Prep

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Lesson 10 lab solution: Using NetworkPolicies

Lesson 10 lab solution: Using NetworkPolicies - Kubernetes Tutorial

From the course: Certified Kubernetes Administrator (CKA) Cert Prep

Lesson 10 lab solution: Using NetworkPolicies

- So here is the lab solution. So let's start by creating the namespace and then we are going to run lab10server in the restricted namespace. - -image is nginx. We need to expose it. So we expose the pod resource type lab10server --port is 80. And then we are going to run the sleepyboxes in the default namespace. So sleepybox1 --image is busybox and --sleep 3600. And likewise for sleepybox2. Now that was the easy part. Next we need to work with network policies and as we want to work with network policies, what exactly do we need to do? Well, we need to create a network policy that limits ingress traffic to restricted. Okay, so the network policy is going to be applied to the restricted namespace in such a way that only the sleepybox1 pod from the default namespace has access and all other access is forbidden. That means that the sleepybox1 pod needs a label. I also want to label on the default namespace because we are going for the network policy for a pod within a namespace from the…

Contents