K8S - ConfigMap的简介和使用

news2024/9/23 19:24:52

在这里插入图片描述

什么是configMap

Kubernetes中的ConfigMap 是用于存储非敏感数据的API对象,用于将配置数据与应用程序的镜像分离。ConfigMap可以包含键值对、文件或者环境变量等配置信息,应用程序可以通过挂载ConfigMap来访问其中的数据,从而实现应用配置的动态管理。ConfigMap的使用有助于提高应用程序的可移植性、可伸缩性和可维护性。

简单来讲, configmap 是用来存储app的配置或者容器的环境变量的, 避免这些配置hard code 在容器内。
但是configMap 并不适合存放敏感数据(例如帐号密码) , 敏感数据应该存放在secret manager中。






configMap的创建

1. by kubectl command line

我们可以用 kubectl create configMap -h 查看官方的一些示例

Aliases:
configmap, cm

Examples:
  # Create a new config map named my-config based on folder bar
  kubectl create configmap my-config --from-file=path/to/bar
  
  # Create a new config map named my-config with specified keys instead of file basenames on disk
  kubectl create configmap my-config --from-file=key1=/path/to/bar/file1.txt --from-file=key2=/path/to/bar/file2.txt
  
  # Create a new config map named my-config with key1=config1 and key2=config2
  kubectl create configmap my-config --from-literal=key1=config1 --from-literal=key2=config2
  
  # Create a new config map named my-config from the key=value pairs in the file
  kubectl create configmap my-config --from-file=path/to/bar
  
  # Create a new config map named my-config from an env file
  kubectl create configmap my-config --from-env-file=path/to/foo.env --from-env-file=path/to/bar.env

可见, 用命令行创建configMap的都必须提供一个or 若干文件,甚至可以是文件夹, 而且真正的内容都要写在文件中的。
而-from-literal 可以在不提供文件的情况下直接在命令指定key value

例子1 基于文件夹
gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/CLI/test$ cd ..
gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/CLI$ ls test/
db1.config  db2.config
gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/CLI$ cat test/db1.config 
db1.hostname=db1
db1.port=3309

gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/CLI$ cat test/db2.config 
db2.hostname=db1
db2.port=3309

gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/CLI$ kubectl create cm test-dir-config --from-file=test/
configmap/test-dir-config created

上面我创建了两个config files 在test 文件夹中, 并用folder 名创建了1个configMap item




查看 configMap 的items

gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/CLI$ kubectl get cm
NAME                DATA   AGE
kube-root-ca.crt    1      172d
test-dir-config     2      2m28s

可以见到 test-dir-config 被创建出来了




查看 configMap的内容

gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/CLI$ kubectl describe cm test-dir-config
Name:         test-dir-config
Namespace:    default
Labels:       <none>
Annotations:  <none>

Data
====
db1.config:
----
db1.hostname=db1
db1.port=3309


db2.config:
----
db2.hostname=db1
db2.port=3309



BinaryData
====

Events:  <none>
gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/CLI$ 

可以到这个configMap item 中有两个item, 注意的是
db.hostname 这种细节不是key

keys 只有两个
db1.config
db2.config

里面的内容的整体是key 对应的value!




例子2 基于某个文件

我们在另1个folder test2 created 了1个文件pgsql.yml

gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/CLI$ ls test2
pgsql.yml
gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/CLI$ cat test2/pgsql.yml 
hostname:
  db3.hostname
port:
  3310

注意格式是yaml的

这时我们创建1个configmap item

gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/CLI$ kubectl create cm db3.config --from-file=test2/pgsql.yml
configmap/db3.config created

查看configMap item

gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/CLI$ kubectl get cm
NAME                DATA   AGE
db3.config          1      67s
kube-root-ca.crt    1      172d
test-dir-config     2      52m

新建的configMap item 名字是db3.config
查看内容

gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/CLI$ kubectl describe cm db3.config
Name:         db3.config
Namespace:    default
Labels:       <none>
Annotations:  <none>

Data
====
pgsql.yml:
----
hostname:
  db3.hostname
port:
  3310

BinaryData
====

Events:  <none>

key 是 pgsql.yml

这时我们再创建1个configMap item

gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/CLI$ kubectl create cm db4.config --from-file=db4-config=test2/pgsql.yml
configmap/db4.config created

注意这里的 --from-fille=db4-config=test2/pgsql.yaml
db4-config 是指定key的名字, overwrite掉 文件名作为key

gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/CLI$ kubectl get cm
NAME                DATA   AGE
db3.config          1      5m33s
db4.config          1      85s
kube-root-ca.crt    1      172d
test-dir-config     2      57m
gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/CLI$ kubectl describe cm db4.config
Name:         db4.config
Namespace:    default
Labels:       <none>
Annotations:  <none>

Data
====
db4-config:
----
hostname:
  db3.hostname
port:
  3310

BinaryData
====

Events:  <none>

再查看内容:
这时的key 已经是 db4-config了



例子3 直接在命令行带上key value 的值
gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/CLI$ kubectl create cm db5.config --from-literal=hostname=db5.hostname --from-literal=port=3311
configmap/db5.config created
gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/CLI$ kubectl get cm
NAME                DATA   AGE
cloud-user-config   1      33d
db3.config          1      36m
db4.config          1      32m
db5.config          2      3s
kube-root-ca.crt    1      172d
test-dir-config     2      88m
gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/CLI$ kubectl describe cm db5.config
Name:         db5.config
Namespace:    default
Labels:       <none>
Annotations:  <none>

Data
====
port:
----
3311
hostname:
----
db5.hostname

BinaryData
====

Events:  <none>

注意这句命令创建了 1个 configmap item, 但是里面有两对KV
分别是
key: hostname
key: port





2. by yaml file

在项目中, 更常用定义资源应该是yaml file 格式

为了实现与上面命令同样的效果, 我们创建了1个yaml file, 内容如下

gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/yaml$ ls
db6-config.yaml
gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/yaml$ cat db6-config.yaml 
apiVersion: v1
kind: ConfigMap
metadata:
  name: db6.config
data:
  hostname: db6.hostname
  port: "3311"g

apply 资源

gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/yaml$ kubectl apply -f db6-config.yaml 
configmap/db6.config created

查看configMap items

configmap/db6.config created
gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/yaml$ kubectl get cm
NAME                DATA   AGE
db3.config          1      85m
db4.config          1      81m
db5.config          2      48m
db6.config          2      33s
kube-root-ca.crt    1      172d
test-dir-config     2      137m

查看内容

gateman@MoreFine-S500:~/projects/coding/k8s-s/configMap/yaml$ kubectl describe cm db6.config
Name:         db6.config
Namespace:    default
Labels:       <none>
Annotations:  <none>

Data
====
hostname:
----
db6.hostname
port:
----
3311

BinaryData
====

Events:  <none>

可见 效果时间一样的

configMap的使用

在yaml 里大概有两种使用方法

  1. 利用configMapKeyRef 读取配置
  2. 利用volumes 把配置写入1个文件
1. 利用configMapKeyRef 读取配置

例子:

我们首先准备1个springboot serice - cloud order
令其的actuator/info 接口可以return 当前环境的所有环境变量

@Component
@Slf4j
public class AppVersionInfo implements InfoContributor {

    @Value("${pom.version}") // https://stackoverflow.com/questions/3697449/retrieve-version-from-maven-pom-xml-in-code
    private String appVersion;

    @Autowired
    private String hostname;

    @Autowired
    private InfoService infoservice;

    @Value("${spring.datasource.url}")
    private String dbUrl;

    @Override
    // https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-features.html#production-ready-endpoints-info
    public void contribute(Info.Builder builder) {
        log.info("AppVersionInfo: contribute ...");
        builder.withDetail("app", "Cloud Order Service")
                .withDetail("version", appVersion)
                .withDetail("hostname",hostname)
                .withDetail("dbUrl", dbUrl)
                .withDetail("description", "This is a simple Spring Boot application to for cloud order.")
                .withDetail("SystemVariables", infoservice.getSystemVariables());

    }
}
@Service
public class InfoService {

        public String getHostName() {
            return "unknown";
        }

        public HashMap<String, String> getSystemVariables() {
            Map<String, String> envVariables = System.getenv();

            //envVariables.forEach((key, value) -> systemVariables.put(key, value));
            return new HashMap<>(envVariables);
        }
}

然后我们利用yaml 创建1个configMap
cloud-order-configmap.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: cloud-order-app-tag-config
data:
  APP_TAG: cloud-order-app-tag

里面指定一了1个KV 对

部署

kubectl apply -f cloud-order-configmap.yaml

然后再编写 deployment 的yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  labels: # label of this deployment
    app: cloud-order # custom defined
    author: nvd11
  name: deployment-cloud-order # name of this deployment
  namespace: default
