Kubernetes实战(五)-pod之间网络请求实战

1 同namespace内pod网络请求

1.1 创建namespace ygq

$ kubectl create namespace ygq
namespace/ygq created

1.2 创建svc和deployment 

在naemspace ygq下创建两个应用:nginx和nginx-test。

1.2.1 部署应用nginx

$ cat nginx-svc.yaml
apiVersion: v1
kind: Service
metadata:name: nginxnamespace: ygq
spec:selector:app: nginxports:- port: 80type: ClusterIP
$ cat deployment-nginx.yaml
apiVersion: apps/v1
kind: Deployment
metadata:creationTimestamp: nulllabels:app: nginxname: nginxnamespace: ygq
spec:replicas: 1selector:matchLabels:app: nginxtemplate:metadata:creationTimestamp: nulllabels:app: nginxspec:containers:- image: docker.io/library/nginx:latestname: nginximagePullPolicy: IfNotPresentimagePullSecrets:- name: harbor-login
$ kubectl apply -f nginx-svc.yaml
$ kubectl apply -f deployment-nginx.yaml
$ kubectl get svc -n ygq 
NAME         TYPE        CLUSTER-IP        EXTERNAL-IP   PORT(S)   AGE
nginx        ClusterIP   192.168.245.168   <none>        80/TCP    3d
$ kubectl get pod -n ygq
NAME                          READY   STATUS    RESTARTS        AGE
nginx-547cc75cb7-j46zl        1/1     Running   0               2d22h

1.2.2 部署应用nginx-test

$ cat nginx-test-svc.yaml
apiVersion: v1
kind: Service
metadata:name: nginx-testnamespace: ygq
spec:selector:app: nginx-testports:- port: 80type: ClusterIP
$ cat deployment-nginx-test.yaml
apiVersion: apps/v1
kind: Deployment
metadata:creationTimestamp: nulllabels:app: nginx-testname: nginx-testnamespace: ygq
spec:replicas: 1selector:matchLabels:app: nginx-testtemplate:metadata:creationTimestamp: nulllabels:app: nginx-testspec:containers:- image: docker.io/library/nginx:latestname: nginximagePullPolicy: IfNotPresentimagePullSecrets:- name: harbor-login
$ kubectl apply -f nginx-test-svc.yaml
$ kubectl apply -f deployment-nginx-test.yaml
$ kubectl get svc -n ygq 
NAME         TYPE        CLUSTER-IP        EXTERNAL-IP   PORT(S)   AGE
nginx-test   ClusterIP   192.168.97.154    <none>        80/TCP    3d
$ kubectl get pod -n ygq
NAME                          READY   STATUS    RESTARTS        AGE
nginx-test-6c5f4dfc79-2ldhg   1/1     Running   1 (2d23h ago)   3d

1.3 测试nginx与nginx-test互相访问

1.3.1 nginx访问nginx-test

1.3.1.1 登录nginx pod
$ kubectl exec -it nginx-547cc75cb7-j46zl /bin/bash -n ygq 
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
1.3.1.2 svc name方式访问nginx-test
root@nginx-547cc75cb7-j46zl:/# curl nginx 
<!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>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>
1.3.1.3 pod ip方式访问nginx-test
# kubectl get pod -n ygq -o wide 
NAME                          READY   STATUS    RESTARTS        AGE     IP              NODE                      NOMINATED NODE   READINESS GATES
nginx-test-6c5f4dfc79-2ldhg   1/1     Running   1 (2d23h ago)   3d      172.20.176.17   cn-shanghai.10.12.46.85   <none>           <none>

pod ip是172.20.176.17。

root@nginx-547cc75cb7-j46zl:/# curl http://172.20.176.17:80
<!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>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>
1.3.1.4 dns方式访问

k8s 中dns的组成结构为:service_name.namespace_name.svc.cluster.local:port,可简写为service_name.namespace_name.svc:port。

deployment nginx-test的端口为80,其dns为:nginx-test.ygq.svc.cluster.local:80,简写为:nginx-test.ygq.svc:80。

1)完整dns

root@nginx-547cc75cb7-j46zl:/# curl http://nginx-test.ygq.svc.cluster.local:80
<!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>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>

2)简写dns

root@nginx-547cc75cb7-j46zl:/# curl http://nginx-test.ygq.svc:80
<!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>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>

1.3.2  nginx-test访问nginx

