kubernetes NetworkPolicy(防火墙)

开头语

写在前面:如有问题,以你为准,

目前24年应届生,各位大佬轻喷,部分资料与图片来自网络

内容较长,页面右上角目录方便跳转

概述

  1. 网络策略指的是 Pod 间的网络隔离策略,默认情况下是互通的。
  2. Pod  之间的互通是通过如下三个标识符的组合来辨识的:
    1. ① 其他被允许的 Pod(例外:Pod 无法阻塞对自身的访问)。
    2. ② 被允许的名称空间。
    3. ③ IP 组块(例外:与 Pod 运行所在的节点的通信总是被允许的, 无论 Pod 或节点的 IP 地址)

默认情况

如果命名空间没有配置任何NetworkPolicy,则允许所有流量进站和出站

网络策略(Network Policy):是一个K8s资源,用于限制Pod出入流量,提供Pod级别和Namespace级别网络访问控制。

网络策略的应用场景:

  1. 应用程序间的访问控制,例如项目A不能访问项目B的Pod
  2. 开发环境命名空间不能访问测试环境命名空间Pod
  3. 当Pod暴露到外部时,需要做Pod白名单
  4. 多租户网络环境隔离

匹配策略

类似于安全组

当有一个命名空间有多个策略使用,只要其中一个策略是放通,其他策略都是拒绝,那也是放通

没有优先级的调整

只有允许策略,没有拒绝策略,(可以通过使用一个默认拒绝所有的策略和一个只开放策略来实现)

Pod 隔离和非隔离

apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:name: networkpol-01namespace: defaultspec:podSelector: # Pod 选择器matchLabels:app: nginx  # 选中的 Pod 就被隔离起来了policyTypes: # 策略类型- Ingress # Ingress 入站规则、Egress 出站规则- Egressingress: # 入站白名单,什么能访问我- from:- podSelector: # 选中的 Pod 可以访问 spec.matchLabels 中筛选的 PodmatchLabels:access: granted #有这个标签的pod才能访问被隔离的pod(上面的nginx)ports: # 开放端口和协议- protocol: TCPport: 80egress: # 出站白名单,我能访问什么- to:- podSelector: # spec.matchLabels 中筛选的 Pod 能访问的 PodmatchLabels:app: tomcat- namespaceSelector:matchLabels:kubernetes.io/metadata.name: dev # spec.matchLabels 中筛选的 Pod 能访问 dev 命名空间下的所有ports:- protocol: TCPport: 8080

Namespace 隔离和非隔离

apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:name: allow-port-from-namespacenamespace: my-appspec:podSelector: {}policyTypes:- Ingressingress:- from:- namespaceSelector:matchLabels:kubernetes.io/metadata.name: echo# 拥有这个标签的namespace 可以访问my-app命名空间ports:- protocol: TCPport: 9000

拒绝操作

入站 yaml

默认拒绝所有入站流量,下面的yaml示例就是如此

# 默认拒绝所有入站流量apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:name: default-deny-ingressnamespace: defaultspec:podSelector: {}policyTypes:- Ingress
# 允许所有入站流量apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:name: allow-all-ingressnamespace: defaultspec:podSelector: {}policyTypes:- Ingressingress:- {}

出站 yaml

# 默认拒绝所有出站流量apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:name: default-deny-egressspec:podSelector: {}policyTypes:- Egress
# 允许所有出站流量apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:name: allow-all-egressspec:podSelector: {}policyTypes:- Egressegress:- {}

默认拒绝所有入站和所有出站流量

apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:name: default-deny-allspec:podSelector: {} # 匹配本命名空间所有podpolicyTypes:- Ingress- Egress# ingress 和 Egress 没有指定规则,则不允许任何流量进出pod

整个 yaml 解析

apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:name: test-network-policynamespace: default # 配置NetworkPolicy的命名空间spec:podSelector:matchLabels:role: db # 在上面ns定义的命名空间下,符合这个labels的pod,才会被添加networkpolicypolicyTypes: # 定义类型- Ingress #(入站)- Egress  #(出站)ingress: # 入站的规则- from: # 源地址,请求来自那个地址- ipBlock: # ip地址cidr: 172.17.0.0/16except: # 除了这个以外- 172.17.1.0/24- namespaceSelector: # namespace 符合有下面这个标签的即可通过 (default命名空间下的pod)matchLabels:project: myproject#  kubernetes.io/metadata.name: test 指定某个命名空间下的所有pod- podSelector: # 和上面隔离的命名空间的同一个命名空间下的pod,且有一下标签matchLabels:role: frontendports: # 开放的协议和端口- protocol: TCPport: 6379egress: # 出站规则- to: # 类似于上面的 from- ipBlock: # 来自那个地址cidr: 10.0.0.0/24- podSelector: # spec.matchLabels 中筛选的 Pod 能访问的 PodmatchLabels:app: tomcat- namespaceSelector:matchLabels:kubernetes.io/metadata.name: dev # spec.matchLabels 中筛选的 Pod 能访问 dev 命名空间下的所有ports: # 开放协议端口- protocol: TCPport: 5978
  1. 隔离 default 名字空间下 role=db 的 Pod (如果它们不是已经被隔离的话)。
  2. (Ingress 规则)允许以下 Pod 连接到 default 名字空间下的带有 role=db 标签的所有 Pod 的 6379 TCP 端口:
    • default 名字空间下带有 role=frontend 标签的所有 Pod
    • 带有 project=myproject 标签的所有名字空间中的 Pod
    • IP 地址范围为 172.17.0.0–172.17.0.255 和 172.17.2.0–172.17.255.255 (即,除了 172.17.1.0/24 之外的所有 172.17.0.0/16)
  3. (Egress 规则)允许 default 名字空间中任何带有标签 role=db 的 Pod 到 CIDR 10.0.0.0/24 下 5978 TCP 端口的连接。

多个from或同一个from多个规则

or 的逻辑

  ingress:- from:- namespaceSelector:matchLabels:kubernetes.io/metadata.name: default- podSelector:matchLabels:app: client1

and

  ingress:- from:- namespaceSelector:matchLabels:kubernetes.io/metadata.name: default- from:- podSelector:matchLabels:app: client1

[root@master cks]# kubectl describe networkpolicy -n test ns-app-allow-appName:         ns-app-allow-appNamespace:    testCreated on:   2023-11-01 07:00:50 -0400 EDTLabels:       <none>Annotations:  <none>Spec:PodSelector:     app=webAllowing ingress traffic:To Port: <any> (traffic allowed to all ports)From:NamespaceSelector: kubernetes.io/metadata.name=defaultFrom:PodSelector: run=client1Not affecting egress trafficPolicy Types: Ingress

and 的逻辑

  ingress:- from:- namespaceSelector:matchLabels:kubernetes.io/metadata.name: defaultpodSelector:matchLabels:app: client1

[root@master cks]# kubectl describe networkpolicy -n test ns-app-allow-appName:         ns-app-allow-appNamespace:    testCreated on:   2023-11-01 07:00:50 -0400 EDTLabels:       <none>Annotations:  <none>Spec:PodSelector:     app=webAllowing ingress traffic:To Port: <any> (traffic allowed to all ports)From:NamespaceSelector: kubernetes.io/metadata.name=defaultPodSelector: run=client1Not affecting egress trafficPolicy Types: Ingress

实操

命名空间级别

限制入站

创建环境(ns:test)

[root@master cks]# kubectl create ns testnamespace/test created[root@master cks]# kubectl get nsNAME                   STATUS   AGEcalico-apiserver       Active   2d2hcalico-system          Active   2d2hdefault                Active   271dingress-nginx          Active   256dkube-node-lease        Active   271dkube-public            Active   271dkube-system            Active   271dkubernetes-dashboard   Active   246dstudy                  Active   231dtest                   Active   5stigera-operator        Active   2d2h[root@master cks]# kubectl run busybox  -n test  --image=busybox:1.30 -- sleep 12hpod/busybox created[root@master cks]# kubectl run nginx -n test --image=nginx:1.17.1pod/nginx created[root@master cks]# kubectl get pod -n testNAME      READY   STATUS    RESTARTS   AGEbusybox   1/1     Running   0          54snginx     1/1     Running   0          4s

创建环境 ns:default

[root@master cks]# kubectl run busybox   --image=busybox:1.30 -- sleep 12hpod/busybox created[root@master cks]# kubectl get pod -o wideNAME      READY   STATUS    RESTARTS   AGE   IP              NODE    NOMINATED NODE   READINESS GATESbusybox   1/1     Running   0          33s   10.244.104.36   node2   <none>           <none>

