--- apiVersion: v1 kind: Namespace metadata: name: ${APP_NAMESPACE} labels: mesh: ${MESH_NAME} appmesh.k8s.aws/sidecarInjectorWebhook: enabled --- apiVersion: appmesh.k8s.aws/v1beta2 kind: Mesh metadata: name: ${MESH_NAME} spec: namespaceSelector: matchLabels: mesh: ${MESH_NAME} --- apiVersion: appmesh.k8s.aws/v1beta2 kind: VirtualNode metadata: name: front namespace: ${APP_NAMESPACE} spec: podSelector: matchLabels: app: front listeners: - portMapping: port: 8080 protocol: http healthCheck: protocol: http path: '/ping' healthyThreshold: 2 unhealthyThreshold: 2 timeoutMillis: 2000 intervalMillis: 5000 backends: - virtualService: virtualServiceRef: name: color serviceDiscovery: dns: hostname: front.${APP_NAMESPACE}.svc.cluster.local --- apiVersion: appmesh.k8s.aws/v1beta2 kind: VirtualNode metadata: name: blue namespace: ${APP_NAMESPACE} spec: podSelector: matchLabels: app: color version: blue 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/v1beta2 kind: VirtualService metadata: name: color namespace: ${APP_NAMESPACE} spec: awsName: color.${APP_NAMESPACE}.svc.cluster.local provider: virtualRouter: virtualRouterRef: name: color --- apiVersion: appmesh.k8s.aws/v1beta2 kind: VirtualRouter metadata: namespace: ${APP_NAMESPACE} name: color spec: listeners: - portMapping: port: 8080 protocol: http routes: - name: color-route httpRoute: match: prefix: / action: weightedTargets: - virtualNodeRef: name: blue weight: 1 # UNCOMMENT below to enable retries # retryPolicy: # maxRetries: 4 # perRetryTimeout: # unit: ms # value: 2000 # httpRetryEvents: # - server-error --- apiVersion: v1 kind: Service metadata: name: front namespace: ${APP_NAMESPACE} 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: 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} 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: 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"