1.3.2.1 登录nginx-test pod
$ kubectl exec -it nginx-test-6c5f4dfc79-2ldhg /bin/bash -n ygq 
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
1.3.2.2 svc name方式访问nginx
root@nginx-test-6c5f4dfc79-2ldhg:/# curl nginx 
<!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>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>
1.3.2.3 pod ip方式访问nginx
$ kubectl get pod -n ygq -o wide 
NAME                          READY   STATUS    RESTARTS        AGE     IP              NODE                      NOMINATED NODE   READINESS GATES
nginx-547cc75cb7-j46zl        1/1     Running   0               2d23h   172.20.176.24   cn-shanghai.10.12.46.85   <none>           <none>
root@nginx-test-6c5f4dfc79-2ldhg:/# curl http://172.20.176.24:80
<!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>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>
1.3.2.4 dns方式访问

deployment nginx的端口为80,其dns为:nginx.ygq.svc.cluster.local:80,简写为:nginx.ygq.svc:80。

1)完整dns

root@nginx-test-6c5f4dfc79-2ldhg:/# curl nginx.ygq.svc.cluster.local:80
<!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>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>

2)简写dns

root@nginx-test-6c5f4dfc79-2ldhg:/# curl nginx.ygq.svc:80
<!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>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>

1.4 结论

同namespace下不同pod直接可通过svc name、pod ip及dns互相访问。

pod ip是不固定的,会伴随pod的状态变化发生改变,生产环境不建议使用pod ip作为请求地址。 

2 不同namespace间pod网络请求

2.1 创建namespace dev

$ kubectl create namespace dev
namespace/dev created

2.2 创建svc和deployment 

在naemspace dev下创建应用:nginx-dev。

2.2.1 部署应用nginx-dev

$ cat deployment-nginx-dev.yaml
apiVersion: apps/v1
kind: Deployment
metadata:creationTimestamp: nulllabels:app: nginx-devname: nginx-devnamespace: dev
spec:replicas: 4selector:matchLabels:app: nginx-devtemplate:metadata:creationTimestamp: nulllabels:app: nginx-devspec:containers:- image: docker.io/library/nginx:latestname: nginximagePullPolicy: IfNotPresentimagePullSecrets:- name: harbor-login
$ cat nginx-dev-svc.yaml
apiVersion: v1
kind: Service
metadata:name: nginx-devnamespace: dev
spec:selector:app: nginx-devports:- port: 80type: ClusterIP
$ kubectl apply -f nginx-dev-svc.yaml
$ kubectl apply -f deployment-nginx-dev.yaml
# kubectl get svc -n dev
NAME        TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)   AGE
nginx-dev   ClusterIP   192.168.28.113   <none>        80/TCP    3d
$ kubectl get pod -n dev
NAME                         READY   STATUS    RESTARTS     AGE
nginx-dev-5966c9747d-gbdq4   1/1     Running   1 (3d ago)   3d

2.3 测试nginx与nginx-dev互相访问

2.3.1 nginx访问nginx-dev

2.3.1.1 登录nginx pod
$ kubectl exec -it nginx-547cc75cb7-j46zl /bin/bash -n ygq 
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
2.3.1.2 svc name方式访问
root@nginx-547cc75cb7-j46zl:/# curl nginx-dev
curl: (6) Could not resolve host: nginx-dev
2.3.1.3 pod ip方式访问 
$ kubectl get pod -n dev -o wide
NAME                         READY   STATUS    RESTARTS     AGE   IP             NODE                      NOMINATED NODE   READINESS GATES
nginx-dev-5966c9747d-gbdq4   1/1     Running   1 (3d ago)   3d    172.20.176.9   cn-shanghai.10.12.46.85   <none>           <none>
root@nginx-547cc75cb7-j46zl:/# curl 172.20.176.9:80
<!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>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>
2.3.1.4 dns方式访问

deployment nginx-dev的端口为80,其dns为:nginx-dev.dev.svc.cluster.local:80,简写为:nginx-dev.dev.svc:80。

1)完整dns

root@nginx-547cc75cb7-j46zl:/# curl nginx-dev.dev.svc.cluster.local:80
<!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>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>

2)简写dns

root@nginx-547cc75cb7-j46zl:/# curl nginx-dev.dev.svc:80
<!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>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>

2.3.2 nginx-dev访问nginx

