kubernetes:删除网络质量

发布于 2025-02-08 07:50:37 字数 1802 浏览 3 评论 0原文

我一直在实验网络策略,尽管我删除了所有政策,但现在POD无法再进行通信。

命名空间

apiVersion: v1
kind: Namespace
metadata:
    name: staging
    labels:
        env: staging

服务A

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: service-a
  namespace: staging
spec:
  replicas: 1
  selector:
    matchLabels:
      app: service-a
  template:
    metadata:
      labels:
        app: service-a
    spec:
      containers:
      - name: service-a
        image: busybox:1.33.1
        command: ["nc", "-lkv", "-p", "8080", "-e", "/bin/sh"]
        ports:
        - containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
  name: service-a
  namespace: staging
spec:
  type: ClusterIP
  selector:
    app: service-a
  ports:
  - port: 8080

服务B

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: service-b
  namespace: staging
spec:
  replicas: 1
  selector:
    matchLabels:
      app: service-b
  template:
    metadata:
      labels:
        app: service-b
    spec:
      containers:
      - name: service-b
        image: busybox:1.33.1
        command: ["nc", "-lkv", "-p", "8080", "-e", "/bin/sh"]
        ports:
        - containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
  name: service-b
  namespace: staging
spec:
  type: ClusterIP
  selector:
    app: service-b
  ports:
  - port: 8080

测试通信

kubectl -n staging exec service-a-7c66d7cdf8-72gqq --  nc -vz service-b

期望的行为是他们可以互相联系,但是有超时。因此,如果剩下任何网络策略,我会说。

kubectl -n staging get networkpolicy
>No resources found in staging namespace.

我尝试过的是,

我删除了名称空间,重新创建并重新创建了这两个服务。 我已经浏览了所有命名空间寻找网络策略以删除它们,但是没有!

在我开始尝试网络刺激之前,一切都很好,但是现在我无法再次工作。对于网络控制器,我正在使用Cillum。

I have been experimenting with network policies, and now pods can no longer communicate with each other though I have deleted all the policies.

Namespace

apiVersion: v1
kind: Namespace
metadata:
    name: staging
    labels:
        env: staging

Service A

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: service-a
  namespace: staging
spec:
  replicas: 1
  selector:
    matchLabels:
      app: service-a
  template:
    metadata:
      labels:
        app: service-a
    spec:
      containers:
      - name: service-a
        image: busybox:1.33.1
        command: ["nc", "-lkv", "-p", "8080", "-e", "/bin/sh"]
        ports:
        - containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
  name: service-a
  namespace: staging
spec:
  type: ClusterIP
  selector:
    app: service-a
  ports:
  - port: 8080

Service B

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: service-b
  namespace: staging
spec:
  replicas: 1
  selector:
    matchLabels:
      app: service-b
  template:
    metadata:
      labels:
        app: service-b
    spec:
      containers:
      - name: service-b
        image: busybox:1.33.1
        command: ["nc", "-lkv", "-p", "8080", "-e", "/bin/sh"]
        ports:
        - containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
  name: service-b
  namespace: staging
spec:
  type: ClusterIP
  selector:
    app: service-b
  ports:
  - port: 8080

Testing Communication

kubectl -n staging exec service-a-7c66d7cdf8-72gqq --  nc -vz service-b

Expected behaviour is that they can contact each other, but instead there is a timeout. So I tjeck if there are any network policies left.

kubectl -n staging get networkpolicy
>No resources found in staging namespace.

What I have tried

I have deleted the namespace, recreated it and recreated the two services.
I have gone through all namespaces looking for network policies to delete them, but there are none!

Before I started experimenting with the networkspolicies everything worked fine, but now I cannot get things working again. For the network controller I am using cillum.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

水溶 2025-02-15 07:50:37

我很愚蠢,我只是忘了第二次写港口。应该是:

kubectl -n staging exec service-a-7c66d7cdf8-72gqq --  nc -vz service-b 8080

I am pretty dumb, I simply forgot to write the port the second time around. It should be:

kubectl -n staging exec service-a-7c66d7cdf8-72gqq --  nc -vz service-b 8080
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文