spec:
  replicas: 3            # desired replica count, Please note that the replica Pods in a Deployment are typically distributed across multiple nodes.
  revisionHistoryLimit: 10 # The number of old ReplicaSets to retain to allow rollback
  selector: # label of the Pod that the Deployment is managing,, it's mandatory, without it , we will get this error 
            # error: error validating data: ValidationError(Deployment.spec.selector): missing required field "matchLabels" in io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector ..
    matchLabels:
      app: cloud-order
  strategy: # Strategy of upodate
    type: RollingUpdate # RollingUpdate or Recreate
    rollingUpdate:
      maxSurge: 25% # The maximum number of Pods that can be created over the desired number of Pods during the update
      maxUnavailable: 25% # The maximum number of Pods that can be unavailable during the update
  template: # Pod template
    metadata:
      labels:
        app: cloud-order # label of the Pod that the Deployment is managing. must match the selector, otherwise, will get the error Invalid value: map[string]string{"app":"bq-api-xxx"}: `selector` does not match template `labels`
    spec: # specification of the Pod
      containers:
      - image: europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/cloud-order:1.0.2 # image of the container
        imagePullPolicy: IfNotPresent
        name: container-cloud-order
        env: # set env varaibles
        - name: APP_ENVIRONMENT # name of the environment variable
          value: prod # value of the environment variable
        - name: APP_TAG 
          valueFrom: # value from config map
            configMapKeyRef: 
              name: cloud-order-app-tag-config # name of the configMap item
              key: APP_TAG # key from the config map item
            
      restartPolicy: Always # Restart policy for all containers within the Pod
      terminationGracePeriodSeconds: 10 # The period of time in seconds given to the Pod to terminate gracefully

注意, 我们在环境变量那里 新增了1个item , 环境变量的名字是 APP_TAG, 而 环境变量的value 是从 configmap 里获取的
部署成功后

测试api /actuator/info

ateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ curl http://www.jp-gcp-vms.cloud:8085/cloud-order/actuator/info | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1777    0  1777    0     0   3067      0 --:--:-- --:--:-- --:--:--  3063
{
  "app": "Cloud Order Service",
  "version": "1.0.2",
  "hostname": "deployment-cloud-order-c56db7848-lt5wc",
  "dbUrl": "jdbc:mysql://192.168.0.42:3306/demo_cloud_order?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true",
  "description": "This is a simple Spring Boot application to for cloud order.",
  "SystemVariables": {
    "PATH": "/usr/java/openjdk-17/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
    "CLUSTERIP_CLOUD_ORDER_SERVICE_HOST": "10.98.117.97",
    "CLUSTERIP_BQ_API_SERVICE_SERVICE_PORT": "8080",
    "KUBERNETES_PORT": "tcp://10.96.0.1:443",
    "JAVA_HOME": "/usr/java/openjdk-17",
    "KUBERNETES_SERVICE_HOST": "10.96.0.1",
    "LANG": "C.UTF-8",
    "CLUSTERIP_CLOUD_ORDER_PORT": "tcp://10.98.117.97:8080",
    "CLUSTERIP_BQ_API_SERVICE_PORT_8080_TCP": "tcp://10.100.68.154:8080",
    "CLUSTERIP_CLOUD_ORDER_PORT_8080_TCP": "tcp://10.98.117.97:8080",
    "CLUSTERIP_BQ_API_SERVICE_PORT_8080_TCP_PROTO": "tcp",
    "PWD": "/app",
    "JAVA_VERSION": "17.0.2",
    "_": "/usr/java/openjdk-17/bin/java",
    "CLUSTERIP_CLOUD_ORDER_PORT_8080_TCP_ADDR": "10.98.117.97",
    "KUBERNETES_PORT_443_TCP": "tcp://10.96.0.1:443",
    "KUBERNETES_PORT_443_TCP_ADDR": "10.96.0.1",
    "CLUSTERIP_CLOUD_ORDER_PORT_8080_TCP_PORT": "8080",
    "CLUSTERIP_BQ_API_SERVICE_PORT": "tcp://10.100.68.154:8080",
    "CLUSTERIP_BQ_API_SERVICE_PORT_8080_TCP_PORT": "8080",
    "KUBERNETES_PORT_443_TCP_PROTO": "tcp",
    "APP_ENVIRONMENT": "prod",
    "KUBERNETES_SERVICE_PORT": "443",
    "CLUSTERIP_CLOUD_ORDER_SERVICE_PORT": "8080",
    "CLUSTERIP_BQ_API_SERVICE_PORT_8080_TCP_ADDR": "10.100.68.154",
    "APP_TAG": "cloud-order-app-tag",
    "HOSTNAME": "deployment-cloud-order-c56db7848-lt5wc",
    "CLUSTERIP_CLOUD_ORDER_PORT_8080_TCP_PROTO": "tcp",
    "CLUSTERIP_BQ_API_SERVICE_SERVICE_HOST": "10.100.68.154",
    "KUBERNETES_PORT_443_TCP_PORT": "443",
    "KUBERNETES_SERVICE_PORT_HTTPS": "443",
    "SHLVL": "1",
    "HOME": "/root"
  }
}

