kubernetes微服务基础及类型

目录

1 什么是微服务

2 微服务的类型

3 ipvs模式

ipvs模式配置方式

4 微服务类型详解

4.1 ClusterIP

4.2 ClusterIP中的特殊模式headless

4.3 nodeport

4.4 metalLB配合loadbalance实现发布IP


1 什么是微服务

用控制器来完成集群的工作负载,那么应用如何暴漏出去?需要通过微服务暴漏出去后才能被访问

  • Service是一组提供相同服务的Pod对外开放的接口。

  • 借助Service,应用可以实现服务发现和负载均衡。

  • service默认只支持4层负载均衡能力,没有7层功能。(可以通过Ingress实现)

2 微服务的类型

微服务类型作用描述
ClusterIP默认值,k8s系统给service自动分配的虚拟IP,只能在集群内部访问
NodePort将Service通过指定的Node上的端口暴露给外部,访问任意一个NodeIP:nodePort都将路由到ClusterIP
LoadBalancer在NodePort的基础上,借助cloud provider创建一个外部的负载均衡器,并将请求转发到 NodeIP:NodePort,此模式只能在云服务器上使用
ExternalName将服务通过 DNS CNAME 记录方式转发到指定的域名(通过 spec.externlName 设定

[root@k8s-master yaml]# kubectl create deployment testpod --image myapp:v1 --replicas 2 --dry-run=client -o yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: testpod
  name: testpod
spec:
  replicas: 2
  selector:
    matchLabels:
      app: testpod
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: testpod
    spec:
      containers:
      - image: myapp:v1
        name: myapp
        resources: {}
status: {}

[root@k8s-master yaml]# kubectl create deployment testpod \
--image myapp:v1 --replicas 2 --dry-run=client -o yaml > testpod.yml

# 修改之后的
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: testpod
  name: testpod
spec:
  replicas: 2
  selector:
    matchLabels:
      app: testpod
  template:
    metadata:
      labels:
        app: testpod
    spec:
      containers:
      - image: myapp:v1
        name: myapp

启动并查看状态

[root@k8s-master yaml]# kubectl apply -f testpod.yml 
deployment.apps/testpod created

[root@k8s-master yaml]# kubectl get pods 
NAME                       READY   STATUS    RESTARTS   AGE
testpod-7b864c4646-ds7p8   1/1     Running   0          5s
testpod-7b864c4646-x8lzf   1/1     Running   0          5s

[root@k8s-master yaml]# kubectl get deployments.apps 
NAME      READY   UP-TO-DATE   AVAILABLE   AGE
testpod   2/2     2            2           16s

[root@k8s-master yaml]# kubectl get deployments.apps --show-labels 
NAME      READY   UP-TO-DATE   AVAILABLE   AGE   LABELS
testpod   2/2     2            2           23s   app=testpod

为 testpod 增加服务资源 

[root@k8s-master yaml]# kubectl expose deployment testpod \
--port 80 --dry-run=client -o yaml

apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    app: testpod
  name: testpod
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: testpod
status:
  loadBalancer: {}

[root@k8s-master yaml]# kubectl expose deployment testpod \
--port 80 --dry-run=client -o yaml >> testpod.yml 


apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: testpod
  name: testpod
spec:
  replicas: 2
  selector:
    matchLabels:
      app: testpod
  template:
    metadata:
      labels:
        app: testpod
    spec:
      containers:
      - image: myapp:v1
        name: myapp

---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: testpod
  name: testpod
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: testpod

声明一下控制器并测试

[root@k8s-master yaml]# kubectl apply -f testpod.yml 
deployment.apps/testpod unchanged
service/testpod created


[root@k8s-master yaml]# kubectl get services 
NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.96.0.1       <none>        443/TCP   3d11h
testpod      ClusterIP   10.107.129.69   <none>        80/TCP    6m55s

[root@k8s-master yaml]# curl 10.107.129.69
Hello MyApp | Version: v1 | <a href="hostname.html">Pod Name</a>

[root@k8s-master yaml]# curl 10.107.129.69
Hello MyApp | Version: v1 | <a href="hostname.html">Pod Name</a>

微服务默认使用iptables调度

[root@k8s-master yaml]# kubectl get services --show-labels 
NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE     LABELS
kubernetes   ClusterIP   10.96.0.1       <none>        443/TCP   3d11h   component=apiserver,provider=kubernetes
testpod      ClusterIP   10.107.129.69   <none>        80/TCP    14m     app=testpod

[root@k8s-master yaml]# iptables -nL -t nat 

3 ipvs模式

  • Service 是由 kube-proxy 组件,加上 iptables 来共同实现的

  • kube-proxy 通过 iptables 处理 Service 的过程,需要在宿主机上设置相当多的 iptables 规则,如果宿主机有大量的Pod,不断刷新iptables规则,会消耗大量的CPU资源

  • IPVS模式的service,可以使K8s集群支持更多量级的Pod

ipvs模式配置方式

1 在所有节点中安装ipvsadm

[root@k8s-master yaml]# yum install ipvsadm -y

2 设置为ipvs模式

 [root@k8s-master yaml]# kubectl -n kube-system edit cm kube-proxy

 metricsBindAddress: ""
    mode: "ipvs"
    nftables:
      masqueradeAll: false

3 重启pod,在pod运行时配置文件中采用默认配置,当改变配置文件后已经运行的pod状态不会变化,所以要重启pod

以下使用的方法是删掉命名空间中的pod控制器的缘故会重新起一个

[root@k8s-master yaml]# kubectl -n kube-system get pods | \
awk '/proxy/{system("kubectl -n kube-system delete pods " $1)}'

pod "kube-proxy-4fllj" deleted
pod "kube-proxy-6jgd2" deleted
pod "kube-proxy-zkn5x" deleted

# 由于使用的是deployment控制器,删除了之后会再次启动
[root@k8s-master yaml]# kubectl -n kube-system get pods 
NAME                                 READY   STATUS    RESTARTS      AGE
coredns-66d4c695bb-29qbq             1/1     Running   2 (28h ago)   3d11h
coredns-66d4c695bb-6th24             1/1     Running   2 (28h ago)   3d11h
etcd-k8s-master                      1/1     Running   2 (28h ago)   3d11h
kube-apiserver-k8s-master            1/1     Running   2 (28h ago)   3d11h
kube-controller-manager-k8s-master   1/1     Running   2 (28h ago)   3d11h
kube-proxy-4p7ds                     1/1     Running   0             15s
kube-proxy-ggnb6                     1/1     Running   0             14s
kube-proxy-r66fc                     1/1     Running   0             14s
kube-scheduler-k8s-master            1/1     Running   2 (28h ago)   3d11h

# 查看ipvs策略是否加载
[root@k8s-master yaml]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  10.96.0.1:443 rr
  -> 192.168.239.100:6443         Masq    1      0          0         
TCP  10.96.0.10:53 rr
  -> 10.244.0.2:53                Masq    1      0          0         
  -> 10.244.0.3:53                Masq    1      0          0         
TCP  10.96.0.10:9153 rr
  -> 10.244.0.2:9153              Masq    1      0          0         
  -> 10.244.0.3:9153              Masq    1      0          0         
TCP  10.107.129.69:80 rr
  -> 10.244.1.29:80               Masq    1      0          0         
  -> 10.244.2.33:80               Masq    1      0          0         
UDP  10.96.0.10:53 rr
  -> 10.244.0.2:53                Masq    1      0          0         
  -> 10.244.0.3:53                Masq    1      0          0  

在使用ipvs模式之后发现添加了一个网卡专属于ipvs的

[root@k8s-master yaml]# ip a | tail
    inet6 fe80::78a9:7cff:fe93:958a/64 scope link 
       valid_lft forever preferred_lft forever
11: kube-ipvs0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default 
    link/ether c6:3e:41:c4:d3:9f brd ff:ff:ff:ff:ff:ff
    inet 10.96.0.1/32 scope global kube-ipvs0
       valid_lft forever preferred_lft forever
    inet 10.107.129.69/32 scope global kube-ipvs0
       valid_lft forever preferred_lft forever
    inet 10.96.0.10/32 scope global kube-ipvs0
       valid_lft forever preferred_lft forever

4 微服务类型详解

4.1 ClusterIP

特点:

clusterip模式只能在集群内访问,并对集群内的pod提供健康检测和自动发现功能

默认值,k8s系统给service自动分配的虚拟IP,只能在集群内部访问

并且在集群内访问是通过域名的方式来访问的

示例:

# 创建一个pod
[root@k8s-master yaml]# kubectl run testpods --image myapp:v1  

# 查看pod 的IP 与标签
[root@k8s-master yaml]# kubectl get pods -o wide --show-labels 
NAME       READY   STATUS    RESTARTS   AGE   IP            NODE        NOMINATED NODE   READINESS GATES   LABELS
testpods   1/1     Running   0          10m   10.244.1.36   k8s-node1   <none>           <none>            run=testpods

# 创建services 的 yaml 文件将刚刚创建的pod对外发布

[root@k8s-master yaml]# kubectl expose pod testpods --port 80 \
--target-port 80 --dry-run=client -o yaml > servise.yml

[root@k8s-master yaml]# vim servise.yml 
# 以下是修改过后的
apiVersion: v1
kind: Service
metadata:
  labels:
    run: testpods
  name: testpods
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    run: testpods    # 这里的值必须与pod的标签一致不然就无法对外发布
  type: ClusterIP    # 这里使用ClusterIP,不写也没有关系,因为是默认值

 声明一下

[root@k8s-master yaml]# kubectl apply -f servise.yml 
service/testpods created



[root@k8s-master yaml]# kubectl describe service testpods 
Name:              testpods
Namespace:         default
Labels:            run=testpods
Annotations:       <none>
Selector:          run=testpods
Type:              ClusterIP
IP Family Policy:  SingleStack
IP Families:       IPv4
IP:                10.97.188.175     # 前端IPVS调度IP
IPs:               10.97.188.175
Port:              <unset>  80/TCP
TargetPort:        80/TCP
Endpoints:         10.244.1.36:80    # Endpoints显示的为后端pod的IP
Session Affinity:  None
Events:            <none>


[root@k8s-master yaml]# kubectl get services 
NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.96.0.1       <none>        443/TCP   4d9h
testpods     ClusterIP   10.97.188.175   <none>        80/TCP    2m53s

 为了掩饰标签一致性才能对外发布,以下实验实例

以上面实验为基础,创建一个新的pod 并修改他的标签

[root@k8s-master yaml]# kubectl run testpods1 --image myapp:v2 
pod/testpods1 created

[root@k8s-master yaml]# kubectl get pods --show-labels 
NAME        READY   STATUS    RESTARTS   AGE   LABELS
testpods    1/1     Running   0          27m   run=testpods
testpods1   1/1     Running   0          15s   run=testpods1


[root@k8s-master yaml]# kubectl describe service testpods 
Name:              testpods
Namespace:         default
Labels:            run=testpods
Annotations:       <none>
Selector:          run=testpods
Type:              ClusterIP
IP Family Policy:  SingleStack
IP Families:       IPv4
IP:                10.97.188.175
IPs:               10.97.188.175
Port:              <unset>  80/TCP
TargetPort:        80/TCP
Endpoints:         10.244.1.36:80        # 此时就只有原先的pod
Session Affinity:  None
Events:            <none>

# 将新创建的pod标签修改覆盖 
[root@k8s-master yaml]# kubectl label pods testpods1 run=testpods --overwrite 
pod/testpods1 labeled


# 查看Endpoints的变化
[root@k8s-master yaml]# kubectl describe service testpods 
Name:              testpods
Namespace:         default
Labels:            run=testpods
Annotations:       <none>
Selector:          run=testpods
Type:              ClusterIP
IP Family Policy:  SingleStack
IP Families:       IPv4
IP:                10.97.188.175
IPs:               10.97.188.175
Port:              <unset>  80/TCP
TargetPort:        80/TCP
Endpoints:         10.244.1.36:80,10.244.2.42:80
Session Affinity:  None
Events:            <none>

# 集群内访问他发现是轮循
[root@k8s-master yaml]# curl 10.97.188.175
Hello MyApp | Version: v2 | <a href="hostname.html">Pod Name</a>
[root@k8s-master yaml]# curl 10.97.188.175
Hello MyApp | Version: v1 | <a href="hostname.html">Pod Name</a>
[root@k8s-master yaml]# curl 10.97.188.175
Hello MyApp | Version: v2 | <a href="hostname.html">Pod Name</a>
[root@k8s-master yaml]# curl 10.97.188.175
Hello MyApp | Version: v1 | <a href="hostname.html">Pod Name</a>
[root@k8s-master yaml]# curl 10.97.188.175
Hello MyApp | Version: v2 | <a href="hostname.html">Pod Name</a>

查看集群内DNS服务

[root@k8s-master yaml]# kubectl -n kube-system get service
NAME       TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)                  AGE
kube-dns   ClusterIP   10.96.0.10   <none>        53/UDP,53/TCP,9153/TCP   4d9h