2.3.2.1 登录nginx-dev pod
$ kubectl exec -it nginx-dev-5966c9747d-gbdq4 /bin/bash -n dev
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
2.3.2.2 svc name方式访问
root@nginx-dev-5966c9747d-gbdq4:/# curl nginx    
curl: (6) Could not resolve host: nginx
2.3.2.3 pod ip方式访问
$ kubectl get pod -n ygq -o wide 
NAME                          READY   STATUS    RESTARTS     AGE     IP              NODE                      NOMINATED NODE   READINESS GATES
nginx-547cc75cb7-j46zl        1/1     Running   0            2d23h   172.20.176.24   cn-shanghai.10.12.46.85   <none>           <none>
root@nginx-dev-5966c9747d-gbdq4:/# curl 172.20.176.24:80
<!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>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>
2.3.2.4 dns方式访问

deployment nginx的端口为80,其dns为:nginx.ygq.svc.cluster.local:80,简写为:nginx.ygq.svc:80。

1)完整dns

root@nginx-dev-5966c9747d-gbdq4:/# curl nginx.ygq.svc.cluster.local:80
<!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>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>

2)简写dns

root@nginx-dev-5966c9747d-gbdq4:/# curl nginx.ygq.svc:80
<!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>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>

2.4 结论 

不同namespace下pod直接可通过pod ip及dns互相访问,但不能通过svc name进行访问

pod ip是不固定的,会伴随pod的状态变化发生改变,生产环境不建议使用pod ip作为请求地址。 

3 pod name实战

3.1 同一namespace下

3.1.1 deployment

$ kubectl get pod -n ygq  -o wide 
NAME                          READY   STATUS    RESTARTS     AGE    IP              NODE                      NOMINATED NODE   READINESS GATES
nginx-547cc75cb7-j46zl        1/1     Running   0            3d     172.20.176.24   cn-shanghai.10.12.46.85   <none>           <none>
nginx-test-6c5f4dfc79-2ldhg   1/1     Running   1 (3d ago)   3d2h   172.20.176.17   cn-shanghai.10.12.46.85   <none>           <none>
$ kubectl create -f deployment-nginx.yaml 
Error from server (AlreadyExists): error when creating "deployment-nginx.yaml": deployments.apps "nginx" already exists

3.1.2 Service

$ kubectl get svc -n ygq  -o wide 
NAME         TYPE        CLUSTER-IP        EXTERNAL-IP   PORT(S)   AGE    SELECTOR
nginx        ClusterIP   192.168.245.168   <none>        80/TCP    3d1h   app=nginx
nginx-test   ClusterIP   192.168.97.154    <none>        80/TCP    3d1h   app=nginx-test
$ kubectl create -f nginx-svc.yaml
Error from server (AlreadyExists): error when creating "nginx-svc.yaml": services "nginx" already exists

3.2 不同namespace 

3.2.1 deployment

$ kubectl get pod -n dev -o wide 
NAME                         READY   STATUS    RESTARTS       AGE    IP              NODE                      NOMINATED NODE   READINESS GATES
nginx-cfcb57f6d-vr79r        1/1     Running   0              10s    172.20.176.28   cn-shanghai.10.12.46.85   <none>           <none>
nginx-dev-5966c9747d-gbdq4   1/1     Running   1 (3d1h ago)   3d1h   172.20.176.9    cn-shanghai.10.12.46.85   <none>           <none>
$ kubectl get pod -n ygq  -o wide 
NAME                          READY   STATUS    RESTARTS     AGE    IP              NODE                      NOMINATED NODE   READINESS GATES
nginx-547cc75cb7-j46zl        1/1     Running   0            3d     172.20.176.24   cn-shanghai.10.12.46.85   <none>           <none>
nginx-test-6c5f4dfc79-2ldhg   1/1     Running   1 (3d ago)   3d2h   172.20.176.17   cn-shanghai.10.12.46.85   <none>           <none>

3.2.2 Service 

$ kubectl get svc -n dev -o wide 
NAME        TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)   AGE    SELECTOR
nginx       ClusterIP   192.168.87.200   <none>        80/TCP    7s     app=nginx
nginx-dev   ClusterIP   192.168.28.113   <none>        80/TCP    3d1h   app=nginx-dev
$ kubectl get svc -n ygq  -o wide 
NAME         TYPE        CLUSTER-IP        EXTERNAL-IP   PORT(S)   AGE    SELECTOR
nginx        ClusterIP   192.168.245.168   <none>        80/TCP    3d1h   app=nginx
nginx-test   ClusterIP   192.168.97.154    <none>        80/TCP    3d1h   app=nginx-test