查看 APP_TAG 的那一行, 的确能正确地获取configmap 里的配置信息!

2. 利用volumes 把配置写入1个文件

在这个例子中
我们再利用yaml 创建另1个configMap

apiVersion: v1
kind: ConfigMap
metadata:
  name: cloud-order-os-version-config
data:
  OS_VERSION: ubuntu-x.x

部署

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl apply -f cloud-order-configmap2.yaml
configmap/cloud-order-os-version-config created

修改 cloud order service 的deployment yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  labels: # label of this deployment
    app: cloud-order # custom defined
    author: nvd11
  name: deployment-cloud-order # name of this deployment
  namespace: default
spec:
  replicas: 3            # desired replica count, Please note that the replica Pods in a Deployment are typically distributed across multiple nodes.
  revisionHistoryLimit: 10 # The number of old ReplicaSets to retain to allow rollback
  selector: # label of the Pod that the Deployment is managing,, it's mandatory, without it , we will get this error 
            # error: error validating data: ValidationError(Deployment.spec.selector): missing required field "matchLabels" in io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector ..
    matchLabels:
      app: cloud-order
  strategy: # Strategy of upodate
    type: RollingUpdate # RollingUpdate or Recreate
    rollingUpdate:
      maxSurge: 25% # The maximum number of Pods that can be created over the desired number of Pods during the update
      maxUnavailable: 25% # The maximum number of Pods that can be unavailable during the update
  template: # Pod template
    metadata:
      labels:
        app: cloud-order # label of the Pod that the Deployment is managing. must match the selector, otherwise, will get the error Invalid value: map[string]string{"app":"bq-api-xxx"}: `selector` does not match template `labels`
    spec: # specification of the Pod
      containers:
      - image: europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/cloud-order:1.0.2 # image of the container
        imagePullPolicy: IfNotPresent
        name: container-cloud-order
        env: # set env varaibles
        - name: APP_ENVIRONMENT # name of the environment variable
          value: prod # value of the environment variable
        - name: APP_TAG 
          valueFrom: # value from config map
            configMapKeyRef: 
              name: cloud-order-app-tag-config # name of the configMap item
              key: APP_TAG # key from the config map item
        volumeMounts: # volume mount
          - name: config-volume
            mountPath: /app/config
      volumes:
        - name: config-volume
          configMap:
            name: cloud-order-os-version-config # name of the config map
            items:
              - key: OS_VERSION # key of the config map item
                path: os-version.conf # name of the file, it will only contain the content of the key
            
            
      restartPolicy: Always # Restart policy for all containers within the Pod
      terminationGracePeriodSeconds: 10 # The period of time in seconds given to the Pod to terminate gracefully

注意我们在这里新增了1个卷 把configmap cloud-order-os-version-config 指定某个key的value 保存到1个文件中 os-version.conf
而在container 的配置中, 我们 吧这个卷mount 在 /app/config 路径下

重新部署:

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl apply -f deployment-cloud-order.yaml 
deployment.apps/deployment-cloud-order configured
gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl get pods
NAME                                         READY   STATUS    RESTARTS         AGE
deployment-bq-api-service-6f6ffc7866-8djx9   1/1     Running   0                26h
deployment-bq-api-service-6f6ffc7866-g4854   1/1     Running   9 (3d21h ago)    45d
deployment-bq-api-service-6f6ffc7866-lwxt7   1/1     Running   11 (3d21h ago)   47d
deployment-bq-api-service-6f6ffc7866-mxwcq   1/1     Running   8 (3d21h ago)    45d
deployment-cloud-order-7cb8466d48-2kcnn      1/1     Running   0                8s
deployment-cloud-order-7cb8466d48-57w6n      1/1     Running   0                7s
deployment-cloud-order-7cb8466d48-d6jk7      1/1     Running   0                5s