查看testpod 的域名解析是否正常 

[root@k8s-master yaml]# dig testpods.default.svc.cluster.local. @10.96.0.10

; <<>> DiG 9.16.23-RH <<>> testpods.default.svc.cluster.local. @10.96.0.10
;; global options: +cmd
;; Got answer:
;; WARNING: .local is reserved for Multicast DNS
;; You are currently testing what happens when an mDNS query is leaked to DNS
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 59510
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: e633e2637dcddbd3 (echoed)
;; QUESTION SECTION:
;testpods.default.svc.cluster.local. IN A

;; ANSWER SECTION:
testpods.default.svc.cluster.local. 8 IN A      10.97.188.175  # 为前端services 的IP

;; Query time: 1 msec
;; SERVER: 10.96.0.10#53(10.96.0.10)
;; WHEN: Sat Sep 07 11:27:16 CST 2024
;; MSG SIZE  rcvd: 125

新建一个容器查看 

[root@k8s-master yaml]# kubectl run busybox -it \
 --image busyboxplus:latest  -- /bin/sh

/ # nslookup testpods
Server:    10.96.0.10
Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local

Name:      testpods
Address 1: 10.97.188.175 testpods.default.svc.cluster.local

/ # cat /etc/resolv.conf 
nameserver 10.96.0.10
search default.svc.cluster.local svc.cluster.local cluster.local
options ndots:5


