目录
效果展示

实例基本信息
1、实例介绍:
创建两个基于nghttp2的微服务(client与server), client每隔10s钟发消息{\"hello world\"}给server,server监听消息输出消息体。
2、实例涉及:
cmake/docker/k8s/minikube/helm的使用,基于nghttp2的微服务,我们需要nghttp2源代码,或者使用其编译出来的静态库。本实例使用其静态库,自己编译太麻烦,可以使用vcpkg,编译出库,如网上的一个项目 nghttp2_asio_test。 按照其操作流程可以编译出许多静态与动态库。编译的时候有可能多次失败出现拉不下来需要的资源,如下面的错误,那就多尝试几次
Failed to download file with error: 1
If you use a proxy, please check your proxy setting. Possible causes are:
1. You are actually using an HTTP proxy, but setting HTTPS_PROXY variable
to `https://address:port`. This is not correct, because `https://` prefix
claims the proxy is an HTTPS proxy, while your proxy (v2ray, shadowsocksr
, etc..) is an HTTP proxy. Try setting `http://address:port` to both
HTTP_PROXY and HTTPS_PROXY instead.
2. You are using Fiddler. Currently a bug (https://github.com/microsoft/vcpkg/issues/17752)
will set HTTPS_PROXY to `https://fiddler_address:port` which lead to problem 1 above.
Workaround is open Windows 10 Settings App, and search for Proxy Configuration page,
Change `http=address:port;https=address:port` to `address`, and fill the port number.
3. You proxy's remote server is out of service.
In future vcpkg releases, if you are using Windows, you no longer need to set
HTTP(S)_PROXY environment variables. Vcpkg will simply apply Windows IE Proxy
Settings set by your proxy software. See (https://github.com/microsoft/vcpkg-tool/pull/49)
and (https://github.com/microsoft/vcpkg-tool/pull/77)
环境搭建:
1)安装linux系统:
制作linux系统U盘,按照步骤安装linux系统,可以按照默认流程安装linux与windows双系统。在此之前最好检查以下自己的wifi网卡驱动和要安装的linux内核版本,因为安装比较低的linux版本,有可能你无法使用wifi, 例如我的Wi-Fi 6 AX201,对系统内和要求5.2+以上, 所以我第一便安装16.4无法满足要求,后来重现下载21.10的linux重新安装。2)安装基本软件curl/git等等,
2)安装docker
可以使用 curl -fsSL https://get.docker.com -o get-docker.sh $ sudo sh get-docker.sh 如果docker version看不到server端你可以执行sudo chmod 666 /var/run/docker.sock 然后docker version就可以看到client/server: Docker Engine
ding@HPNotebook:~$ docker version
Client: Docker Engine - Community
Version: 20.10.11
API version: 1.41
Go version: go1.16.9
Git commit: dea9396
Built: Thu Nov 18 00:37:21 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/version": dial unix /var/run/docker.sock: connect: permission denied (解决办法chmod 666 /var/run/docker.sock)
3)安kubectl
http://curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.21.2/bin/linux/amd64/kubectl chmod +x ./kubectl sudo mv ./kubectl /usr/local/bin/kubect
4) minikube
安装http://wget https://github.com/kubernetes/minikube/releases/download/v1.22.0/minikube-linux-amd64.tar.gz
tar xvf minikube-linux-amd64.tar.gz mv minikube-linux-amd64 minikube 启动minikube start --kubernetes-version=v1.21.2
minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
coredns-558bd4d5db-dw5pj 1/1 Running 0 28h
etcd-minikube &nb

该博客介绍了基于nghttp2实现微服务的实例,包括创建client和server,使用cmake、docker、k8s、minikube和helm。过程中详细讲解了遇到的错误和解决方法,如编译nghttp2库、配置HTTP代理、处理Docker镜像版本不匹配的问题,以及部署和检验微服务的过程。
最低0.47元/天 解锁文章
687

被折叠的 条评论
为什么被折叠?