进入容器:

gateman@MoreFine-S500:~$ kubectl exec -it deployment-cloud-order-7cb8466d48-d6jk7 /bin/bash
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
bash-4.4# cd /app/config
bash-4.4# ls
os-version.conf
bash-4.4# cat os-version.conf 
ubuntu-x.x

可以见到configmap的内容的确放入了 容器内的对应的目录下

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

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

相关文章

知识图谱构建实战:GraphRAG与Neo4j的结合之道

前言 我们在前面讲解 GraphRag 从原始文本中提取知识图谱和构建图结构的时候,最后存储的文件是parquet 格式,文件存储在下面文件夹: 这节我们就探索一下怎么将我们生成好的图谱文件导入到我们的 Neo4j 图数据库,最后进行可视化分析,也能和我们之前的项目混合检索结合起来…

Java Web|day7. Web会话跟踪(cookie与session)

Web会话跟踪(cookie与session) 会话&#xff08;Session&#xff09;跟踪是Web程序中常用的技术&#xff0c;用来跟踪用户的整个会话。 cookie 定义 cookie是某些网站为了辨别用户身份&#xff0c;进行Session跟踪而储存在用户本地终端上的数据&#xff08;通常经过加密&am…

虹科应用|增强型以太网交换机:如何实现同IP控制的高效网络管理?

导读&#xff1a;车载以太网交换机的配置和管理是确保数据流高效、安全传输的关键。虹科增强型以太网交换机&#xff08;EES&#xff09;通过其先进的功能&#xff0c;为用户提供了一种灵活且高效的解决方案。 随着车载网络对带宽需求的不断提高&#xff0c;虹科Technica推出一…

第二届EI机器视觉、图像处理与影像技术国际会议将于9月13-15日召开

第二届机器视觉、图像处理与影像技术国际会议&#xff08;The 2nd International Conference on Machine Vision, Image Processing & Imaging Technology&#xff0c;简称MVIPIT&#xff09;将于2024年9月13日-15日在中国张家口举行。 MVIPIT 2024聚焦机器视觉、图像处理…

如何将 CICD 模版重构为 CICD component?

极狐GitLab 是 GitLab 在中国的发行版&#xff0c;专门面向中国程序员和企业提供企业级一体化 DevOps 平台&#xff0c;用来帮助用户实现需求管理、源代码托管、CI/CD、安全合规&#xff0c;而且所有的操作都是在一个平台上进行&#xff0c;省事省心省钱。可以一键安装极狐GitL…

MFC画图示意八皇后问题的含义

八皇后问题是C语言算法的一个经典例子; 它要求解的问题是, 以国际象棋为背景,有八个皇后(八个棋子),如何在 8*8 的棋盘中放置八个皇后,使得任意两个皇后都不在同一条横线、纵线或者斜线上。 根据资料,答案不止一个,共有92个;可以有92种摆法; 第一个答案应该是如…

小程序学习day08-导航传参、下拉刷新(移动端的专有名词)、上拉触底(移动端的专有名词)、自定义编译模式、生命周期

34、导航传参 &#xff08;1&#xff09;声明式导航传参 1&#xff09;Navigator组件的url属性用来指定将要跳转到页面的路径&#xff0c;同时&#xff0c;可以携带参数 2&#xff09;携带参数的要求 ①参数与路径之间用?分隔 ②参数键与参数值之间用相连 ③不同参数用&…

如何在手机版和网页版Facebook上更改名字(2024)

本文将详细介绍如何在Facebook上更改名字&#xff0c;包括手机和网页版Facebook的具体步骤&#xff0c;以及添加Facebook昵称的方法&#xff0c;并分享如何高效管理多个Facebook网页版账户。 Facebook怎么改名字 Facebook手机版改名 打开Facebook APP并登录账号。 点击右下角的…

TinTinLand Web3 + DePIN 共学月|深入探索 DePIN 项目,全景分析去中心化网络未来

「TinTinLand Web3 主题共学月」是由 TinTinLand 每月发起的主题学习活动&#xff0c;携手知名项目共同打造一个系统化、互动性强的学习平台&#xff0c;帮助开发者不断提升技能&#xff0c;紧跟 Web3 技术的前沿发展。活动通过演示视频、学习打卡、模拟环境、实际操作等多种方…

2024-08-16升级记录:使用Android RecyclerView控件显示列表型信息

