Kubernetes资源详解

news2024/10/6 7:01:58

华子目录

  • 1.Kubernetes中的资源
    • 1.1资源管理介绍
    • 1.2资源管理方式
      • 1.2.1命令式对象管理
      • 1.2.2`kubectl`常见`command`命令
      • 1.2.3资源类型
      • 1.2.4常用资源类型
  • `基本命令`示例
  • `运行和调试`命令示例
  • `高级命令`示例
    • 总结
  • `其他命令`示例
  • `create`和`apply`区别案例
  • 显示`命名空间`
  • 查看`命名空间`中的`pod`
  • 如何对外`暴露端口`
  • 查看`某一个pod`的详细信息

1.Kubernetes中的资源

1.1资源管理介绍

在这里插入图片描述

  • kubernetes中,所有的内容都抽象为资源,用户需要通过操作资源来管理kubernetes
  • kubernetes 本质上就是一个集群系统,用户可以在集群部署各种服务
  • 所谓的部署服务,其实就是在kubernetes集群中运行一个个的容器,并将指定的程序跑在容器
  • kubernetes最小管理单元pod不是容器只能容器放在pod
  • kubernetes一般也不会直接管理pod,而是通过pod控制器来管理pod
  • pod容器服务访问是由kubernetes提供的service资源来实现的。pod中的容器不能直接被访问,需要通过service微服务端口进行暴露,最终我们通过微服务来访问pod中的容器
  • pod中程序的数据需要持久化是由kubernetes提供的各种存储系统来实现的

1.2资源管理方式

  • 命令式对象管理:直接使用命令去操作kubernetes资源
[root@k8s-master ~]# kubectl run nginx-pod --image=nginx:latest --port=80

#nginx-pod是pod名
  • 命令式对象配置:通过命令配置配置文件去操作kubernetes资源
    • 不能对yaml中的内容做更新k8s不允许对create创建的yaml文件进行修改
