微服务部署描述文件Deploy.yaml
一、各微服务创建部署描述文件
1.1 mall-auth-server
---
apiVersion: apps/v1
kind: Deployment
metadata:name: mall-auth-servernamespace: sangomalllabels:app: mall-auth-server
spec:replicas: 1selector:matchLabels:app: mall-auth-servertemplate:metadata:labels:app: mall-auth-serverspec:containers:- name: mall-auth-serverimage: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latestimagePullPolicy: Alwaysports:- name: tcp-30000containerPort: 30000protocol: TCPresources:limits:cpu: 1000mmemory: 500Mirequests:cpu: 10mmemory: 10Mi---
kind: Service
apiVersion: v1
metadata:name: mall-auth-servernamespace: sangomalllabels:app: mall-auth-server
spec:ports:- name: httpprotocol: TCPport: 30000targetPort: 30000selector:app: mall-auth-server
1.2 mall-cart
---
apiVersion: apps/v1
kind: Deployment
metadata:name: mall-cartnamespace: sangomalllabels:app: mall-cart
spec:replicas: 1selector:matchLabels:app: mall-carttemplate:metadata:labels:app: mall-cartspec:containers:- name: mall-cartimage: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latestimagePullPolicy: Alwaysports:- name: tcp-22200containerPort: 22200protocol: TCPresources:limits:cpu: 1000mmemory: 500Mirequests:cpu: 10mmemory: 10Mi---
kind: Service
apiVersion: v1
metadata:name: mall-cartnamespace: sangomalllabels:app: mall-cart
spec:ports:- name: httpprotocol: TCPport: 22200targetPort: 22200selector:app: mall-cart
1.3 mall-coupon
---
apiVersion: apps/v1
kind: Deployment
metadata:name: mall-couponnamespace: sangomalllabels:app: mall-coupon
spec:replicas: 1selector:matchLabels:app: mall-coupontemplate:metadata:labels:app: mall-couponspec:containers:- name: mall-couponimage: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latestimagePullPolicy: Alwaysports:- name: tcp-8010containerPort: 8010protocol: TCPresources:limits:cpu: 1000mmemory: 500Mirequests:cpu: 10mmemory: 10Mi---
kind: Service
apiVersion: v1
metadata:name: mall-couponnamespace: sangomalllabels:app: mall-coupon
spec:ports:- name: httpprotocol: TCPport: 8010targetPort: 8010selector:app: mall-coupon
1.4 mall-gateway
---
apiVersion: apps/v1
kind: Deployment
metadata:name: mall-gatewaynamespace: sangomalllabels:app: mall-gateway
spec:replicas: 1selector:matchLabels:app: mall-gatewaytemplate:metadata:labels:app: mall-gatewayspec:containers:- name: mall-gatewayimage: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latestimagePullPolicy: Alwaysports:- name: tcp-8072containerPort: 8072protocol: TCPresources:limits:cpu: 1000mmemory: 1024Mirequests:cpu: 10mmemory: 512Mi
---
kind: Service
apiVersion: v1
metadata:name: mall-gatewaynamespace: sangomalllabels:app: mall-gateway
spec:ports:- name: httpprotocol: TCPport: 8072targetPort: 8072selector:app: mall-gateway
1.5 mall-member
---
apiVersion: apps/v1
kind: Deployment
metadata:name: mall-membernamespace: sangomalllabels:app: mall-member
spec:replicas: 1selector:matchLabels:app: mall-membertemplate:metadata:labels:app: mall-memberspec:containers:- name: mall-memberimage: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latestimagePullPolicy: Alwaysports:- name: tcp-20300containerPort: 20300protocol: TCPresources:limits:cpu: 1000mmemory: 500Mirequests:cpu: 10mmemory: 10Mi
---
kind: Service
apiVersion: v1
metadata:name: mall-membernamespace: sangomalllabels:app: mall-member
spec:ports:- name: httpprotocol: TCPport: 20300targetPort: 20300selector:app: mall-member
1.6 mall-order
---
apiVersion: apps/v1
kind: Deployment
metadata:name: mall-ordernamespace: sangomalllabels:app: mall-order
spec:replicas: 1selector:matchLabels:app: mall-ordertemplate:metadata:labels:app: mall-orderspec:containers:- name: mall-orderimage: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latestimagePullPolicy: Alwaysports:- name: tcp-8030containerPort: 8030protocol: TCPresources:limits:cpu: 1000mmemory: 500Mirequests:cpu: 10mmemory: 10Mi---
kind: Service
apiVersion: v1
metadata:name: mall-ordernamespace: sangomalllabels:app: mall-order
spec:ports:- name: httpprotocol: TCPport: 8030targetPort: 8030selector:app: mall-order
1.7 mall-product
---
apiVersion: apps/v1
kind: Deployment
metadata:name: mall-productnamespace: sangomalllabels:app: mall-product
spec:replicas: 1selector:matchLabels:app: mall-producttemplate:metadata:labels:app: mall-productspec:containers:- name: mall-productimage: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latestimagePullPolicy: Alwaysports:- name: tcp-8040containerPort: 8040protocol: TCPresources:limits:cpu: 1000mmemory: 500Mirequests:cpu: 10mmemory: 10Mi---
kind: Service
apiVersion: v1
metadata:name: mall-productnamespace: sangomalllabels:app: mall-product
spec:ports:- name: httpprotocol: TCPport: 8040targetPort: 8040selector:app: mall-product
1.8 mall-search
---
apiVersion: apps/v1
kind: Deployment
metadata:name: mall-searchnamespace: sangomalllabels:app: mall-search
spec:replicas: 1selector:matchLabels:app: mall-searchtemplate:metadata:labels:app: mall-searchspec:containers:- name: mall-searchimage: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latestimagePullPolicy: Alwaysports:- name: tcp-8090containerPort: 8090protocol: TCPresources:limits:cpu: 1000mmemory: 500Mirequests:cpu: 10mmemory: 10Mi---
kind: Service
apiVersion: v1
metadata:name: mall-searchnamespace: sangomalllabels:app: mall-search
spec:ports:- name: httpprotocol: TCPport: 8090targetPort: 8090selector:app: mall-search
1.9 mall-seckill
---
apiVersion: apps/v1
kind: Deployment
metadata:name: mall-seckillnamespace: sangomalllabels:app: mall-seckill
spec:replicas: 1selector:matchLabels:app: mall-seckilltemplate:metadata:labels:app: mall-seckillspec:containers:- name: mall-seckillimage: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latestimagePullPolicy: Alwaysports:- name: tcp-9601containerPort: 9601protocol: TCPresources:limits:cpu: 1000mmemory: 500Mirequests:cpu: 10mmemory: 10Mi---
kind: Service
apiVersion: v1
metadata:name: mall-seckillnamespace: sangomalllabels:app: mall-seckill
spec:ports:- name: httpprotocol: TCPport: 9601targetPort: 9601selector:app: mall-seckill
1.10 mall-third-party
---
apiVersion: apps/v1
kind: Deployment
metadata:name: mall-third-partynamespace: sangomalllabels:app: mall-third-party
spec:replicas: 1selector:matchLabels:app: mall-third-partytemplate:metadata:labels:app: mall-third-partyspec:containers:- name: mall-third-partyimage: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latestimagePullPolicy: Alwaysports:- name: tcp-8100containerPort: 8100protocol: TCPresources:limits:cpu: 1000mmemory: 500Mirequests:cpu: 10mmemory: 10Mi---
kind: Service
apiVersion: v1
metadata:name: mall-third-partynamespace: sangomalllabels:app: mall-third-party
spec:ports:- name: httpprotocol: TCPport: 8100targetPort: 8100selector:app: mall-third-party
1.11 mall-ware
---
apiVersion: apps/v1
kind: Deployment
metadata:name: mall-warenamespace: sangomalllabels:app: mall-ware
spec:replicas: 1selector:matchLabels:app: mall-waretemplate:metadata:labels:app: mall-warespec:containers:- name: mall-wareimage: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latestimagePullPolicy: Alwaysports:- name: tcp-8050containerPort: 8050protocol: TCPresources:limits:cpu: 1000mmemory: 500Mirequests:cpu: 10mmemory: 10Mi---
kind: Service
apiVersion: v1
metadata:name: mall-warenamespace: sangomalllabels:app: mall-ware
spec:ports:- name: httpprotocol: TCPport: 8050targetPort: 8050selector:app: mall-ware
1.12 renren-fast-master [renren-fast]
---
apiVersion: apps/v1
kind: Deployment
metadata:name: renren-fastnamespace: sangomalllabels:app: renren-fast
spec:replicas: 1selector:matchLabels:app: renren-fasttemplate:metadata:labels:app: renren-fastspec:containers:- name: renren-fastimage: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latestimagePullPolicy: Alwaysports:- name: tcp-8093containerPort: 8093protocol: TCPresources:limits:cpu: 1000mmemory: 500Mirequests:cpu: 10mmemory: 10Mi
---
kind: Service
apiVersion: v1
metadata:name: renren-fastnamespace: sangomalllabels:app: renren-fast
spec:ports:- name: httpprotocol: TCPport: 8093targetPort: 8093selector:app: renren-fast
1.13 renren-generator-master [renren-generator]
---
apiVersion: apps/v1
kind: Deployment
metadata:name: renren-generatornamespace: sangomalllabels:app: renren-generator
spec:replicas: 1selector:matchLabels:app: renren-generatortemplate:metadata:labels:app: renren-generatorspec:containers:- name: renren-generatorimage: $REGISTRY/$DOCKERHUB_NAMESPACE/$PROJECT_NAME:latestimagePullPolicy: Alwaysports:- name: tcp-80containerPort: 80protocol: TCPresources:limits:cpu: 1000mmemory: 500Mirequests:cpu: 10mmemory: 10Mi---
kind: Service
apiVersion: v1
metadata:name: renren-generatornamespace: sangomalllabels:app: renren-generator
spec:ports:- name: httpprotocol: TCPport: 80targetPort: 80selector:app: renren-generator
二、部署描述文件使用
本案例通过流水线方式执行部署描述文件,在流水线中讲解。
# kubectl apply -f deploy.yml