进入 busybox pod 里面进行ping(default)

[root@master cks]# kubectl get podNAME      READY   STATUS    RESTARTS   AGEbusybox   1/1     Running   0          2m46s[root@master cks]# kubectl get pod -n testNAME      READY   STATUS    RESTARTS   AGEbusybox   1/1     Running   0          5m47snginx     1/1     Running   0          4m57s[root@master cks]# kubectl get pod -n test -owideNAME      READY   STATUS    RESTARTS   AGE     IP              NODE    NOMINATED NODE   READINESS GATESbusybox   1/1     Running   0          5m54s   10.244.104.34   node2   <none>           <none>nginx     1/1     Running   0          5m4s    10.244.104.35   node2   <none>           <none>[root@master cks]# kubectl exec -it busybox /bin/shkubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead./ # ping 10.244.104.35PING 10.244.104.35 (10.244.104.35): 56 data bytes64 bytes from 10.244.104.35: seq=0 ttl=63 time=0.124 ms^C--- 10.244.104.35 ping statistics ---1 packets transmitted, 1 packets received, 0% packet lossround-trip min/avg/max = 0.124/0.124/0.124 ms/ # ping 10.244.104.34PING 10.244.104.34 (10.244.104.34): 56 data bytes64 bytes from 10.244.104.34: seq=0 ttl=63 time=0.093 ms64 bytes from 10.244.104.34: seq=1 ttl=63 time=0.076 ms^C--- 10.244.104.34 ping statistics ---2 packets transmitted, 2 packets received, 0% packet lossround-trip min/avg/max = 0.076/0.084/0.093 ms/ #

编写 networkpolicy,让其他所有命名空间访问不了test命名空间下的pod

# 默认拒绝所有入站流量apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:name: test-deny-ingressnamespace: testspec:podSelector: {}policyTypes:- Ingress

[root@master cks]# kubectl create -f np-test-web.yaml[root@master cks]# kubectl get NetworkPolicy -n testNAME                POD-SELECTOR   AGEtest-deny-ingress   <none>         2m7s[root@master cks]# kubectl describe NetworkPolicy -n testName:         test-deny-ingressNamespace:    testCreated on:   2023-11-01 04:00:34 -0400 EDTLabels:       <none>Annotations:  <none>Spec:PodSelector:     <none> (Allowing the specific traffic to all pods in this namespace)Allowing ingress traffic:<none> (Selected pods are isolated for ingress connectivity)Not affecting egress trafficPolicy Types: Ingress

测试

# defualt 下的 busybox[root@master cks]# kubectl exec -it busybox /bin/shkubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead./ # ping 10.244.104.35PING 10.244.104.35 (10.244.104.35): 56 data bytes
# test 下的 busybox[root@master cks]# kubectl get pod  -owideNAME      READY   STATUS    RESTARTS   AGE   IP              NODE    NOMINATED NODE   READINESS GATESbusybox   1/1     Running   0          12m   10.244.104.36   node2   <none>           <none>[root@master cks]# kubectl exec -it busybox /bin/sh -n testkubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead./ # ping www.baidu.comPING www.baidu.com (14.119.104.254): 56 data bytes64 bytes from 14.119.104.254: seq=0 ttl=127 time=7.583 ms64 bytes from 14.119.104.254: seq=1 ttl=127 time=6.822 ms/ # ping 10.244.104.36PING 10.244.104.36 (10.244.104.36): 56 data bytes64 bytes from 10.244.104.36: seq=0 ttl=63 time=0.071 ms64 bytes from 10.244.104.36: seq=1 ttl=63 time=0.074 ms

结果表明:test 下的 pod 没办法被defualt的pod 访问,但是它可以访问外部

限制出站