/ # curl testpods
Hello MyApp | Version: v2 | <a href="hostname.html">Pod Name</a>
/ # curl testpods
Hello MyApp | Version: v1 | <a href="hostname.html">Pod Name</a>
/ # curl testpods
Hello MyApp | Version: v2 | <a href="hostname.html">Pod Name</a>
/ # curl testpods.default.svc.cluster.local.
Hello MyApp | Version: v1 | <a href="hostname.html">Pod Name</a>
/ # curl testpods.default.svc.cluster.local.
Hello MyApp | Version: v2 | <a href="hostname.html">Pod Name</a>
/ # curl testpods.default.svc.cluster.local.
Hello MyApp | Version: v1 | <a href="hostname.html">Pod Name</a>

4.2 ClusterIP中的特殊模式headless

headless(无头服务)

Headless Services是一种特殊的service,其spec:clusterIP表示为None,这样在实际运行时就不会被分配ClusterIP。也被称为无头服务。

对于无头 Services 并不会分配 Cluster IP,kube-proxy不会处理它们, 而且平台也不会为它们进行负载均衡和路由,集群访问通过dns解析直接指向到业务pod上的IP,所有的调度有dns单独完成

# 可以是控制器
---
apiVersion: v1
kind: Service
metadata:
  name: testpods
  labels:
    run: testpods
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    run: testpods
  type: ClusterIP
  clusterIP: None  # 直接设置为 None