[root@k8s-master ~]# kubectl  create/patch  -f  nginx-pod.yml
  • 声明式对象配置:通过apply命令和配置文件去操作kubernetes资源
    • 可以对yaml中的内容做更新(修改完yaml文件的内容后,可以使用apply对其进行应用
[root@k8s-master ~]# kubectl  apply  -f  nginx-pod.yml
类型适用环境优点缺点
命令式对象管理测试简单只能操作活动对象,无法审计,跟踪
命令式对象配置开发可以审计,跟踪项目大时,配置文件多,操作麻烦
声明式对象配置开发支持目录操作意外情况下难以调试

1.2.1命令式对象管理

  • kubectlkubernetes集群的命令行工具,通过它能够对集群本身进行管理,并能够在集群上进行容器化应用的安装部署
  • kubectl命令的语法如下:
[root@k8s-master ~]# kubectl  [command]  [type]  [name]  [flags]
  • command:指定要对资源执行的操作,例如creategetdelete
  • type:指定资源类型,比如deploymentpodservice
  • name:指定资源名称名称大小写敏感
  • flags:指定额外可选参数

查看所有pod

[root@k8s-master ~]# kubectl get pods 

查看某一个pod

[root@k8s-master ~]# kubectl get pods pod名

查看某个pod,以yaml格式显示

[root@k8s-master ~]# kubectl get pods pod名 -o yaml

创建两个名为webserver1webserver2pod

  • 其中myapp是一个nginx服务
[root@k8s-master ~]# kubectl run webserver1 --image myapp:v1
pod/webserver1 created
[root@k8s-master ~]# kubectl run webserver2 --image myapp:v2
pod/webserver2 created


[root@k8s-master ~]# kubectl get pods
NAME         READY   STATUS    RESTARTS   AGE
webserver1   1/1     Running   0          8m27s
webserver2   1/1     Running   0          6m37s


[root@k8s-master ~]# kubectl get pods -o wide
NAME         READY   STATUS    RESTARTS   AGE   IP           NODE            NOMINATED NODE   READINESS GATES
webserver1   1/1     Running   0          2m    10.244.1.2   k8s-node1.org   <none>           <none>
webserver2   1/1     Running   0          10s   10.244.2.6   k8s-node2.org   <none>           <none>


[root@k8s-master ~]# kubectl get pods -o name
pod/webserver1
pod/webserver2

1.2.2kubectl常见command命令

命令分类命令翻译命令作用
基本命令create创建创建一个资源
edit编辑编辑一个资源
get获取获取一个资源
patch补丁更新更新一个资源
delete删除删除一个资源
explain解释展示资源文档
运行和调试run运行集群运行一个指定的镜像
expose暴露暴露资源为service
describe描述显示资源内部信息
logs日志输出容器pod中的日志
attach缠绕进入运行中的容器
exec执行执行容器中的一个命令
cp复制pod内外复制文件
rollout首次展示管理资源的发布
scale规模扩(缩)容pod的数量
autoscale自动调整自动调整pod数量
高级命令apply应用通过文件资源进行配置
label标签更新资源上的标签
其他命令cluster-info集群信息显示集群信息
version版本显示当前serverclient版本

1.2.3资源类型

kubernetes所有的内容都抽象为资源

  • 查看所有资源类型
[root@k8s-master ~]# kubectl api-resources
NAME                                SHORTNAMES   APIVERSION                        NAMESPACED   KIND
bindings                                         v1                                true         Binding
componentstatuses                   cs           v1                                false        ComponentStatus
configmaps                          cm           v1                                true         ConfigMap
endpoints                           ep           v1                                true         Endpoints
events                              ev           v1                                true         Event
limitranges                         limits       v1                                true         LimitRange
namespaces                          ns           v1                                false        Namespace
nodes                               no           v1                                false        Node
persistentvolumeclaims              pvc          v1                                true         PersistentVolumeClaim
persistentvolumes                   pv           v1                                false        PersistentVolume
pods                                po           v1                                true         Pod
podtemplates                                     v1                                true         PodTemplate
replicationcontrollers              rc           v1                                true         ReplicationController
resourcequotas                      quota        v1                                true         ResourceQuota
secrets                                          v1                                true         Secret
serviceaccounts                     sa           v1                                true         ServiceAccount
services                            svc          v1                                true         Service
mutatingwebhookconfigurations                    admissionregistration.k8s.io/v1   false        MutatingWebhookConfiguration
validatingadmissionpolicies                      admissionregistration.k8s.io/v1   false        ValidatingAdmissionPolicy
validatingadmissionpolicybindings                admissionregistration.k8s.io/v1   false        ValidatingAdmissionPolicyBinding
validatingwebhookconfigurations                  admissionregistration.k8s.io/v1   false        ValidatingWebhookConfiguration
customresourcedefinitions           crd,crds     apiextensions.k8s.io/v1           false        CustomResourceDefinition
apiservices                                      apiregistration.k8s.io/v1         false        APIService
controllerrevisions                              apps/v1                           true         ControllerRevision
daemonsets                          ds           apps/v1                           true         DaemonSet
deployments                         deploy       apps/v1                           true         Deployment
replicasets                         rs           apps/v1                           true         ReplicaSet
statefulsets                        sts          apps/v1                           true         StatefulSet
selfsubjectreviews                               authentication.k8s.io/v1          false        SelfSubjectReview
tokenreviews                                     authentication.k8s.io/v1          false        TokenReview
localsubjectaccessreviews                        authorization.k8s.io/v1           true         LocalSubjectAccessReview
selfsubjectaccessreviews                         authorization.k8s.io/v1           false        SelfSubjectAccessReview
selfsubjectrulesreviews                          authorization.k8s.io/v1           false        SelfSubjectRulesReview
subjectaccessreviews                             authorization.k8s.io/v1           false        SubjectAccessReview
horizontalpodautoscalers            hpa          autoscaling/v2                    true         HorizontalPodAutoscaler
cronjobs                            cj           batch/v1                          true         CronJob
jobs                                             batch/v1                          true         Job
certificatesigningrequests          csr          certificates.k8s.io/v1            false        CertificateSigningRequest
leases                                           coordination.k8s.io/v1            true         Lease
endpointslices                                   discovery.k8s.io/v1               true         EndpointSlice
events                              ev           events.k8s.io/v1                  true         Event
flowschemas                                      flowcontrol.apiserver.k8s.io/v1   false        FlowSchema
prioritylevelconfigurations                      flowcontrol.apiserver.k8s.io/v1   false        PriorityLevelConfiguration
ingressclasses                                   networking.k8s.io/v1              false        IngressClass
ingresses                           ing          networking.k8s.io/v1              true         Ingress
networkpolicies                     netpol       networking.k8s.io/v1              true         NetworkPolicy
runtimeclasses                                   node.k8s.io/v1                    false        RuntimeClass
poddisruptionbudgets                pdb          policy/v1                         true         PodDisruptionBudget
clusterrolebindings                              rbac.authorization.k8s.io/v1      false        ClusterRoleBinding
clusterroles                                     rbac.authorization.k8s.io/v1      false        ClusterRole
rolebindings                                     rbac.authorization.k8s.io/v1      true         RoleBinding
roles                                            rbac.authorization.k8s.io/v1      true         Role
priorityclasses                     pc           scheduling.k8s.io/v1              false        PriorityClass
csidrivers                                       storage.k8s.io/v1                 false        CSIDriver
csinodes                                         storage.k8s.io/v1                 false        CSINode
csistoragecapacities                             storage.k8s.io/v1                 true         CSIStorageCapacity
storageclasses                      sc           storage.k8s.io/v1                 false        StorageClass
volumeattachments                                storage.k8s.io/v1                 false        VolumeAttachment

1.2.4常用资源类型

资源分类资源名称缩写资源作用
集群级别资源nodesno集群组成部分
namespacesns隔离pod
pod资源podspo装载容器
pod资源控制器replicationcontrollersrc控制pod资源
replicasetsrs控制pod资源
deploymentsdeploy控制pod资源
daemonsetsds控制pod资源
jobs控制pod资源
cronjobscj控制pod资源
horizontalpodautoscalershpa控制pod资源
statefulsetssts控制pod资源
服务发现资源servicessvc统一pod对外接口
ingressing统一pod对外接口
存储资源volumeattachments存储
persistentvolumespv存储
persistentvolumeclaimspvc存储
配置资源configmapscm配置
secrets配置

基本命令示例

kubectl的详细说明地址:https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands

  • 显示集群版本
[root@k8s-master ~]# kubectl version
Client Version: v1.30.0
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.30.0
  • 显示集群信息
[root@k8s-master ~]# kubectl cluster-info
Kubernetes control plane is running at https://172.25.254.100:6443
CoreDNS is running at https://172.25.254.100:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
  • 创建一个名为webclusterdeployment控制器,控制器中pod数量为2
#先删除之前的pod
[root@k8s-master ~]# kubectl get pods -o wide
NAME         READY   STATUS    RESTARTS   AGE   IP           NODE            NOMINATE
webserver1   1/1     Running   0          16h   10.244.1.2   k8s-node1.org   <none>
webserver2   1/1     Running   0          16h   10.244.2.6   k8s-node2.org   <none>



[root@k8s-master ~]# kubectl delete pods webserver1 --force
[root@k8s-master ~]# kubectl delete pods webserver2 --force


[root@k8s-master ~]# kubectl get pods
No resources found in default namespace.
#创建一个名为`webcluster`的`deployment`控制器,控制器中`pod`数量为`2`
[root@k8s-master ~]# kubectl create deployment webcluster --image nginx --replicas 2
deployment.apps/webcluster created


[root@k8s-master ~]# kubectl get pods -o name
pod/webcluster-7c584f774b-9b67l
pod/webcluster-7c584f774b-d8xws


[root@k8s-master ~]# kubectl get pods -o wide
NAME                          READY   STATUS    RESTARTS   AGE   IP           NODE            NOMINATED NODE   READINESS GATES
webcluster-7c584f774b-9b67l   1/1     Running   0          79s   10.244.2.7   k8s-node2.org   <none>           <none>
webcluster-7c584f774b-d8xws   1/1     Running   0          79s   10.244.1.3   k8s-node1.org   <none>           <none>


#查看deployment控制器
[root@k8s-master ~]# kubectl get deployments.apps
NAME         READY   UP-TO-DATE   AVAILABLE   AGE
webcluster   2/2     2            2           50s
  • 查看资源帮助explain
#等级式查看
[root@k8s-master ~]# kubectl explain deployment
GROUP:      apps
KIND:       Deployment
VERSION:    v1

DESCRIPTION:
    Deployment enables declarative updates for Pods and ReplicaSets.

FIELDS:
  apiVersion    <string>
    APIVersion defines the versioned schema of this representation of an object.
    Servers should convert recognized schemas to the latest internal value, and
    may reject unrecognized values. More info:
    https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources

  kind  <string>
    Kind is a string value representing the REST resource this object
    represents. Servers may infer this from the endpoint the client submits
    requests to. Cannot be updated. In CamelCase. More info:
    https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds

  metadata      <ObjectMeta>
    Standard object's metadata. More info:
    https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata

  spec  <DeploymentSpec>
    Specification of the desired behavior of the Deployment.

  status        <DeploymentStatus>
    Most recently observed status of the Deployment.



[root@k8s-master ~]# kubectl explain deployment.metadata



[root@k8s-master ~]# kubectl explain deployment.spec
  • 编辑名为webclusterdeployment控制器,将pod数量改为3
#编辑名为webcluster的deployment控制器
[root@k8s-master ~]# kubectl edit deployments.apps webcluster
#会进入编辑状态
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"
  creationTimestamp: "2024-10-05T03:47:39Z"
  generation: 1
  labels:
    app: webcluster
  name: webcluster
  namespace: default
  resourceVersion: "27001"
  uid: a8bf27c5-c6bb-46d4-b4f7-4accfbb60e71
spec:
  progressDeadlineSeconds: 600
  replicas: 3     #将原来的2个pod改为3个pod
......
......
......
:wq
  • 发现改完立即生效
[root@k8s-master ~]# kubectl get deployments.apps webcluster
NAME         READY   UP-TO-DATE   AVAILABLE   AGE
webcluster   3/3     3            3           18m


[root@k8s-master ~]# kubectl get pods -o name
pod/webcluster-7c584f774b-9b67l
pod/webcluster-7c584f774b-d8xws
pod/webcluster-7c584f774b-r48fd


[root@k8s-master ~]# kubectl get pods -o wide
NAME                          READY   STATUS    RESTARTS   AGE    IP           NODE            NOMINATED NODE   READINESS GATES
webcluster-7c584f774b-9b67l   1/1     Running   0          20m    10.244.2.7   k8s-node2.org   <none>           <none>
webcluster-7c584f774b-d8xws   1/1     Running   0          20m    10.244.1.3   k8s-node1.org   <none>           <none>
webcluster-7c584f774b-r48fd   1/1     Running   0          114s   10.244.2.8   k8s-node2.org   <none>           <none>
  • 利用补丁 patch更改控制器配置(编辑名为webclusterdeployment控制器,将pod数量改为4
[root@k8s-master ~]# kubectl patch deployments.apps webcluster -p '{"spec":{"replicas":4}}'
deployment.apps/webcluster patched


[root@k8s-master ~]# kubectl get deployments.apps
NAME         READY   UP-TO-DATE   AVAILABLE   AGE
webcluster   4/4     4            4           26m


[root@k8s-master ~]# kubectl get pods -o name
pod/webcluster-7c584f774b-9b67l
pod/webcluster-7c584f774b-d8xws
pod/webcluster-7c584f774b-r48fd
pod/webcluster-7c584f774b-swst6


[root@k8s-master ~]# kubectl get pods -o wide
NAME                          READY   STATUS    RESTARTS   AGE    IP           NODE            NOMINATED NODE   READINESS GATES
webcluster-7c584f774b-9b67l   1/1     Running   0          27m    10.244.2.7   k8s-node2.org   <none>           <none>
webcluster-7c584f774b-d8xws   1/1     Running   0          27m    10.244.1.3   k8s-node1.org   <none>           <none>
webcluster-7c584f774b-r48fd   1/1     Running   0          9m7s   10.244.2.8   k8s-node2.org   <none>           <none>
webcluster-7c584f774b-swst6   1/1     Running   0          92s    10.244.1.4   k8s-node1.org   <none>           <none>
  • 控制器中删除pod

控制器删除一个pod后,k8s会根据数量再开一个pod

[root@k8s-master ~]# kubectl get pods -o wide
NAME                          READY   STATUS    RESTARTS   AGE    IP           NODE            NOMINATED NODE   READINESS GATES
webcluster-7c584f774b-9b67l   1/1     Running   0          27m    10.244.2.7   k8s-node2.org   <none>           <none>
webcluster-7c584f774b-d8xws   1/1     Running   0          27m    10.244.1.3   k8s-node1.org   <none>           <none>
webcluster-7c584f774b-r48fd   1/1     Running   0          9m7s   10.244.2.8   k8s-node2.org   <none>           <none>
webcluster-7c584f774b-swst6   1/1     Running   0          92s    10.244.1.4   k8s-node1.org   <none>           <none>
[root@k8s-master ~]# kubectl delete pods webcluster-7c584f774b-9b67l
pod "webcluster-7c584f774b-9b67l" deleted
[root@k8s-master ~]# kubectl get pods -o wide
NAME                          READY   STATUS    RESTARTS   AGE     IP           NODE            NOMINATED NODE   READINESS GATES
webcluster-7c584f774b-d8xws   1/1     Running   0          31m     10.244.1.3   k8s-node1.org   <none>           <none>
webcluster-7c584f774b-r48fd   1/1     Running   0          13m     10.244.2.8   k8s-node2.org   <none>           <none>
webcluster-7c584f774b-swst6   1/1     Running   0          5m25s   10.244.1.4   k8s-node1.org   <none>           <none>
webcluster-7c584f774b-tx55p   1/1     Running   0          5s      10.244.2.9   k8s-node2.org   <none>           <none>
  • 直接删除控制器控制器控制的所有pod都会被删除
[root@k8s-master ~]# kubectl delete deployments.apps webcluster
deployment.apps "webcluster" deleted

[root@k8s-master ~]# kubectl get deployments.apps
No resources found in default namespace.

[root@k8s-master ~]# kubectl get pods -o wide
No resources found in default namespace.

运行和调试命令示例

  • 首先要保证一个纯净的实验环境
#发现没有pod
[root@k8s-master ~]# kubectl get pods
No resources found in default namespace.
  • 运行一个名为testpodpod,该pod不属于任何控制器
[root@k8s-master ~]# kubectl run testpod --image nginx
pod/testpod created


[root@k8s-master ~]# kubectl get pods -o name
pod/testpod


[root@k8s-master ~]# kubectl get pods -o wide
NAME      READY   STATUS    RESTARTS   AGE   IP            NODE            NOMINATED NODE   READINESS GATES
testpod   1/1     Running   0          9s    10.244.2.10   k8s-node2.org   <none>           <none>
  • 端口暴露
[root@k8s-master ~]# kubectl get services
NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
kubernetes   ClusterIP   10.96.0.1       <none>        443/TCP    18h


#--port指定pod中的端口,--target-port指定容器中的服务端口
[root@k8s-master ~]# kubectl expose pod testpod --port 8080 --target-port 80
service/testpod exposed


[root@k8s-master ~]# kubectl get services
NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
kubernetes   ClusterIP   10.96.0.1       <none>        443/TCP    18h
testpod      ClusterIP   10.99.119.189   <none>        8080/TCP   8s
#访问10.244.2.12
[root@k8s-master ~]# curl 10.244.2.12
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>


#访问10.99.119.189:8080
[root@k8s-master ~]# curl 10.99.119.189:8080
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
  • 查看运行中pod详细信息
[root@k8s-master ~]# kubectl get pods -o wide
NAME      READY   STATUS    RESTARTS   AGE   IP            NODE            NOMINATED NODE   READINESS GATES
testpod   1/1     Running   0          10m   10.244.2.12   k8s-node2.org   <none>           <none>


[root@k8s-master ~]# kubectl describe pods testpod
Name:             testpod
Namespace:        default
Priority:         0
Service Account:  default
Node:             k8s-node2.org/172.25.254.20
Start Time:       Sat, 05 Oct 2024 00:45:53 -0400
Labels:           run=testpod
Annotations:      <none>
Status:           Running
IP:               10.244.2.12
IPs:
  IP:  10.244.2.12
Containers:
  testpod:
    Container ID:   docker://13361a3a29b394fa0049c28405a76a686a26a7c9a1e1fddbcdc4312f2698156a
    Image:          nginx
    Image ID:       docker-pullable://nginx@sha256:127262f8c4c716652d0e7863bba3b8c45bc9214a57d13786c854272102f7c945
    Port:           <none>
    Host Port:      <none>
    State:          Running
      Started:      Sat, 05 Oct 2024 00:45:54 -0400
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-tzfw6 (ro)
Conditions:
  Type                        Status
  PodReadyToStartContainers   True
  Initialized                 True
  Ready                       True
  ContainersReady             True
  PodScheduled                True
Volumes:
  kube-api-access-tzfw6:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  10m   default-scheduler  Successfully assigned default/testpod to k8s-node2.org
  Normal  Pulling    10m   kubelet            Pulling image "nginx"
  Normal  Pulled     10m   kubelet            Successfully pulled image "nginx" in 281ms (281ms including waiting). Image size: 187694648 bytes.
  Normal  Created    10m   kubelet            Created container testpod
  Normal  Started    10m   kubelet            Started container testpod
  • 查看资源日志
[root@k8s-master ~]# kubectl logs
daemonsets/              pods/                    services/
deployments/             replicasets/             statefulsets/
jobs/                    replicationcontrollers/  testpod
[root@k8s-master ~]# kubectl logs pods/testpod
......
......
......
  • 运行交互pod
[root@k8s-master ~]# kubectl run -it testpod1 --image busybox
If you don't see a command prompt, try pressing enter.
/ #
/ #
/ # ls
bin    dev    etc    home   lib    lib64  proc   root   sys    tmp    usr    var
/ # exit      #退出交互式,不停止pod


[root@k8s-master ~]# kubectl get pods -o wide
NAME       READY   STATUS    RESTARTS      AGE   IP            NODE            NOMINATED NODE   READINESS GATES
testpod    1/1     Running   0             20m   10.244.2.12   k8s-node2.org   <none>           <none>
testpod1   1/1     Running   1 (24s ago)   36s   10.244.1.6    k8s-node1.org   <none>           <none>


#再次进入容器
[root@k8s-master ~]# kubectl attach -it  pods/testpod1
If you don't see a command prompt, try pressing enter.
/ #
/ #
/ # ls
bin    dev    etc    home   lib    lib64  proc   root   sys    tmp    usr    var
/ # exit 或  ctrl+p+q退出不停止pod


[root@k8s-master ~]# kubectl get pods -o wide
NAME       READY   STATUS    RESTARTS       AGE     IP            NODE            NOMINATED NODE   READINESS GATES
testpod    1/1     Running   0              24m     10.244.2.12   k8s-node2.org   <none>           <none>
testpod1   1/1     Running   2 (3m9s ago)   4m30s   10.244.1.6    k8s-node1.org   <none>           <none>
  • 在已经运行的pod中运行容器中的指定命令
[root@k8s-master ~]# kubectl exec -it pods/testpod1 ifconfig
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
eth0      Link encap:Ethernet  HWaddr 12:C1:23:80:08:BA
          inet addr:10.244.1.6  Bcast:10.244.1.255  Mask:255.255.255.0
          inet6 addr: fe80::10c1:23ff:fe80:8ba/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1450  Metric:1
          RX packets:15 errors:0 dropped:0 overruns:0 frame:0
          TX packets:13 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2148 (2.0 KiB)  TX bytes:962 (962.0 B)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
  • 复制master宿主机文件到pod中的容器中
[root@k8s-master ~]# kubectl cp anaconda-ks.cfg   testpod1:/


[root@k8s-master ~]# kubectl  exec  -it  pods/testpod1  /bin/sh
/ # ls
anaconda-ks.cfg  home             root             var
bin              lib              sys
dev              lib64            tmp
etc              proc             usr
/ # touch file1
/ # ls
anaconda-ks.cfg  file1            proc             usr
bin              home             root             var
dev              lib              sys
etc              lib64            tmp
/ # echo hello world > file1
/ # cat file1
hello world111
  • 复制pod容器中的文件master宿主机中
[root@k8s-master ~]# kubectl cp  testpod1:/file1   /mnt/file
tar: removing leading '/' from member names
[root@k8s-master ~]# cd /mnt/
[root@k8s-master mnt]# ls
file
[root@k8s-master mnt]# cat file
hello world111

高级命令示例

  • 利用命令生成yaml格式文件
[root@k8s-master ~]# mkdir huazi
[root@k8s-master ~]# cd huazi/
[root@k8s-master huazi]#

首先要确保一个纯净的实验环境

[root@k8s-master huazi]# kubectl get pods
NAME       READY   STATUS    RESTARTS      AGE
testpod    1/1     Running   0             43m
testpod1   1/1     Running   2 (22m ago)   23m


[root@k8s-master huazi]# kubectl delete pods testpod
pod "testpod" deleted
[root@k8s-master huazi]# kubectl delete pods testpod1 --force
pod "testpod1" deleted
  • --drg-run=client仅尝试不运行,是一个固定写法
#仅尝试,不运行
[root@k8s-master huazi]# kubectl create deployment webserver --image nginx --dry-run=client -o yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: webserver
  name: webserver
spec:
  replicas: 1
  selector:
    matchLabels:
      app: webserver
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: webserver
    spec:
      containers:
      - image: nginx
        name: nginx
        resources: {}
status: {}
  • 导入文件
#创建一个控制器文件
[root@k8s-master huazi]# kubectl create deployment webserver --image nginx --dry-run=client -o yaml > webserver.yml
[root@k8s-master huazi]# ls
webserver.yml
#对文件进行简单的修改
[root@k8s-master huazi]# vim  webserver.yml
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: webserver
  name: webserver
spec:
  replicas: 2    #修改为2个pod
  selector:
    matchLabels:
      app: webserver
  template:
    metadata:
      labels:
        app: webserver
    spec:
      containers:
      - image: nginx
        name: nginx
  • 应用文件
#这个文件是一个控制器文件
[root@k8s-master huazi]# kubectl apply -f webserver.yml
deployment.apps/webserver created


[root@k8s-master huazi]# kubectl get deployments.apps
NAME        READY   UP-TO-DATE   AVAILABLE   AGE
webserver   2/2     2            2           27s


[root@k8s-master huazi]# kubectl get pods -o name
pod/webserver-7bc769cd4c-mg9kl
pod/webserver-7bc769cd4c-nl7q2


[root@k8s-master huazi]# kubectl get pods -o wide
NAME                         READY   STATUS    RESTARTS   AGE     IP            NODE            NOMINATED NODE   READINESS GATES
webserver-7bc769cd4c-mg9kl   1/1     Running   0          2m10s   10.244.2.13   k8s-node2.org   <none>           <none>
webserver-7bc769cd4c-nl7q2   1/1     Running   0          2m10s   10.244.1.7    k8s-node1.org   <none>           <none>
  • 删除控制器文件
[root@k8s-master huazi]# kubectl delete -f webserver.yml
deployment.apps "webserver" deleted


[root@k8s-master huazi]# kubectl get deployments.apps
No resources found in default namespace.


[root@k8s-master huazi]# kubectl get pods -o wide
No resources found in default namespace.
  • 管理资源标签
#这个是没有控制的pod
[root@k8s-master huazi]# kubectl run webserver --image nginx
pod/webserver created


[root@k8s-master huazi]# kubectl get pods -o wide
NAME        READY   STATUS    RESTARTS   AGE   IP            NODE            NOMINATED NODE   READINESS GATES
webserver   1/1     Running   0          12s   10.244.2.15   k8s-node2.org   <none>           <none>


[root@k8s-master huazi]# kubectl get pods --show-labels
NAME        READY   STATUS    RESTARTS   AGE   LABELS
webserver   1/1     Running   0          50s   run=webserver
  • 更改标签
  • --overwrite覆盖
[root@k8s-master huazi]# kubectl label pods webserver run=web --overwrite
pod/webserver labeled


[root@k8s-master huazi]# kubectl get pods --show-labels
NAME        READY   STATUS    RESTARTS   AGE     LABELS
webserver   1/1     Running   0          3m48s   run=web
  • 添加标签
  • 通过键值对添加即可
[root@k8s-master huazi]# kubectl label pods webserver app=web1
pod/webserver labeled


[root@k8s-master huazi]# kubectl get pods --show-labels
NAME        READY   STATUS    RESTARTS   AGE     LABELS
webserver   1/1     Running   0          5m33s   app=web1,run=web
  • 删除标签
[root@k8s-master huazi]# kubectl label pods webserver app-
pod/webserver unlabeled


[root@k8s-master huazi]# kubectl get pods --show-labels
NAME        READY   STATUS    RESTARTS   AGE     LABELS
webserver   1/1     Running   0          6m48s   run=web
  • 创建一个控制器pod
#先删除之前的pod
[root@k8s-master huazi]# kubectl delete pods webserver
pod "webserver" deleted
[root@k8s-master huazi]# kubectl get pods
No resources found in default namespace.
[root@k8s-master huazi]# kubectl create deployment webserver --image nginx --dry-run=client -o yaml > web-label.yaml
[root@k8s-master huazi]# ls
web-label.yaml  webserver.yml

[root@k8s-master huazi]# vim web-label.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: webserver
  name: webserver
spec:
  replicas: 2   #修改为2个pod
  selector:
    matchLabels:
      app: webserver
  template:
    metadata:
      labels:
        app: webserver
    spec:
      containers:
      - image: nginx
        name: nginx
[root@k8s-master huazi]# kubectl apply -f web-label.yaml
deployment.apps/webserver created


[root@k8s-master huazi]# kubectl get deployments.apps
NAME        READY   UP-TO-DATE   AVAILABLE   AGE
webserver   2/2     2            2           7s


[root@k8s-master huazi]# kubectl get pods --show-labels
NAME                         READY   STATUS    RESTARTS   AGE   LABELS
webserver-7bc769cd4c-bnklx   1/1     Running   0          44s   app=webserver,pod-template-hash=7bc769cd4c
webserver-7bc769cd4c-cdj8f   1/1     Running   0          44s   app=webserver,pod-template-hash=7bc769cd4c

修改一个控制器pod上的一个标签

[root@k8s-master huazi]# kubectl get pods --show-labels
NAME                         READY   STATUS    RESTARTS   AGE   LABELS
webserver-7bc769cd4c-bnklx   1/1     Running   0          44s   app=webserver,pod-tem                                                                                                       plate-hash=7bc769cd4c
webserver-7bc769cd4c-cdj8f   1/1     Running   0          44s   app=webserver,pod-tem                                                                                                       plate-hash=7bc769cd4c


[root@k8s-master huazi]# kubectl label pods webserver-7bc769cd4c-bnklx app=lee --over                                                                                                       write
pod/webserver-7bc769cd4c-bnklx labeled
[root@k8s-master huazi]# kubectl get pods --show-labels                                                                                                                                     NAME                         READY   STATUS    RESTARTS   AGE     LABELS
webserver-7bc769cd4c-bnklx   1/1     Running   0          3m14s   app=lee,pod-templat                                                                                                       e-hash=7bc769cd4c
webserver-7bc769cd4c-cdj8f   1/1     Running   0          3m14s   app=webserver,pod-t                                                                                                       emplate-hash=7bc769cd4c
webserver-7bc769cd4c-cgzcq   1/1     Running   0          3s      app=webserver,pod-t                                                                                                       emplate-hash=7bc769cd4c

我们发现k8s又起了一个新的pod

当我们删除另一个标签后,k8s又起了一个新的pod

[root@k8s-master huazi]# kubectl label pods webserver-7bc769cd4c-cdj8f pod-template-hash-
pod/webserver-7bc769cd4c-cdj8f unlabeled
[root@k8s-master huazi]# kubectl get pods --show-labels
NAME                         READY   STATUS    RESTARTS   AGE     LABELS
webserver-7bc769cd4c-bnklx   1/1     Running   0          5m22s   app=lee,pod-template-hash=7bc769cd4c
webserver-7bc769cd4c-cdj8f   1/1     Running   0          5m22s   app=webserver
webserver-7bc769cd4c-cgzcq   1/1     Running   0          2m11s   app=webserver,pod-template-hash=7bc769cd4c
webserver-7bc769cd4c-zq5mw   1/1     Running   0          5s      app=webserver,pod-template-hash=7bc769cd4c

当我们修改回来原来的标签后,k8s又把之前新的pod删除

[root@k8s-master huazi]# kubectl label pods webserver-7bc769cd4c-bnklx app=webserver --overwrite
pod/webserver-7bc769cd4c-bnklx labeled
[root@k8s-master huazi]# kubectl get pods --show-labels
NAME                         READY   STATUS    RESTARTS   AGE     LABELS
webserver-7bc769cd4c-cdj8f   1/1     Running   0          8m45s   app=webserver
webserver-7bc769cd4c-cgzcq   1/1     Running   0          5m34s   app=webserver,pod-template-hash=7bc769cd4c
webserver-7bc769cd4c-zq5mw   1/1     Running   0          3m28s   app=webserver,pod-template-hash=7bc769cd4c

总结

所以我们发现,k8s是通过标签去记录pod的数量,如果有多个标签,且多个标签必须一致。如果不一致,则k8s会根据pod的数量重新启动相应pod

其他命令示例

[root@k8s-master huazi]# kubectl cluster-info
Kubernetes control plane is running at https://172.25.254.100:6443
CoreDNS is running at https://172.25.254.100:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
[root@k8s-master huazi]# kubectl version
Client Version: v1.30.0
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.30.0

createapply区别案例

[root@k8s-master huazi]# kubectl run testpod1 --image myapp:v1 --dry-run=client -o yaml > testpod1.yml

[root@k8s-master huazi]# ls
testpod1.yml

[root@k8s-master huazi]# vim testpod1.yml
apiVersion: v1
kind: Pod
metadata:
  labels:
    run: testpod1
  name: testpod1
spec:
  containers:
  - image: myapp:v1
    name: testpod1



[root@k8s-master huazi]# kubectl create -f testpod1.yml
pod/testpod1 created
[root@k8s-master huazi]# kubectl get pods -o wide
NAME       READY   STATUS    RESTARTS   AGE   IP            NODE            NOMINATED NODE   READINESS GATES
testpod1   1/1     Running   0          8s    10.244.1.10   k8s-node1.org   <none>           <none>

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

[root@k8s-master huazi]# vim testpod1.yml
apiVersion: v1
kind: Pod
metadata:
  labels:
    run: testpod1
  name: testpod1
spec:
  containers:
  - image: myapp:v2   #将版本改为v2
    name: testpod1


#发现使用create更新不了
[root@k8s-master huazi]# kubectl create -f testpod1.yml
Error from server (AlreadyExists): error when creating "testpod1.yml": pods "testpod1" already exists


#使用apply可以更新
[root@k8s-master huazi]# kubectl apply -f testpod1.yml

[root@k8s-master huazi]# kubectl get pods -o wide
NAME       READY   STATUS    RESTARTS      AGE     IP            NODE            NOMINATED NODE   READINESS GATES
testpod1   1/1     Running   1 (23s ago)   3m13s   10.244.1.10   k8s-node1.org   <none>           <none>


[root@k8s-master huazi]# curl 10.244.1.10
Hello MyApp | Version: v2 | <a href="hostname.html">Pod Name</a>
  • 所以create只能建立,不能更新apply可以更新

显示命名空间

[root@k8s-master huazi]# kubectl -n
default          kube-node-lease  kube-system
kube-flannel     kube-public

查看命名空间中的pod

  • 查看所有命名空间中的pod
  • --all-namespaces
[root@k8s-master huazi]# kubectl get pods --all-namespaces
NAMESPACE      NAME                                     READY   STATUS    RESTARTS        AGE
default        testpod1                                 1/1     Running   1 (4m54s ago)   7m44s
kube-flannel   kube-flannel-ds-m7ksl                    1/1     Running   0               22h
kube-flannel   kube-flannel-ds-q55gr                    1/1     Running   0               22h
kube-flannel   kube-flannel-ds-twvv4                    1/1     Running   1 (21h ago)     22h
kube-system    coredns-6c7f6478d8-gplcq                 1/1     Running   0               23h
kube-system    coredns-6c7f6478d8-vcqg9                 1/1     Running   0               23h
kube-system    etcd-k8s-master.org                      1/1     Running   0               23h
kube-system    kube-apiserver-k8s-master.org            1/1     Running   0               23h
kube-system    kube-controller-manager-k8s-master.org   1/1     Running   0               23h
kube-system    kube-proxy-2dbz2                         1/1     Running   1 (21h ago)     22h
kube-system    kube-proxy-fcnpc                         1/1     Running   0               23h
kube-system    kube-proxy-jwn8w                         1/1     Running   0               22h
kube-system    kube-scheduler-k8s-master.org            1/1     Running   0               23h
  • 查看默认命名空间中的pod
[root@k8s-master huazi]# kubectl get pods
NAME       READY   STATUS    RESTARTS       AGE
testpod1   1/1     Running   1 (7m4s ago)   9m54s
[root@k8s-master huazi]# kubectl -n
default          kube-node-lease  kube-system
kube-flannel     kube-public
[root@k8s-master huazi]# kubectl -n default get pods
NAME       READY   STATUS    RESTARTS        AGE
testpod1   1/1     Running   1 (7m58s ago)   10m

如何对外暴露端口

[root@k8s-master huazi]# kubectl run web --image myapp:v1
pod/web created

[root@k8s-master huazi]# kubectl get pods -o wide
NAME   READY   STATUS    RESTARTS   AGE   IP            NODE            NOMINATED NODE   READINESS GATES
web    1/1     Running   0          32s   10.244.1.11   k8s-node1.org   <none>           <none>
#10.244.1.11是pod的ip地址


[root@k8s-master huazi]# curl 10.244.1.11
Hello MyApp | Version: v1 | <a href="hostname.html">Pod Name</a>
[root@k8s-master huazi]# kubectl expose pod web --port 8080 --target-port 80
service/web exposed
#--port指定pod中的端口,
#--target-port指定容器中的服务端口

[root@k8s-master huazi]# kubectl get services
NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
kubernetes   ClusterIP   10.96.0.1       <none>        443/TCP    23h
web          ClusterIP   10.108.123.93   <none>        8080/TCP   19s
#10.108.123.93这个ip是service的ip地址
#当访问10.108.123.93:8080端口时,转到10.244.1.11的80端口

[root@k8s-master huazi]# curl 10.108.123.93:8080
Hello MyApp | Version: v1 | <a href="hostname.html">Pod Name</a>
[root@k8s-master huazi]# kubectl edit services web
apiVersion: v1
kind: Service
metadata:
  creationTimestamp: "2024-10-05T09:21:02Z"
  labels:
    run: web
  name: web
  namespace: default
  resourceVersion: "57432"
  uid: 33ea0201-e8b2-42ea-874d-2aa2b8e20455
spec:
  clusterIP: 10.108.123.93
  clusterIPs:
  - 10.108.123.93
  internalTrafficPolicy: Cluster
  ipFamilies:
  - IPv4
  ipFamilyPolicy: SingleStack
  ports:
  - port: 8080
    protocol: TCP
    targetPort: 80
  selector:
    run: web
  sessionAffinity: None
  type: NodePort   #修改类型为NodePort
status:
  loadBalancer: {}


[root@k8s-master huazi]# kubectl get services
NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
kubernetes   ClusterIP   10.96.0.1       <none>        443/TCP          23h
web          NodePort    10.108.123.93   <none>        8080:31340/TCP   9m51s


[root@k8s-master huazi]# kubectl get pods -o wide
NAME   READY   STATUS    RESTARTS   AGE   IP            NODE            NOMINATED NODE   READINESS GATES
web    1/1     Running   0          14m   10.244.1.11   k8s-node1.org   <none>           <none>


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


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

在这里插入图片描述
发现可以对外访问

[root@k8s-master huazi]# kubectl explain service.spec
......
......
......
    Possible enum values:
     - `"ClusterIP"` means a service will only be accessible inside the cluster,
    via the cluster IP.
     - `"ExternalName"` means a service consists of only a reference to an
    external name that kubedns or equivalent will return as a CNAME record, with
    no exposing or proxying of any pods involved.
     - `"LoadBalancer"` means a service will be exposed via an external load
    balancer (if the cloud provider supports it), in addition to 'NodePort'
    type.
     - `"NodePort"` means a service will be exposed on one port of every node,
    in addition to 'ClusterIP' type.

查看某一个pod的详细信息

[root@k8s-master huazi]# kubectl get pods
NAME   READY   STATUS    RESTARTS   AGE
web    1/1     Running   0          20m
[root@k8s-master huazi]# kubectl describe pods web
Name:             web
Namespace:        default
Priority:         0
Service Account:  default
Node:             k8s-node1.org/172.25.254.10
Start Time:       Sat, 05 Oct 2024 05:17:53 -0400
Labels:           run=web
Annotations:      <none>
Status:           Running
IP:               10.244.1.11
IPs:
  IP:  10.244.1.11
Containers:
  web:
    Container ID:   docker://d1f4ea79ffe996f292f2b0af787afdf7e235496b4b4a89878005a3fed662426f
    Image:          myapp:v1
    Image ID:       docker-pullable://myapp@sha256:9eeca44ba2d410e54fccc54cbe9c021802aa8b9836a0bcf3d3229354e4c8870e
    Port:           <none>
    Host Port:      <none>
    State:          Running
      Started:      Sat, 05 Oct 2024 05:17:54 -0400
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-mv6b4 (ro)
Conditions:
  Type                        Status
  PodReadyToStartContainers   True
  Initialized                 True
  Ready                       True
  ContainersReady             True
  PodScheduled                True
Volumes:
  kube-api-access-mv6b4:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  20m   default-scheduler  Successfully assigned default/web to k8s-node1.org
  Normal  Pulled     20m   kubelet            Container image "myapp:v1" already present on machine
  Normal  Created    20m   kubelet            Created container web
  Normal  Started    20m   kubelet            Started container web

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

数据库伸缩设计-分库分表如何做?读书笔记

一些企业内部系统&#xff0c;用户数量和业务规模有限&#xff0c;因此并不会产生巨大的数据量&#xff0c;这时数据库的存储和读写性能均不会成为瓶颈&#xff0c;没有扩容的需要&#xff0c;因此无须考虑伸缩性。对于一些互联网系统&#xff0c;前后端应用可以通过CDN 、缓存…

基于Zynq SDIO WiFi移植二(支持2.4/5G)

1 SDIO设备识别 经过编译&#xff0c;将移植好的uboot、kernel、rootFS、ramdisk等烧录到Flash中&#xff0c;上电启动&#xff0c;在log中&#xff0c;可看到sdio设备 [ 1.747059] mmc1: queuing unknown CIS tuple 0x01 (3 bytes) [ 1.761842] mmc1: queuing unknown…

vite学习教程06、vite.config.js配置

前言 博主介绍&#xff1a;✌目前全网粉丝3W&#xff0c;csdn博客专家、Java领域优质创作者&#xff0c;博客之星、阿里云平台优质作者、专注于Java后端技术领域。 涵盖技术内容&#xff1a;Java后端、大数据、算法、分布式微服务、中间件、前端、运维等。 博主所有博客文件…

Meta MovieGen AI:颠覆性的文本生成视频技术详解

近年来&#xff0c;生成式AI技术的发展迅猛&#xff0c;尤其是在文本生成图像、文本生成视频等领域。Meta公司近期推出的MovieGen AI&#xff0c;以其强大的文本生成视频能力震撼了整个AI行业。本文将详细解读Meta MovieGen AI的核心技术、功能特性及其在实际应用中的潜力。 一…

ssrf学习(ctfhub靶场)

ssrf练习 目录 ssrf类型 漏洞形成原理&#xff08;来自网络&#xff09; 靶场题目 第一题&#xff08;url探测网站下文件&#xff09; 第二关&#xff08;使用伪协议&#xff09; 关于http和file协议的理解 file协议 http协议 第三关&#xff08;端口扫描&#xff09…

Linux自动化构建工具Make/Makefile

make是一个命令 makefile是一个文件 touch 创建并用vim打开makefile 写入依赖对象和依赖方法 mycode是目标文件 第二行数依赖方法 以tab键开头 make makefile原理 makefile中写的是依赖关系和依赖方法 clean英语清理文件 后不用加源文件。.PHONY定义clean是伪目标。 make只…

各省份-产业链现代化水平(2001-2022年)

产业链现代化水平是一个综合性指标&#xff0c;它为我们提供了一个多维度的视角来评估各省份在产业链现代化进程中的发展水平。这个指标涵盖了技术创新、产业升级、生产效率、产业结构优化等多个方面&#xff0c;包含原始数据、测算结果以及参考文献。 2001年-2022年各省份-产…

Debezium日常分享系列之:Debezium 3.0.0.Final发布

Debezium日常分享系列之&#xff1a;Debezium 3.0.0.Final发布 Debezium 核心的变化需要 Java 17基于Kafka 3.8 构建废弃的增量信号字段的删除每个表的详细指标 MariaDB连接器的更改版本 11.4.3 支持 MongoDB连接器的更改MongoDB sink connector MySQL连接器的改变MySQL 9MySQL…

vscode 连接云服务器(ubantu 20.04)

更改服务器系统 如果云服务器上的系统不是ubantu20.04的&#xff0c;可以进行更改&#xff1a; 登录云服务官网&#xff08;这里以阿里云为例&#xff09;点击控制台 点击服务器实例 点击更多操作、重置系统 点击重置为其他镜像、系统镜像&#xff1a;选择你要使用的系统镜像…

[Linux]:线程(三)

✨✨ 欢迎大家来到贝蒂大讲堂✨✨ &#x1f388;&#x1f388;养成好习惯&#xff0c;先赞后看哦~&#x1f388;&#x1f388; 所属专栏&#xff1a;Linux学习 贝蒂的主页&#xff1a;Betty’s blog 1. POSIX 信号量 1.1 信号量的概念 为了解决多执行流访问临界区&#xff0c…

Java中的break、continue和return语句

break、continue和return break语句引入基本介绍基本语法示意图注意事项练习String字符串的比较 continue跳转控制语句基本介绍基本语法示意图 return跳转控制语句 break语句 引入 随机生成1-100的一个数&#xff0c;直到生成了97这个数&#xff0c;看看你一共用了几次&#…

前端性能优化 面试如何完美回答

前言 性能优化是目前在面试中被问到非常多的问题&#xff0c;主要就是通过各种算和技术来提高页和应用的速度和用户体前端性能优化的问题并不好回答 在回答的时候干万不要掉进一个误区&#xff0c;认为性能优化只是几个技术点而已&#xff0c;事实上性能优化涉及到的是多方面的…

【2024年10月测试通过】conda下使用虚拟环境安装最新版pytorch2.4+cuda12.4

开头先说重点&#xff1a; 1.采用conda的虚拟环境&#xff0c;会在沙盒环境下安装好所有所需包&#xff0c;而且该虚拟环境拷贝给其他人员可以直接用&#xff0c;很方便。 2.pytorch官网访问不了&#xff0c;有一个国内镜像推荐&#xff0c;地址为PyTorch - PyTorch 中文 3.…

unity ps 2d animation 蛇的制作

一、PS的使用 1.打开PS 利用钢笔工具从下往上勾勒填充 2.复制图层&#xff0c;Ctrl T,w调为-100% 3.对齐图层并继续用钢笔工具进行三角勾勒 3.画眼睛,按U快捷键打开椭圆工具&#xff0c;按住Shift可以画圆&#xff0c;填充并复制图层对称。 4.画笔工具&#xff0c;打开小…

Golang | Leetcode Golang题解之第458题可怜的小猪

题目&#xff1a; 题解&#xff1a; func poorPigs(buckets, minutesToDie, minutesToTest int) int {if buckets 1 {return 0}combinations : make([][]int, buckets1)for i : range combinations {combinations[i] make([]int, buckets1)}combinations[0][0] 1iterations…

「漏洞复现」用友U8 CRM config/fillbacksettingedit.php SQL注入漏洞

0x01 免责声明 请勿利用文章内的相关技术从事非法测试&#xff0c;由于传播、利用此文所提供的信息而造成的任何直接或者间接的后果及损失&#xff0c;均由使用者本人负责&#xff0c;作者不为此承担任何责任。工具来自网络&#xff0c;安全性自测&#xff0c;如有侵权请联系删…

蓝牙定位的MATLAB仿真程序(基于信号强度,平面内的定位,四个蓝牙基站)

这段代码通过RSSI信号强度实现了蓝牙定位,展示了如何使用锚点位置和测量的信号强度来估计未知点的位置。它涵盖了信号衰减模型、距离计算和最小二乘法估计等基本概念。通过图形化输出,用户可以直观地看到真实位置与估计位置的关系。 文章目录 蓝牙定位原理蓝牙定位的原理优缺…

【综合性渗透利器】- TscanPlus

如果你在寻找一款轻量级、实用且开源的漏洞扫描工具&#xff0c;那么 TscanPlus 绝对值得一试。这款工具由 TideSec 团队打造&#xff0c;以其简洁、高效、易用的特点&#xff0c;广受好评&#xff0c;目前在github上拥有1.5k star。 为什么推荐 TscanPlus&#xff1f; 无论你…

基于Zynq SDIO WiFi移植一(支持2.4/5G)

基于SDIO接口的WIFI&#xff0c;在应用上&#xff0c;功耗低于USB接口&#xff0c;且无须USB Device支持&#xff0c;满足某些应用场景 1 硬件连接 2 Vivado工程配置 3 驱动编译 3.1 KERNRL CONFIG (build ENV) 修改 export KERNELPATH<path of kernel header>export T…

【web安全】——SSRF服务器端请求伪造

1.SSRF漏洞基础 1.1SSRF漏洞概述与成因 SSRF(Server-Side Request Forgery:服务器端请求伪造) 是一种由攻击者构造形成由服务端发起请求的一个安全漏洞。 一般情况下&#xff0c;SSRF攻击的目标是从外网无法访问的内部系统。&#xff08;正是因为它是由服务端发起的&#xf…