私は、ネットワークポリシーのサポートを有効にして、Google Kubernetes Engine(GKE)で動作するKubernetesクラスタを持っています。私はもうそれに接続することはできませんクラスタに必ず他のポッドを作るために、このネットワークポリシーを作成した後Kubernetes NetworkPolicyはロードバランサを許可します
kubectl run nginx --image=nginx
kubectl expose deployment nginx --port=80 --type=LoadBalancer
: 私はそれのためnginxの展開とロードバランサを作成し
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: access-nginx
spec:
podSelector:
matchLabels:
run: nginx
ingress:
- from:
- namespaceSelector:
matchLabels:
name: kube-system
ports:
- protocol: TCP
port: 80
は今(意図したように)私のクラスタ内の他のポッドがそれに到達することはできません。
kubectl run busybox --rm -ti --image=busybox /bin/sh
If you don't see a command prompt, try pressing enter.
/# wget --spider --timeout=1 nginx
Connecting to nginx (10.63.254.50:80)
wget: download timed out
しかし、それは私の外部ブラウザを使用して、私はまたを通じてそれにもう接続できないことを私を驚かせましたロードバランサ:
open http://$(kubectl get svc nginx --output=jsonpath={.status.loadBalancer.ingress[0].ip})
ポリシーを削除すると、再び機能します。
私の質問は、どのようにnginxに到達するのを他のポッドからブロックするのですか?ロードバランサを開いた状態でアクセスを維持しますか?