This commit is contained in:
sandervanvugt 2022-11-30 11:10:32 -08:00
parent 50a8876e65
commit 1a8e9eb146

79
lesson9lab.yaml Normal file
View File

@ -0,0 +1,79 @@
apiVersion: v1
kind: Namespace
metadata:
name: restricted
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: mynp
namespace: restricted
spec:
podSelector:
matchLabels:
target: "yes"
policyTypes:
- Ingress
- Egress
ingress:
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: default
podSelector:
matchLabels:
access: "yes"
ports:
- protocol: TCP
port: 80
egress:
- {}
---
apiVersion: v1
kind: Pod
metadata:
name: nginx
namespace: restricted
labels:
target: "yes"
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
---
apiVersion: v1
kind: Pod
metadata:
name: sleepybox1
namespace: default
labels:
access: "yes"
spec:
containers:
- name: busybox
image: busybox
args:
- sleep
- "3600"
---
apiVersion: v1
kind: Pod
metadata:
name: sleepybox2
namespace: default
labels:
access: "noway"
spec:
containers:
- name: busybox
image: busybox
args:
- sleep
- "3600"