[root@k8s-master yaml]# kubectl delete service testpods 
service "testpods" deleted

[root@k8s-master yaml]# kubectl apply -f servise.yml 
service/testpods created

[root@k8s-master yaml]# kubectl get service
NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP   4d20h
testpods     ClusterIP   None         <none>        80/TCP    13s


[root@k8s-master yaml]# kubectl describe service testpods 
Name:              testpods
Namespace:         default
Labels:            run=testpods
Annotations:       <none>
Selector:          run=testpods
Type:              ClusterIP
IP Family Policy:  SingleStack
IP Families:       IPv4
IP:                None            # 没有前端,证明不经过服务直接转到了后端pod
IPs:               None
Port:              <unset>  80/TCP
TargetPort:        80/TCP
Endpoints:         10.244.1.36:80,10.244.2.42:80  
Session Affinity:  None
Events:            <none>

4.3 nodeport

通过ipvs暴漏端口从而使外部主机通过master节点的对外ip:<port>来访问pod业务

其访问过程为:

---
apiVersion: v1
kind: Service
metadata:
  name: testpods
  labels:
    run: testpods
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    run: testpods
  type: NodePort

[root@k8s-master yaml]# kubectl delete -f servise.yml
[root@k8s-master yaml]# kubectl apply -f servise.yml 