3.3 结论

不同namescpace下可以存在相同名称的资源,同一namespace下不允许有相同名称的资源。

4 总结

  • 同一namespace下的应用可以通过svc name、pod ip和dns互相访问,不同namespace下可以通过pod ip和dns互相访问。
  • 同一namespace下不允许有相同名称的资源,不同namescpace下可以存在名字一样的资源。

 

 

 

 

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

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

相关文章

立哥国家示范项目-5G智慧文旅

项目总体技术方案&#xff1a; 1、旅游5G专网建设&#xff1a;是基于公网授权频谱&#xff0c;采用专线形式&#xff0c;使用MEC服务器为用户提供服务,边缘计算使用Edge VLAVR支持多类型应用&#xff0c;并通过编排实现边缘业务的构建。解决了信号密度覆盖小、强度弱的问题。 …

代码随想录二刷 | 数组 | 总结篇

代码随想录二刷 &#xff5c; 数组 &#xff5c; 总结篇 基础知识二分查找移除元素有序数组的平方长度最小的数组最小覆盖子串螺旋数组 基础知识 定义&#xff1a;数组是存放在连续内存空间上的相同类型数据的集合 特点&#xff1a; 数组下标从 0 开始数组内存空间的地址是连…

Golang Context 的并发安全性探究

在 Golang 中&#xff0c;Context 是一个用于管理 goroutine 生命周期、传递请求和控制信息的重要机制。然而&#xff0c;当多个 goroutine 同时使用 Context 时&#xff0c;很容易出现并发安全性问题。本文将探讨如何正确使用 Context 并保证其在并发环境下的安全性。 1. Con…

23111707[含文档+PPT+源码等]计算机毕业设计基于javawebmysql的旅游网址前后台-全新项目

文章目录 **软件开发环境及开发工具&#xff1a;****功能介绍&#xff1a;****论文截图&#xff1a;****实现&#xff1a;****代码:** 编程技术交流、源码分享、模板分享、网课教程 &#x1f427;裙&#xff1a;776871563 软件开发环境及开发工具&#xff1a; 前端使用技术&a…

mock测试数据

1.下载一个jar 架包 地址&#xff1a;链接&#xff1a;https://pan.baidu.com/s/1G5rVF5LlIYpyU-_KHsGjOA?pwdab12 提取码&#xff1a;ab12 2.配置当前电脑java环境变量 3.在同一文件目录下创建json 数据4.在终端切换到当前目录下启动服务&#xff0c; java -jar ./moco-r…

力扣:171. Excel 表列序号(Python3)

题目&#xff1a; 给你一个字符串 columnTitle &#xff0c;表示 Excel 表格中的列名称。返回 该列名称对应的列序号 。 例如&#xff1a; A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ... 来源&#xff1a;力扣&#xff08;LeetCode&#xff09; …

使用百度翻译API或腾讯翻译API做一个小翻译工具

前言 书到用时方恨少&#xff0c;只能临时抱佛脚。英文pdf看不懂&#xff0c;压根看不懂。正好有百度翻译API和腾讯翻译API&#xff0c;就利用两个API自己写一个简单的翻译工具&#xff0c;充分利用资源&#xff0c;用的也放心。 前期准备 关键肯定是两大厂的翻译API&#x…

IDEA 集成 Docker 插件一键部署 SpringBoot 应用

目录 前言IDEA 安装 Docker 插件配置 Docker 远程服务器编写 DockerFileSpringBoot 部署配置SpringBoot 项目部署结语 前言 随着容器化技术的崛起&#xff0c;Docker成为了现代软件开发的关键工具。在Java开发中&#xff0c;Spring Boot是一款备受青睐的框架&#xff0c;然而&…

kubenetes-服务发现和负载均衡

一、服务发布 kubenetes把服务发布至集群内部或者外部&#xff0c;服务的三种不同类型&#xff1a; ClusterlPNodePortLoadBalancer ClusterIP是发布至集群内部的一个虚拟IP,通过负载均衡技术转发到不同的pod中。 NodePort解决的是集群外部访问的问题&#xff0c;用户可能不…

debian 修改镜像源为阿里云【详细步骤】

