--- apiVersion: v1 kind: Namespace metadata: labels: appmesh.k8s.aws/sidecarInjectorWebhook: enabled name: ${APP_NAMESPACE} --- apiVersion: appmesh.k8s.aws/v1beta1 kind: Mesh metadata: name: ${MESH_NAME} --- apiVersion: appmesh.k8s.aws/v1beta1 kind: VirtualNode metadata: name: front namespace: ${APP_NAMESPACE} spec: meshName: ${MESH_NAME} listeners: - portMapping: port: 8080 protocol: http healthCheck: protocol: http path: '/ping' healthyThreshold: 2 unhealthyThreshold: 2 timeoutMillis: 2000 intervalMillis: 5000 backends: - virtualService: virtualServiceName: color.${APP_NAMESPACE}.svc.cluster.local serviceDiscovery: dns: hostName: front.${APP_NAMESPACE}.svc.cluster.local --- apiVersion: appmesh.k8s.aws/v1beta1 kind: VirtualNode metadata: name: blue namespace: ${APP_NAMESPACE} spec: meshName: ${MESH_NAME} listeners: - portMapping: port: 8080 protocol: http healthCheck: protocol: http path: '/ping' healthyThreshold: 2 unhealthyThreshold: 2 timeoutMillis: 2000 intervalMillis: 5000 serviceDiscovery: dns: hostName: color.${APP_NAMESPACE}.svc.cluster.local --- apiVersion: appmesh.k8s.aws/v1beta1 kind: VirtualService metadata: name: color.${APP_NAMESPACE}.svc.cluster.local namespace: ${APP_NAMESPACE} spec: meshName: ${MESH_NAME} virtualRouter: name: color-router listeners: - portMapping: port: 8080 protocol: http routes: - name: color-route http: match: prefix: / action: weightedTargets: - virtualNodeName: blue weight: 1 # UNCOMMENT below to enable retries # retryPolicy: # maxRetries: 4 # perRetryTimeoutMillis: 2000 # httpRetryEvents: # - server-error --- apiVersion: v1 kind: Service metadata: name: front namespace: ${APP_NAMESPACE} labels: app: front spec: ports: - port: 8080 name: http selector: app: front --- apiVersion: apps/v1 kind: Deployment metadata: name: front namespace: ${APP_NAMESPACE} spec: replicas: 1 selector: matchLabels: app: front template: metadata: annotations: appmesh.k8s.aws/mesh: ${MESH_NAME} labels: app: front spec: containers: - name: app image: ${FRONT_APP_IMAGE} ports: - containerPort: 8080 env: - name: "COLOR_HOST" value: "color.${APP_NAMESPACE}.svc.cluster.local:8080" - name: "PORT" value: "8080" --- apiVersion: v1 kind: Service metadata: name: color namespace: ${APP_NAMESPACE} labels: app: blue spec: ports: - port: 8080 name: http selector: app: color --- apiVersion: apps/v1 kind: Deployment metadata: name: blue namespace: ${APP_NAMESPACE} spec: replicas: 1 selector: matchLabels: app: color version: blue template: metadata: annotations: appmesh.k8s.aws/mesh: ${MESH_NAME} labels: app: color version: blue spec: containers: - name: app image: ${COLOR_APP_IMAGE} ports: - containerPort: 8080 env: - name: "COLOR" value: "blue" - name: "PORT" value: "8080"