[root@k8s-master yaml]# kubectl get service
NAME         TYPE           CLUSTER-IP       EXTERNAL-IP       PORT(S)        AGE
kubernetes   ClusterIP      10.96.0.1        <none>            443/TCP        5d
testpods     NodePort       10.111.173.191   <none>            80:30110/TCP   4s


[root@complete ~]# curl 192.168.239.100:30110
Hello MyApp | Version: v1 | <a href="hostname.html">Pod Name</a>
[root@complete ~]# curl 192.168.239.100:30110
Hello MyApp | Version: v2 | <a href="hostname.html">Pod Name</a>
[root@complete ~]# curl 192.168.239.100:30110
Hello MyApp | Version: v1 | <a href="hostname.html">Pod Name</a>
[root@complete ~]# curl 192.168.239.100:30110
Hello MyApp | Version: v2 | <a href="hostname.html">Pod Name</a>

4.4 metalLB配合loadbalance实现发布IP


MetalLB 是一个流行的开源解决方案,用于在 Kubernetes 集群中提供类似于云提供商的 LoadBalancer 类型服务的功能。MetalLB 允许你在没有云提供商的情况下,在物理服务器或私有云环境中分配和管理外部 IP 地址。

MetalLB 是一个专注于解决 Kubernetes 集群内部负载均衡问题的工具,特别是在没有云提供商负载均衡器支持的环境下。它提供了类似云提供商负载均衡器的功能,使得 Kubernetes 服务能够通过 LoadBalancer 类型的服务暴露到外部网络。MetalLB 不是用来搭建整个云平台的工具,而是为了解决特定的网络负载均衡需求。如果需要构建完整的云平台,还需要考虑其他组件和技术栈,比如计算、存储、网络虚拟化等。

# 使用魔法下载镜像
[root@k8s-master loadbanlan]# docker pull quay.io/metallb/speaker:v0.14.8
[root@k8s-master loadbanlan]# docker pull quay.io/metallb/controller:v0.14.8