# 默认拒绝所有入站流量apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:name: test-deny-ingressnamespace: testspec:podSelector: {}policyTypes:- Ingress- Egress
[root@master cks]# kubectl apply -f np-test-web.yaml[root@master cks]# kubectl describe NetworkPolicy -n testName:         test-deny-ingressNamespace:    testCreated on:   2023-11-01 04:00:34 -0400 EDTLabels:       <none>Annotations:  <none>Spec:PodSelector:     <none> (Allowing the specific traffic to all pods in this namespace)Allowing ingress traffic:<none> (Selected pods are isolated for ingress connectivity)Allowing egress traffic:<none> (Selected pods are isolated for egress connectivity)Policy Types: Ingress, Egress[root@master cks]# kubectl exec -it busybox /bin/sh -n testkubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead./ # ping  www.baidu.com^C/ # ping 10.244.104.36PING 10.244.104.36 (10.244.104.36): 56 data bytes^C--- 10.244.104.36 ping statistics ---3 packets transmitted, 0 packets received, 100% packet loss

pod 级别

限制单个test 下的web pod 的访问权限

限制入站

kubectl run nginx -n test --image=nginx:1.17.1 -l="app=web"[root@master cks]# kubectl get pod -n test --show-labelsNAME      READY   STATUS    RESTARTS   AGE   LABELSbusybox   1/1     Running   0          30m   run=busyboxnginx     1/1     Running   0          37s   app=web

apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:name: test-deny-ingressnamespace: testspec:podSelector:matchLabels:app: webpolicyTypes:- Ingressingress:- from:- namespaceSelector:matchLabels:kubernetes.io/metadata.name: test# - podSelector: {}  # 匹配本命名空间所有pod                             
[root@master cks]# kubectl apply -f np-test-web.yamlnetworkpolicy.networking.k8s.io/test-deny-ingress changed

测试

[root@master cks]# kubectl get pod -n test -owideNAME      READY   STATUS    RESTARTS   AGE     IP              NODE    NOMINATED NODE   READINESS GATESbusybox   1/1     Running   0          34m     10.244.104.34   node2   <none>           <none>nginx     1/1     Running   0          4m27s   10.244.104.37   node2   <none>           <none>[root@master cks]# kubectl exec -it busybox /bin/sh -n testkubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead./ # ping 10.244.104.37PING 10.244.104.37 (10.244.104.37): 56 data bytes64 bytes from 10.244.104.37: seq=0 ttl=63 time=0.148 ms64 bytes from 10.244.104.37: seq=1 ttl=63 time=0.105 ms^C--- 10.244.104.37 ping statistics ---2 packets transmitted, 2 packets received, 0% packet lossround-trip min/avg/max = 0.105/0.126/0.148 ms/ # exitcommand terminated with exit code 127[root@master cks]# kubectl exec -it busybox /bin/shkubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead./ # ping 10.244.104.37PING 10.244.104.37 (10.244.104.37): 56 data bytes^C--- 10.244.104.37 ping statistics ---3 packets transmitted, 0 packets received, 100% packet loss

其他案例

(双策略)允许其他命名空间访问指定命名空间的指定 pod

编写一个拒绝的yaml:只有本命名空间可以访问web pod

# 只允许 test 命名空间可以相互访问,拒绝其他命名空间的访问apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:name: test-deny-ingressnamespace: testspec:podSelector: {}policyTypes:- Ingressingress:- from:- namespaceSelector:matchLabels:kubernetes.io/metadata.name: test# 或者不指定ingress部分,默认是拒绝

再写一允许yaml

# 只允许test下带标签 app: web 的 pod 可以被其他命名空间访问apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:name: test-allow-ingressnamespace: testspec:podSelector:matchLabels:app: webpolicyTypes:- Ingressingress:- from:- namespaceSelector:{}
[root@master cks]# kubectl get NetworkPolicy -n testNAME                 POD-SELECTOR   AGEtest-allow-ingress   app=web        8stest-deny-ingress    <none>         56m[root@master cks]# kubectl get pod -n test -owideNAME      READY   STATUS    RESTARTS   AGE   IP              NODE    NOMINATED NODE   READINESS GATESbusybox   1/1     Running   0          68m   10.244.104.34   node2   <none>           <none>nginx     1/1     Running   0          38m   10.244.104.37   node2   <none>           <none>[root@master cks]# kubectl exec -it busybox /bin/sh -n testkubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead./ # ping 10.244.104.37PING 10.244.104.37 (10.244.104.37): 56 data bytes64 bytes from 10.244.104.37: seq=0 ttl=63 time=0.098 ms# default 命名空间访问效果
[root@master cks]# kubectl exec -it busybox /bin/shkubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead./ # ping 10.244.104.34PING 10.244.104.34 (10.244.104.34): 56 data bytes--- 10.244.104.34 ping statistics ---2 packets transmitted, 0 packets received, 100% packet loss/ # ping 10.244.104.37PING 10.244.104.37 (10.244.104.37): 56 data bytes64 bytes from 10.244.104.37: seq=0 ttl=63 time=0.118 ms

