Jul 14, 2024
App A
and App B
) and a database (Redis DB
) running in different namespaces.App A
can communicate with the DB, but pods in App B
cannot.kubectl get pods -A
: Show all pods across namespaces.kubectl get pods -A -owide
: Show IP addresses of pods.Namespace A
pod to Namespace B
pod:
kubectl -n namespace-a exec -it pod-name -- curl <namespace-b-pod-ip>
Namespace A
pod to Namespace C
pod using similar command.kubectl describe namespace namespace-a
: Shows labels for a namespace.apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-app-a
namespace: namespace-b
spec:
podSelector:
matchLabels:
environment: test
policyTypes:
- Ingress
ingress:
- from:
- namespaceSelector:
matchLabels:
myspace: namespace-a
kubectl apply -f <file-name>
.Namespace C
pod unable to ping Namespace B
pod.-
) in front of selectors for 'or' conditions.