# 打上标签
[root@k8s-master loadbanlan]# docker tag quay.io/metallb/controller:v0.14.8 reg.shuyan.com/metallb/controller:v0.14.8 
[root@k8s-master loadbanlan]# docker tag quay.io/metallb/speaker:v0.14.8 reg.shuyan.com/metallb/speaker:v0.14.8


# 传到自己的镜像仓库
[root@k8s-master ~]# docker push reg.shuyan.com/metallb/controller:v0.14.8
[root@k8s-master ~]# docker push reg.shuyan.com/metallb/speaker:v0.14.8

下载部署文件 

wget https://raw.githubusercontent.com/metallb/metallb/v0.13.12/config/manifests/metallb-native.yaml

修改下载下来的文件

指定自己的镜像仓库

[root@k8s-master loadbanlan]# vim metallb-native.yaml 
image: metallb/speaker:v0.14.8
image: metallb/controller:v0.14.8

apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
  name: first-pool
  namespace: metallb-system
spec:
  addresses:
  - 192.168.239.200-192.168.239.250

---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
  name: example
  namespace: metallb-system
spec:
  ipAddressPools:
  - first-pool

在 Kubernetes 中,LoadBalancer 类型的 Service 是一种特殊的 Service,它旨在将集群内部的服务暴露给外部网络。LoadBalancer 类型的 Service 通过使用云提供商或网络负载均衡器将外部流量路由到集群内的后端服务。

[root@k8s-master loadbanlan]# kubectl create deployment load \
--image myapp:v1 --dry-run=client -o yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: load
  name: load
spec:
  replicas: 1
  selector:
    matchLabels:
      app: load
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: load
    spec:
      containers:
      - image: myapp:v1
        name: myapp
        resources: {}
status: {}

[root@k8s-master loadbanlan]# kubectl create deployment load \
--image myapp:v1 --dry-run=client -o yaml > load.yml

[root@k8s-master loadbanlan]# kubectl expose deployment load \
--port 80 --target-port 80 --dry-run=client -o yaml

apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    app: load
  name: load
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: load
status:
  loadBalancer: {}

[root@k8s-master loadbanlan]# kubectl expose deployment load \
--port 80 --target-port 80 --dry-run=client -o yaml >> load.yml

# 修改之后的
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: load
  name: load
spec:
  replicas: 4
  selector:
    matchLabels:
      app: load
  template:
    metadata:
      labels:
        app: load
    spec:
      containers:
      - image: myapp:v1
        name: myapp
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: load
  name: load
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: load
  type: LoadBalancer

声明分配IP的配置文件

[root@k8s-master loadbanlan]# kubectl apply -f configmap.yml 
ipaddresspool.metallb.io/first-pool created
l2advertisement.metallb.io/example created


[root@k8s-master loadbanlan]# kubectl get service
NAME         TYPE           CLUSTER-IP       EXTERNAL-IP       PORT(S)        AGE
kubernetes   ClusterIP      10.96.0.1        <none>            443/TCP        4d23h
load         LoadBalancer   10.105.244.178   192.168.239.200   80:30911/TCP   16m
testpods     ClusterIP      None             <none>            80/TCP         3h13m

不在kubernetes集群中的也能直接访问到

[root@complete ~]# curl 192.168.239.200
Hello MyApp | Version: v1 | <a href="hostname.html">Pod Name</a>

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

【卷起来】VUE3.0教程-08-路由管理

在Vue中&#xff0c;我们可以通过vue-router路由管理页面之间的关系。 Vue Router是Vue.js的官方路由&#xff0c;它与Vue.js核心深度集成&#xff0c;让用Vue.js构建单页应用变得轻而易举。 &#x1f332; 在Vue中引入路由 安装路由 npm install --save vue-router 建立三个…

详聊LLaMa技术细节:LLaMA大模型是如何炼成的?

