반응형
01. 특정 조건의 networkPolicy 생성.
[solve]
[root@k8s-master ~]# vi 46-test.yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-port-from-namespace
namespace: echo
spec:
policyTypes:
- Ingress
ingress:
- from:
- namespaceSelector:
matchLabels:
name: my-app
ports:
- protocol: TCP
port: 9000
[root@k8s-master ~]# kubectl apply -f 46-test.yaml
networkpolicy.networking.k8s.io/allow-port-from-namespace created
[root@k8s-master ~]#
[root@k8s-master ~]# kubectl get networkpolicies.networking.k8s.io -A
NAMESPACE NAME POD-SELECTOR AGE
calico-apiserver allow-apiserver apiserver=true 46h
echo allow-port-from-namespace <none> 2m16s
[root@k8s-master ~]#
반응형
'Compute > kubernetis' 카테고리의 다른 글
[따배씨] 1. ETCD Backup & Restore / CKA 시험 문제 학습 (0) | 2025.01.29 |
---|---|
[CKA] 16. ETCD backup & Restore (0) | 2025.01.14 |
[CKA] 14. daemonset 생성 (0) | 2025.01.14 |
[CKA] 13. clusterRole과 serviceAccount를 생성 (0) | 2025.01.14 |
[CKA] 12. ingress 생성 | 특정 조건의 ingress 생성 (0) | 2025.01.14 |