pod之间调用

同一命名空间下pod之间的调用
# 只允许 test 命名空间中的带有run:client1 可以访问apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:name: ns-app-allow-appnamespace: testspec:podSelector:matchLabels:run: webpolicyTypes:- Ingressingress:- from:- podSelector:matchLabels:run: client1         

[root@master cks]# kubectl create -f  np-test-web-client1.yamlnetworkpolicy.networking.k8s.io/ns-app-allow-app created[root@master cks]# kubectl get NetworkPolicy -n testNAME                 POD-SELECTOR   AGEns-app-allow-app     run=web        5stest-allow-ingress   app=web        2m26stest-deny-ingress    <none>         2m33s[root@master cks]# kubectl get pod -n test -owideNAME      READY   STATUS    RESTARTS   AGE     IP               NODE    NOMINATED NODE   READINESS GATESbusybox   1/1     Running   0          156m    10.244.104.34    node2   <none>           <none>client1   1/1     Running   0          2m20s   10.244.166.157   node1   <none>           <none>nginx     1/1     Running   0          126m    10.244.104.37    node2   <none>           <none>[root@master cks]# kubectl exec -it busybox /bin/sh -n testkubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead./ # ping 10.244.166.157PING 10.244.166.157 (10.244.166.157): 56 data bytes[root@master cks]# kubectl exec -it client1 /bin/sh -n testkubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead./ # ping 10.244.166.157PING 10.244.166.157 (10.244.166.157): 56 data bytes64 bytes from 10.244.166.157: seq=0 ttl=64 time=0.703 ms64 bytes from 10.244.166.157: seq=1 ttl=64 time=0.037 ms
不同命名空间下pod之间的调用
# 只允许 default 命名空间中的带有run:client1 可以访问apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:name: ns-app-allow-appnamespace: testspec:podSelector:matchLabels:run: webpolicyTypes:- Ingressingress:- from:- namespaceSelector:matchLabels:name: default   podSelector:matchLabels:run: client1         

测试

[root@master cks]# kubectl get pod -n test -owideNAME      READY   STATUS    RESTARTS   AGE    IP               NODE    NOMINATED NODE   READINESS GATESbusybox   1/1     Running   0          175m   10.244.104.34    node2   <none>           <none>client1   1/1     Running   0          21m    10.244.166.157   node1   <none>           <none>nginx     1/1     Running   0          145m   10.244.104.37    node2   <none>           <none>[root@master cks]# kubectl exec -it client1 /bin/sh -n testkubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead./ # ping 10.244.104.37PING 10.244.104.37 (10.244.104.37): 56 data bytes--- 10.244.104.37 ping statistics ---2 packets transmitted, 0 packets received, 100% packet loss[root@master cks]# kubectl exec -it client1 /bin/shkubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead./ # ping 10.244.104.37PING 10.244.104.37 (10.244.104.37): 56 data bytes64 bytes from 10.244.104.37: seq=0 ttl=63 time=0.128 ms64 bytes from 10.244.104.37: seq=1 ttl=63 time=0.090 ms

所有命名空间的指定pod
# 允许所有命名空间中的带有run:client1 可以访问apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:name: ns-app-allow-appnamespace: testspec:podSelector:matchLabels:run: webpolicyTypes:- Ingressingress:- from:- namespaceSelector: {}podSelector:matchLabels:run: client1         

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/333924.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Google Breakpad使用方法

源码下载地址&#xff1a;https://chromium.googlesource.com/breakpad/breakpad 依赖头文件下载地址&#xff1a; https://chromium.googlesource.com/linux-syscall-support Breakpad由三个主要组件&#xff1a; client 是一个库, 以library的形式内置在应用中&#xff0c…

Flask修改Response Headers中的Server值

Headers中的Server会暴露出Python版本&#xff0c;导致的结果就是方便被渗透快速定位Python版本后找到对应版本的漏洞&#xff0c;因此导致网络安全问题 伪方法&#xff1a; 像这个马上就暴露出Python版本&#xff0c;如何解决这个网络上有说直接用response.headers.remove(Ser…