文章目录 修改步骤第 1 步:安装 vim 软件第 2 步:备份源第 3 步:修改为阿里云镜像参考👉 背景:在 Docker 中安装了 jenkins 容器。查看系统,发现是 debian 11(bullseye)。 👉 目标:修改 debian bullseye 的镜像为阿里云镜像,加速软件安装。 修改步骤 第 1 步:…

限制Domain Admin登录非域控服务器和用户计算机

限制Domain Admin管理员使用敏感管理员帐户(域或林中管理员组、域管理员组和企业管理员组中的成员帐户)登录到信任度较低的服务器和用户端计算机。 此限制可防止管理员通过登录到信任度较低的计算机来无意中增加凭据被盗的风险。 建议采用的策略 建议使用以下策略限制对信任度…

SPASS-偏相关分析

基本概念 偏相关分析的任务就是在研究两个变量之间的线性相关关系时控制可能对其产生影响的变量,这种相关系数称为偏相关系数。偏相关系数的数值和简单相关系数的数值常常是不同的,在计算简单相关系数时,所有其他自变量不予考虑。 统计原理 控制一个变量和控制两个变量的偏…

Python winreg将cmd/PowerShell(管理员)添加到右键菜单

效果 1. 脚本 用管理员权限运行&#xff0c;重复执行会起到覆盖效果&#xff08;根据sub_key&#xff09;。 icon自己设置。text可以自定义。sub_key可以改但不推荐&#xff08;避免改成和系统已有项冲突的&#xff09;。command不要改。 from winreg import *registry r&q…

Flutter执行flutter doctor报错HTTP Host Availability

问题描述 [!] HTTP Host Availability✗ HTTP host https://maven.google.com/ is not reachable. Reason: An erroroccurred while checking the HTTP host: Operation timed out解决方案 将文件flutter/packages/flutter_tools/lib/src/http_host_validator.dart中的https:…

在 Qt 框架中,有许多内置的信号可用于不同的类和对象\triggered

在 Qt 框架中&#xff0c;有许多内置的信号可用于不同的类和对象 以下是一些常见的内置信号的示例&#xff1a; clicked()&#xff1a;按钮&#xff08;QPushButton、QToolButton 等&#xff09;被点击时触发的信号。 pressed() 和 released()&#xff1a;按钮被按下和释放时…

ubuntu20.04安装cv2

查看ubuntu的版本 cat /etc/lsb-release DISTRIB_IDUbuntu DISTRIB_RELEASE20.04 DISTRIB_CODENAMEfocal DISTRIB_DESCRIPTION"Ubuntu 20.04.3 LTS"更改镜像源 cp /etc/apt/sources.list /etc/apt/sources.list.bak cat > /etc/apt/sources.listdeb http://mirr…

使用Docker部署Python Flask应用的完整教程

一、引言 Docker是一种开源的容器化平台&#xff0c;可以将应用程序及其依赖项打包成一个独立的容器&#xff0c;实现快速部署和跨平台运行。本文将详细介绍如何使用Docker来部署Python Flask应用程序&#xff0c;帮助开发者更高效地构建和部署应用。 二、准备工作 在开始之前…

4-flask-cbv源码、Jinja2模板、请求响应、flask中的session、flask项目参考

1 flask中cbv源码 2 Jinja2模板 3 请求响应 4 flask中的session 5 flask项目参考 1 flask中cbv源码 ***flask的官网文档&#xff1a;***https://flask.palletsprojects.com/en/3.0.x/views/1 cbv源码执行流程1 请求来了&#xff0c;路由匹配成功---》执行ItemAPI.as_view(item…

软件质量保护与测试(第2版)学习总结第十三章 集成测试

很多人都认为微软是一家软件开发公司&#xff0c;事实上我们是一家软件测试公司。 ---比尔盖茨 集成测试是在单元测试的基础上将多个模块组合在一起进行测试的过程。 13.1.1 区别 单元测试主要关注模块内部&#xff0c;系统测试则是在用户的角度来评价系统&#xff…

Pikachu漏洞练习平台之XXE(XML外部实体注入)

目录 什么是 XML&#xff1f; 什么是DTD&#xff1f; 什么是XEE&#xff1f; 常见payload 什么是 XML&#xff1f; XML 指可扩展标记语言&#xff08;EXtensible Markup Language&#xff09;&#xff1b; XML 不会做任何事情&#xff0c;而是用来结构化、存储以及传输信息…