在页面上使用RecyclerView实现一个列表型信息展示&#xff1a; 步骤如下&#xff1a; 一、在页面布局中添加RecyclerView控件 <TextViewandroid:id"id/txt_gnss_info"android:layout_width"match_parent"android:layout_height"wrap_content"…

学习node.js 二 path模块,os模块,process

目录 path模块 1. path.basename() 2. path.dirname 3. path.extname 4. path.join 5. path.resolve 6. path.parse path.format OS模块 1. 获取操作系统的一些信息 &#xff08;1&#xff09;os.platform() &#xff08;2)os.release &#xff08;3&#xff09;os.ho…

1.1GB大更新,华为Pura70系列鸿蒙新版本优化哪些方面

华为Pura70 Pro手机迎来了其操作系统的又一次重要更新&#xff0c;推送了鸿蒙4.2.0.176新版本。这次升级不仅在安全性、音效和智慧多窗等方面进行了优化&#xff0c;还集成了2024年7月的安全补丁&#xff0c;为用户带来了更加安全、流畅的使用体验。 1.升级包内容丰富 华为Pur…

Python编码系列—掌握Python Web开发:Flask与FastAPI实战应用

&#x1f31f;&#x1f31f; 欢迎来到我的技术小筑&#xff0c;一个专为技术探索者打造的交流空间。在这里&#xff0c;我们不仅分享代码的智慧&#xff0c;还探讨技术的深度与广度。无论您是资深开发者还是技术新手&#xff0c;这里都有一片属于您的天空。让我们在知识的海洋中…

Ropdump:针对二进制可执行文件的安全检测工具

关于Ropdump Ropdump是一款针对二进制可执行文件的安全检测工具&#xff0c;该工具基于纯Python开发&#xff0c;是一个命令行工具&#xff0c;旨在帮助广大研究人员检测和分析二进制可执行文件中潜在的ROP小工具、缓冲区溢出漏洞和内存泄漏等安全问题。 功能介绍 1、识别二进…

win10安装docker,打包python、java然后centos执行镜像

一、win10安装Docker Desktop docker官网&#xff08;需要魔法&#xff09;下载&#xff1a;https://www.docker.com/products/docker-desktop/ 安装方法参考&#xff1a;https://blog.csdn.net/beautifulmemory/article/details/137970794 下载完毕后界面安装&#xff0c;不勾…

日拱一卒(3)——leetcode学习记录:二叉树最小深度

一、任务&#xff1a;平衡二叉树 给定一个二叉树&#xff0c;找出其最小深度。 最小深度是从根节点到最近叶子节点的最短路径上的节点数量。 说明&#xff1a;叶子节点是指没有子节点的节点。 二、思路&#xff1a; 1. 递归计算二叉树的深度 节点不存在&#xff0c;返回0…

2024新型数字政府综合解决方案(九)

新型数字政府综合解决方案通过整合人工智能、大数据、区块链与云计算技术&#xff0c;构建了一个智能化、透明化和高效的政务服务平台&#xff0c;以提升政府服务的响应速度和处理效率&#xff0c;增强数据的安全性和透明度&#xff1b;该平台实现了跨部门的数据共享与实时更新…

Zotero更改插入word中所有引用编号的颜色

002-如何批量更改Zotero插入在word中参考文献的颜色&#xff08;快速变蓝&#xff09; 主要根据此视频进行学习。 需要记住 查找的内容为&#xff1a; ^19 ADDIN ZOTERO_ITEM 在word中打开 文件->更多->选项->高级 下滑选择域底纹&#xff0c; 可以看到所有的引用 …

【数据结构与算法】分治法

分治法目录 一.分治法的思想二.分治法的步骤三.举个例子四.具体实现五.完整代码 一.分治法的思想 将一个大问题,拆解成为若干个小问题,而且大问题与小问题的解决方法一样. 说到这里我们可以联想到递归,没错就是用递归的思想. 分:递归解决较小的问题 治:子问题的解构建原问题的…

RTX 4070 GDDR6显存曝光:性能与成本的平衡之选

近期&#xff0c;关于NVIDIA RTX 4070新显卡的信息曝光&#xff0c;这款显卡将配备较为缓慢的GDDR6显存&#xff0c;而非更高性能的GDDR6X。这一配置的选择引发了业内的广泛关注&#xff0c;特别是在性能与成本的平衡问题上。 新版RTX 4070 OC 2X的核心特点 **1.显存类型与带…