本文介绍来自 Meta AI 的 LLaMa 模型&#xff0c;类似于 OPT&#xff0c;也是一种完全开源的大语言模型。LLaMa 的参数量级从 7B 到 65B 大小不等&#xff0c;是在数万亿个 token 上面训练得到。值得一提的是&#xff0c;LLaMa 虽然只使用公共的数据集&#xff0c;依然取得了强…

读论文-《基于计算机视觉的工业金属表面缺陷检测综述》

文章目录 1. 背景1.1 工业需求1.2 传统方法的局限1.3 计算机视觉技术的优势 2. 技术流程2.1 光学成像2.1.1照明方式2.1.2 缺陷和背景特性 2.2 图像预处理2.3 缺陷检测2.4 结果分析和决策 3. 关键算法3.1 光学成像技术相关算法3.2 图像预处理相关算法3.2.1 图像增强3.2.2特征提取…

【JS】将class转为构造函数需要注意的细节

前言 将 class 转为构造函数看似很简单&#xff0c;但作为封装者&#xff0c;有很多注意事项 class Person {constructor(name) {this.name name;}fn() { console.log(this.name); } }实现 初步转化如下&#xff1a; function Person() {this.name name } Person.prototy…

网络学习-eNSP配置VRRP

虚拟路由冗余协议(Virtual Router Redundancy Protocol&#xff0c;简称VRRP) VRRP广泛应用在边缘网络中&#xff0c;是一种路由冗余协议&#xff0c;它的设计目标是支持特定情况下IP数据流量失败转移不会引起混乱&#xff0c;允许主机使用单路由器&#xff0c;以及即使在实际…

二百六十三、Java——IDEA项目打成jar包,然后在Linux中运行

一、目的 在用Java对原Kafka的JSON字段解析成一条条数据&#xff0c;然后写入另一个Kafka中&#xff0c;代码写完后打成jar包&#xff0c;放在Linux中&#xff0c;直接用海豚调度运行 二、Java利用fastjson解析复杂嵌套json字符串 这一块主要是参考了这个文档&#xff0c;然…

如何进行DAP-seq的数据挖掘,筛选验证位点

从样本准备到寄送公司&#xff0c;每一天都在“祈祷”有个心仪的分析结果&#xff0c;终于在这天随着邮件提示音的响起&#xff0c;收到了分析结果...... 分析前工作 爱基在进行数据分析之前&#xff0c;会有两次质控报告反馈给老师们。第一个&#xff0c;基因组DNA的提取质控…

Django路由访问及查询数据

1、在应用模块下&#xff0c;创建urls文件&#xff0c;用来存放访问路由 2、在项目总访问url里面注册路由 3、在view文件里&#xff0c;定义方法参数 from django.core import serializers from django.db import connection from django.http import HttpResponse, JsonRespo…

什么是线程池?从底层源码入手,深度解析线程池的工作原理

导航&#xff1a; 【Java笔记踩坑汇总】Java基础JavaWebSSMSpringBootSpringCloud瑞吉外卖/谷粒商城/学成在线设计模式面试题汇总性能调优/架构设计源码解析 目录 一、什么是线程池&#xff1f; 1.1 基本介绍 1.2 创建线程的两种方式 1.2.1 方式1&#xff1a;自定义线程池…

NASA数据集:高级星载热发射和反射辐射计(ASTER)1B 级快速传感器辐射度登记全球数据产品

目录 简介 代码 引用 网址推荐 0代码在线构建地图应用 机器学习 ASTER L1B Registered Radiance at the Sensor V003 ASTER 加急 L1B 登记传感器 V003 的辐照度 简介 高级星载热发射和反射辐射计&#xff08;ASTER&#xff09;1B 级快速传感器辐射度登记全球数据产品是…

AIGC简化文件管理:Python自动重命名Word和PDF文件

1.背景 大家应该也有遇到&#xff0c;自己电脑有很多文件命名不合理的文件&#xff0c;比如&#xff1a;文件1、想法3 &#xff0c;当你长时间再看到这个文件的时候&#xff0c;已经很难知道文件内容。 今天我们将借助AIGC的编码能力&#xff0c;帮我们生成一个批量改文件名的…

语法基础课第五节字符串(知识点+题目)

字符串是计算机与人类沟通的重要手段。 1. 字符与整数的联系——ASCII码 每个常用字符都对应一个-128 ~ 127的数字&#xff0c;二者之间可以相互转化。注意&#xff1a;目前负数没有与之对应的字符。&#xff08;英文&#xff09; #include <iostream>using namespace…

Unity让摄像机跟随物体的方法(不借助父子关系)

在Unity中&#xff0c;不使用子对象的方式让相机跟随物体移动&#xff0c;我们通过编写脚本来实现。下面放一个从工程中摘出来的的C#脚本示例&#xff0c;用于将相机绑定到一个Target对象上并跟随其移动&#xff1a; using UnityEngine; public class FollowCamera : MonoBeh…

Python | Leetcode Python题解之第400题第N位数字

题目&#xff1a; 题解&#xff1a; class Solution:def findNthDigit(self, n: int) -> int:d, count 1, 9while n > d * count:n - d * countd 1count * 10index n - 1start 10 ** (d - 1)num start index // ddigitIndex index % dreturn num // 10 ** (d - d…

DroidBot-GPT: GPT-powered UI Automation for Android论文学习

本文介绍了DroidBot GPT&#xff0c;这是一种利用类似GPT的大型语言模型&#xff08;LLM&#xff09;自动化与Android移动应用程序交互的工具。给定所需任务的自然语言描述&#xff0c;DroidBot GPT可以自动生成并执行导航应用程序以完成任务的操作。它的工作原理是将应用程序G…

LabVIEW软件,如何检测连接到的设备?

在LabVIEW软件中&#xff0c;检测连接到的设备通常是通过NI提供的硬件驱动和相关工具来完成的。以下是几种常见的检测设备的方法&#xff1a; 1. 使用NI MAX&#xff08;Measurement & Automation Explorer&#xff09; 打开NI MAX&#xff1a;LabVIEW设备管理通常通过NI …

完整指南:CNStream流处理多路并发框架适配到NVIDIA Jetson Orin (四) 运行、调试、各种问题解决

目录 1 调试jetson-mpeg视频解码模块 1.1 修改config.json 1.2 Picture size 0x0 is invalid 1.3 Process(): Send package failed. Maximum number of attempts reached 1.4 Picture size 2239821608x65535 is invalid 1.5 保存h264文件解码之后的测试图片 1.6 保存RTS…

【CanMV K230 AI视觉】 人体检测

【CanMV K230 AI视觉】 人体检测 人体检测 动态测试效果可以去下面网站自己看。 B站视频链接&#xff1a;已做成合集 抖音链接&#xff1a;已做成合集 人体检测 人体检测是判断摄像头画面中有无出现人体&#xff0c;常用于人体数量检测&#xff0c;人流量监控以及安防监控等。…

“版权护航·星影计划”暨电影《末代天师》发布仪式

2024 年 9 月 10 日&#xff0c;由华纳星辰&#xff08;北京&#xff09;文化传媒有限公司与浙江焱煌影视文化传媒有限公司共同主办的 “版权护航・星影计划” 暨网络电影《末代天师》新闻发布会&#xff0c;在北京渔阳饭店世纪宴会厅华彩盛启。 北京影视艺术学会会长张连生、中…

springboot luttuc redis 集成protobuf,手动序列化反序列化

前置需知&#xff1a; 1.本文章和网上大部分博客配置不太一样&#xff0c;各位看官要分析一下自己的需求。集成protobuf 本文章主要是手动调用protobuf的序列化方法&#xff0c;而不是交由springboot 去做&#xff0c;会偏向原生java 使用方式 2.由于为了和公司其他的项目达成…