• k8s集群中部署服务之部署描述文件准备


    微服务部署描述文件Deploy.yaml

    一、各微服务创建部署描述文件

    1.1 mall-auth-server

    在这里插入图片描述

    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: mall-auth-server
      namespace: sangomall
      labels:
        app: mall-auth-server
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: mall-auth-server
      template:
        metadata:
          labels:
            app: mall-auth-server
        spec:
          containers:
          - name: mall-auth-server
            image: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latest
            imagePullPolicy: Always
            ports:
            - name: tcp-30000
              containerPort: 30000
              protocol: TCP
            resources:
              limits:
                cpu: 1000m
                memory: 500Mi
              requests:
                cpu: 10m
                memory: 10Mi
    
    ---
    kind: Service
    apiVersion: v1
    metadata:
      name: mall-auth-server
      namespace: sangomall
      labels:
        app: mall-auth-server
    spec:
      ports:
      - name: http
        protocol: TCP
        port: 30000
        targetPort: 30000
      selector:
        app: mall-auth-server
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50

    1.2 mall-cart

    在这里插入图片描述

    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: mall-cart
      namespace: sangomall
      labels:
        app: mall-cart
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: mall-cart
      template:
        metadata:
          labels:
            app: mall-cart
        spec:
          containers:
          - name: mall-cart
            image: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latest
            imagePullPolicy: Always
            ports:
            - name: tcp-22200
              containerPort: 22200
              protocol: TCP
            resources:
              limits:
                cpu: 1000m
                memory: 500Mi
              requests:
                cpu: 10m
                memory: 10Mi
    
    ---
    kind: Service
    apiVersion: v1
    metadata:
      name: mall-cart
      namespace: sangomall
      labels:
        app: mall-cart
    spec:
      ports:
        - name: http
          protocol: TCP
          port: 22200
          targetPort: 22200
      selector:
        app: mall-cart
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50

    1.3 mall-coupon

    在这里插入图片描述

    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: mall-coupon
      namespace: sangomall
      labels:
        app: mall-coupon
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: mall-coupon
      template:
        metadata:
          labels:
            app: mall-coupon
        spec:
          containers:
          - name: mall-coupon
            image: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latest
            imagePullPolicy: Always
            ports:
            - name: tcp-8010
              containerPort: 8010
              protocol: TCP
            resources:
              limits:
                cpu: 1000m
                memory: 500Mi
              requests:
                cpu: 10m
                memory: 10Mi
    
    ---
    kind: Service
    apiVersion: v1
    metadata:
      name: mall-coupon
      namespace: sangomall
      labels:
        app: mall-coupon
    spec:
      ports:
        - name: http
          protocol: TCP
          port: 8010
          targetPort: 8010
      selector:
        app: mall-coupon
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50

    1.4 mall-gateway

    在这里插入图片描述

    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: mall-gateway
      namespace: sangomall
      labels:
        app: mall-gateway
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: mall-gateway
      template:
        metadata:
          labels:
            app: mall-gateway
        spec:
          containers:
          - name: mall-gateway
            image: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latest
            imagePullPolicy: Always
            ports:
              - name: tcp-8072
                containerPort: 8072
                protocol: TCP
            resources:
              limits:
                cpu: 1000m
                memory: 1024Mi
              requests:
                cpu: 10m
                memory: 512Mi
    ---
    kind: Service
    apiVersion: v1
    metadata:
      name: mall-gateway
      namespace: sangomall
      labels:
        app: mall-gateway
    spec:
      ports:
      - name: http
        protocol: TCP
        port: 8072
        targetPort: 8072
      selector:
        app: mall-gateway
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49

    1.5 mall-member

    在这里插入图片描述

    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: mall-member
      namespace: sangomall
      labels:
        app: mall-member
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: mall-member
      template:
        metadata:
          labels:
            app: mall-member
        spec:
          containers:
          - name: mall-member
            image: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latest
            imagePullPolicy: Always
            ports:
            - name: tcp-20300
              containerPort: 20300
              protocol: TCP
            resources:
              limits:
                cpu: 1000m
                memory: 500Mi
              requests:
                cpu: 10m
                memory: 10Mi
    ---
    kind: Service
    apiVersion: v1
    metadata:
      name: mall-member
      namespace: sangomall
      labels:
        app: mall-member
    spec:
      ports:
        - name: http
          protocol: TCP
          port: 20300
          targetPort: 20300
      selector:
        app: mall-member
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49

    1.6 mall-order

    在这里插入图片描述

    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: mall-order
      namespace: sangomall
      labels:
        app: mall-order
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: mall-order
      template:
        metadata:
          labels:
            app: mall-order
        spec:
          containers:
          - name: mall-order
            image: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latest
            imagePullPolicy: Always
            ports:
            - name: tcp-8030
              containerPort: 8030
              protocol: TCP
            resources:
              limits:
                cpu: 1000m
                memory: 500Mi
              requests:
                cpu: 10m
                memory: 10Mi
    
    ---
    kind: Service
    apiVersion: v1
    metadata:
      name: mall-order
      namespace: sangomall
      labels:
        app: mall-order
    spec:
      ports:
        - name: http
          protocol: TCP
          port: 8030
          targetPort: 8030
      selector:
        app: mall-order
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50

    1.7 mall-product

    在这里插入图片描述

    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: mall-product
      namespace: sangomall
      labels:
        app: mall-product
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: mall-product
      template:
        metadata:
          labels:
            app: mall-product
        spec:
          containers:
          - name: mall-product
            image: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latest
            imagePullPolicy: Always
            ports:
              - name: tcp-8040
                containerPort: 8040
                protocol: TCP
            resources:
              limits:
                cpu: 1000m
                memory: 500Mi
              requests:
                cpu: 10m
                memory: 10Mi
    
    ---
    kind: Service
    apiVersion: v1
    metadata:
      name: mall-product
      namespace: sangomall
      labels:
        app: mall-product
    spec:
      ports:
        - name: http
          protocol: TCP
          port: 8040
          targetPort: 8040
      selector:
        app: mall-product
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50

    1.8 mall-search

    在这里插入图片描述

    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: mall-search
      namespace: sangomall
      labels:
        app: mall-search
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: mall-search
      template:
        metadata:
          labels:
            app: mall-search
        spec:
          containers:
            - name: mall-search
              image: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latest
              imagePullPolicy: Always
              ports:
              - name: tcp-8090
                containerPort: 8090
                protocol: TCP
              resources:
                limits:
                  cpu: 1000m
                  memory: 500Mi
                requests:
                  cpu: 10m
                  memory: 10Mi
    
    ---
    kind: Service
    apiVersion: v1
    metadata:
      name: mall-search
      namespace: sangomall
      labels:
        app: mall-search
    spec:
      ports:
        - name: http
          protocol: TCP
          port: 8090
          targetPort: 8090
      selector:
        app: mall-search
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50

    1.9 mall-seckill

    在这里插入图片描述

    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: mall-seckill
      namespace: sangomall
      labels:
        app: mall-seckill
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: mall-seckill
      template:
        metadata:
          labels:
            app: mall-seckill
        spec:
          containers:
            - name: mall-seckill
              image: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latest
              imagePullPolicy: Always
              ports:
              - name: tcp-9601
                containerPort: 9601
                protocol: TCP
              resources:
                limits:
                  cpu: 1000m
                  memory: 500Mi
                requests:
                  cpu: 10m
                  memory: 10Mi
    
    ---
    kind: Service
    apiVersion: v1
    metadata:
      name: mall-seckill
      namespace: sangomall
      labels:
        app: mall-seckill
    spec:
      ports:
        - name: http
          protocol: TCP
          port: 9601
          targetPort: 9601
      selector:
        app: mall-seckill
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50

    1.10 mall-third-party

    在这里插入图片描述

    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: mall-third-party
      namespace: sangomall
      labels:
        app: mall-third-party
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: mall-third-party
      template:
        metadata:
          labels:
            app: mall-third-party
        spec:
          containers:
            - name: mall-third-party
              image: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latest
              imagePullPolicy: Always
              ports:
              - name: tcp-8100
                containerPort: 8100
                protocol: TCP
              resources:
                limits:
                  cpu: 1000m
                  memory: 500Mi
                requests:
                  cpu: 10m
                  memory: 10Mi
    
    ---
    kind: Service
    apiVersion: v1
    metadata:
      name: mall-third-party
      namespace: sangomall
      labels:
        app: mall-third-party
    spec:
      ports:
        - name: http
          protocol: TCP
          port: 8100
          targetPort: 8100
      selector:
        app: mall-third-party
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50

    1.11 mall-ware

    在这里插入图片描述

    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: mall-ware
      namespace: sangomall
      labels:
        app: mall-ware
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: mall-ware
      template:
        metadata:
          labels:
            app: mall-ware
        spec:
          containers:
            - name: mall-ware
              image: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latest
              imagePullPolicy: Always
              ports:
              - name: tcp-8050
                containerPort: 8050
                protocol: TCP
              resources:
                limits:
                  cpu: 1000m
                  memory: 500Mi
                requests:
                  cpu: 10m
                  memory: 10Mi
    
    
    ---
    kind: Service
    apiVersion: v1
    metadata:
      name: mall-ware
      namespace: sangomall
      labels:
        app: mall-ware
    spec:
      ports:
        - name: http
          protocol: TCP
          port: 8050
          targetPort: 8050
      selector:
        app: mall-ware
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51

    1.12 renren-fast-master [renren-fast]

    在这里插入图片描述

    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: renren-fast
      namespace: sangomall
      labels:
        app: renren-fast
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: renren-fast
      template:
        metadata:
          labels:
            app: renren-fast
        spec:
          containers:
          - name: renren-fast
            image: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latest
            imagePullPolicy: Always
            ports:
            - name: tcp-8093
              containerPort: 8093
              protocol: TCP
            resources:
              limits:
                cpu: 1000m
                memory: 500Mi
              requests:
                cpu: 10m
                memory: 10Mi
    ---
    kind: Service
    apiVersion: v1
    metadata:
      name: renren-fast
      namespace: sangomall
      labels:
        app: renren-fast
    spec:
      ports:
        - name: http
          protocol: TCP
          port: 8093
          targetPort: 8093
      selector:
        app: renren-fast
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49

    1.13 renren-generator-master [renren-generator]

    在这里插入图片描述

    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: renren-generator
      namespace: sangomall
      labels:
        app: renren-generator
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: renren-generator
      template:
        metadata:
          labels:
            app: renren-generator
        spec:
          containers:
          - name: renren-generator
            image: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latest
            imagePullPolicy: Always
            ports:
              - name: tcp-80
                containerPort: 80
                protocol: TCP
            resources:
              limits:
                cpu: 1000m
                memory: 500Mi
              requests:
                cpu: 10m
                memory: 10Mi
    
    
    ---
    kind: Service
    apiVersion: v1
    metadata:
      name: renren-generator
      namespace: sangomall
      labels:
        app: renren-generator
    spec:
      ports:
        - name: http
          protocol: TCP
          port: 80
          targetPort: 80
      selector:
        app: renren-generator
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51

    二、部署描述文件使用

    本案例通过流水线方式执行部署描述文件,在流水线中讲解。

    # kubectl apply -f deploy.yml
    
    • 1

    在这里插入图片描述

  • 相关阅读:
    初识《时间复杂度和空间复杂度》
    企业电子招标采购系统源码之从供应商管理到采购招投标、采购合同、采购执行的全过程数字化管理
    Nacos数据库配置
    PWM实验
    前端新特性
    mindspore.scipy 入门使用指导
    Java多线程基础知识-2
    最新 IntelliJ IDEA 旗舰版和社区版下载安装教程(图解)
    深入理解CSS内部样式的编写方式
    4.整合第三方技术【整合JUnit】
  • 原文地址:https://blog.csdn.net/qq_37892401/article/details/132888527