4. ACK部署微服务
结合如下架构图,依次部署注册中心、应用A、应用B、应用C。
- 在集群列表页面,根据集群ID找到具体ACK集群(需记忆下集群名称,后续操作将用到),单击详情。
- 在左侧导航栏中,选择工作负载>无状态,在无状态页面,单击右上角的使用YAML创建资源部署应用A、应用B、应用C以及注册中心。
- 在创建页面,输入如下注册中心的YAML,单击创建,并等待注册中心启动(一般耗时30s)。
apiVersion: apps/v1 kind: Deployment metadata: name: nacos-server spec: replicas: 1 selector: matchLabels: app: nacos-server template: metadata: labels: app: nacos-server spec: containers: - env: - name: MODE value: standalone image: registry.cn-shanghai.aliyuncs.com/yizhan/nacos-server:v2.1.2 imagePullPolicy: Always name: nacos-server livenessProbe: failureThreshold: 3 initialDelaySeconds: 15 periodSeconds: 10 successThreshold: 1 tcpSocket: port: 8848 timeoutSeconds: 3 readinessProbe: failureThreshold: 3 initialDelaySeconds: 15 periodSeconds: 10 successThreshold: 1 tcpSocket: port: 8848 timeoutSeconds: 3 resources: requests: cpu: 500m memory: 1Gi dnsPolicy: ClusterFirst restartPolicy: Always # Nacos Server Service 配置 --- apiVersion: v1 kind: Service metadata: name: nacos-server spec: ports: - port: 8848 protocol: TCP targetPort: 8848 selector: app: nacos-server type: ClusterIP
- 在创建页面,输入如下的应用A、应用B、应用C的YAML,单击创建。
apiVersion: apps/v1 kind: Deployment metadata: name: spring-cloud-a spec: replicas: 1 selector: matchLabels: app: spring-cloud-a template: metadata: labels: msePilotCreateAppName: spring-cloud-a msePilotAutoEnable: 'on' app: spring-cloud-a spec: containers: - name: spring-cloud-a image: registry.cn-shanghai.aliyuncs.com/yizhan/spring-cloud-a:1.0.0 imagePullPolicy: Always ports: - containerPort: 20001 livenessProbe: tcpSocket: port: 20001 initialDelaySeconds: 10 periodSeconds: 30 --- apiVersion: apps/v1 kind: Deployment metadata: name: spring-cloud-a-gray spec: replicas: 1 selector: matchLabels: app: spring-cloud-a-gray strategy: template: metadata: labels: alicloud.service.tag: gray msePilotCreateAppName: spring-cloud-a msePilotAutoEnable: 'on' app: spring-cloud-a-gray spec: containers: - name: spring-cloud-a-new image: registry.cn-shanghai.aliyuncs.com/yizhan/spring-cloud-a:1.0.0 imagePullPolicy: Always ports: - containerPort: 20001 livenessProbe: tcpSocket: port: 20001 initialDelaySeconds: 10 periodSeconds: 30 --- apiVersion: apps/v1 kind: Deployment metadata: name: spring-cloud-b spec: replicas: 1 selector: matchLabels: app: spring-cloud-b strategy: template: metadata: labels: msePilotCreateAppName: spring-cloud-b msePilotAutoEnable: 'on' app: spring-cloud-b spec: containers: - name: spring-cloud-b image: registry.cn-shanghai.aliyuncs.com/yizhan/spring-cloud-b:1.0.0 imagePullPolicy: Always ports: - containerPort: 8080 livenessProbe: tcpSocket: port: 20002 initialDelaySeconds: 10 periodSeconds: 30 --- apiVersion: apps/v1 kind: Deployment metadata: name: spring-cloud-c spec: replicas: 1 selector: matchLabels: app: spring-cloud-c template: metadata: labels: msePilotCreateAppName: spring-cloud-c msePilotAutoEnable: 'on' app: spring-cloud-c spec: containers: - name: spring-cloud-c image: registry.cn-shanghai.aliyuncs.com/yizhan/spring-cloud-c:1.0.0 imagePullPolicy: Always ports: - containerPort: 8080 livenessProbe: tcpSocket: port: 20003 initialDelaySeconds: 10 periodSeconds: 30 --- apiVersion: apps/v1 kind: Deployment metadata: name: spring-cloud-c-gray spec: replicas: 1 selector: matchLabels: app: spring-cloud-c-gray template: metadata: labels: alicloud.service.tag: gray msePilotCreateAppName: spring-cloud-c msePilotAutoEnable: 'on' app: spring-cloud-c-gray spec: containers: - name: spring-cloud-c-gray image: registry.cn-shanghai.aliyuncs.com/yizhan/spring-cloud-c:1.0.0 imagePullPolicy: Always ports: - containerPort: 8080 livenessProbe: tcpSocket: port: 20003 initialDelaySeconds: 10 periodSeconds: 30
本步骤部署了应用A、应用B、应用C以及注册中心,可以让内部流量按照业务逻辑进行调用。下一步我们将会配置MSE Ingress网关,引入外部流量。