Postgres 中文周报:PostgreSQL 2023 热门回顾

2024 新年好&#xff01;原英文 Postgres Weekly 最新一期回顾了 2023 周刊中的热门点击文章、视频与工具等事项。当然&#xff0c;PostgreSQL 在 2023 年值得回顾的瞬间还有很多&#xff0c;远不止周刊中提到的。因此&#xff0c;在编译原周刊内容的基础上&#xff0c;我们增加…

HarmonyOS 应用开发学习笔记 stateStyles:多态样式

1、 HarmoryOS Ability页面的生命周期 2、 Component自定义组件 3、HarmonyOS 应用开发学习笔记 ets组件生命周期 4、HarmonyOS 应用开发学习笔记 ets组件样式定义 Styles装饰器&#xff1a;定义组件重用样式 Extend装饰器&#xff1a;定义扩展组件样式 前面记录了ets组件样式…

1-04C语言执行过程

一、概述 本小节主要讲解一个C程序从源代码到最终执行的过程&#xff0c;这个过程又可以细分为两部分&#xff1a; 源代码到可执行文件的过程可执行文件在内存中执行 本小节是C语言基础当中&#xff0c;比较容易被初学者忽视的知识点。而实际上&#xff1a; 熟悉C程序从源文…

使用curl命令在Linux中进行HTTP请求

在Linux中&#xff0c;curl是一个非常强大的命令行工具&#xff0c;用于发送HTTP请求。它允许用户发送各种类型的HTTP请求&#xff0c;如GET、POST、PUT、DELETE等&#xff0c;并能够处理响应数据。 首先&#xff0c;确保您的Linux系统已经安装了curl。如果未安装&#xff0c;…

OpenVoice实时语音克隆功能实现

前言 在【OpenVoice本地部署教程与踩坑记录】一文中介绍了OpenVoice的基本概念与&#xff0c;并且完成了项目的安装与运行。官方给的示例和用法中仅包含了文本转TTS再克隆音色的功能&#xff0c;仅能用于TTS场景下的文字朗读。 本文基于官方示例改造&#xff0c;实现了实时采集…

亿尚网:撤柜上线电商+直播将成为美妆行业发展的绝佳组合

亿尚网&#xff1a;撤柜上线电商直播将成为美妆行业发展的绝佳组合 来源&#xff1a; 编辑&#xff1a;亿尚风范 时间&#xff1a;2024-01-09 随着社交媒体的兴起&#xff0c;网红经济逐渐成为市场中的一股不可忽视的力量。而在这其中&#xff0c;直播电商的模式更是为网红们…

前端实现搜索功能

最近遇到一个需求,用户在输入框输入关键字之后,点击搜索按钮后进行搜索,如下图,选中的数据在下面,上面展现的是搜索后的数据,现在选中了2条数据: 当用户输入KET后点击搜索,搜出的结果有16条,勾选全选选中后,将选中的16条的数据加到之前已选的2条数据里,于是此时已选…

阿里云云服务器u1实例和e实例有什么区别?

阿里云服务器u1和e实例有什么区别&#xff1f;ECS通用算力型u1实例是企业级独享型云服务器&#xff0c;ECS经济型e实例是共享型云服务器&#xff0c;所以相比较e实例&#xff0c;云服务器u1性能更好一些。e实例为共享型云服务器&#xff0c;共享型实例采用非绑定CPU调度模式&am…

如何启动、停止rocketmq

RocketMQ 是一个分布式消息中间件&#xff0c;启动、停止RocketMQ 实际上意味着重启 RocketMQ 的各个组件&#xff0c;包括 Namesrv、Broker 等。以下是一个通用的重启步骤&#xff0c;具体步骤可能会根据你的部署方式和 RocketMQ 版本有所不同&#xff1a; 1. 停止rocketmq …

prometheus 监控 Hyperledger Fabric 网络

本例中使用的 fabric 版本为 2.4.1 修改 orderer , peer 节点 docker-compose 文件 orderer 节点&#xff1a; environment:- ORDERER_METRICS_PROVIDERprometheus- ORDERER_OPERATIONS_LISTENADDRESS0.0.0.0:8443 ports:- 8443:8443peer 节点&#xff1a; environment:- CO…