加入收藏 | 设为首页 | 会员中心 | 我要投稿 惠州站长网 (https://www.0752zz.com.cn/)- 办公协同、云通信、物联设备、操作系统、高性能计算!
当前位置: 首页 > 移动 > 正文

微服务架构在Kubernetes上的实现

发布时间:2019-07-13 03:27:14 所属栏目:移动 来源:新牛哥
导读:副标题#e# 【编者的话】本文是微服务网格系列的第二部分,通过Kubernetes这个当前最流行的微服务部署平台,来具体讲解微服务的部署过程,让用户对微服务有具体认知,同时为后续结合Istio部署更复杂服务打下基

现在我们只需要构建它。 选择一个镜像tag,然后运行以下两个Docker命令来构建和保存镜像:

  1. # Build the container on your local machine 
  2. docker build -t <image-tag> . 
  3. # Push the container to docker registry 
  4. docker push <image-tag> 

在我们部署之前还有一步。虽然我们已经定义了将进入我们的Pod的内容,但我们还没有定义我们的服务。让我们做一个简单的服务定义,称为Hello Service。我们将它保存在hello-service.yml服务定义文件中。

  1. apiVersion: v1 
  2. kind: Service 
  3. metadata: 
  4. name: helloworld-v1 
  5. spec: 
  6. ports: 
  7.   - port: 80 
  8.   protocol: TCP 
  9.   targetPort: 8080 
  10. selector: 
  11.    app: helloworld-v1 
  12. type: LoadBalancer 
  13.  
  14. --- 
  15.  
  16. apiVersion: apps/v1 
  17. kind: Deployment 
  18. metadata: 
  19. name: helloworld-v1 
  20. labels: 
  21.   app: helloworld-v1 
  22. spec: 
  23. replicas: 1 
  24. selector: 
  25.   matchLabels: 
  26.      app: helloworld-v1 
  27. template: 
  28.   metadata: 
  29.      labels: 
  30.         app: helloworld-v1 
  31.   spec: 
  32.      containers: 
  33.         - name: helloworld-kubernetes 
  34.         # replace <image-tag> with your actual image 
  35.           image: <image-tag> 
  36.           ports: 
  37.             - containerPort: 8080 

(编辑:惠州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

推荐文章
    热点阅读