How to create rolling deployment in Kubernetes in Amazon AWS using .yaml config file (including AWS Load Balancer setup)

Below process has been tested only in Amazon AWS cloud. While the rolling deployment as specified below should work on any kubernetes cluster, I'm not sure about functionality of the load balancer part in other cloud providers besides AWS.

This config deploys container
coil/stock_analytics:v2
that is getting stock price from Yahoo Finance and is exposing it as na API on port 80.

Initiate the rolling deployment using:

kubectl apply -f deployment-config.yaml

Don't forget to specify your desired version of the container in the config file.

Of course Kubernetes cluster needs to be already running and load balancer has to be enabled in AWS.

deployment-config.yaml:

---
apiVersion: v1
kind: Namespace
metadata:
  name: stock-app
---
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: stock-app
  name: deployment-stock-app
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: stock-app
  replicas: 3
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 34%
  template:
    metadata:
      labels:
        app.kubernetes.io/name: stock-app
    spec:
      containers:
      - image: coil/stock_analytics:v2
        imagePullPolicy: Always
        name: stock-app
        ports:
        - containerPort: 80
        readinessProbe:
          httpGet:
            path: /
            port: 80
          initialDelaySeconds: 4
          periodSeconds: 4
          successThreshold: 1
---
apiVersion: v1
kind: Service
metadata:
  namespace: stock-app
  name: service-stock-app
spec:
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
  type: NodePort
  selector:
    app.kubernetes.io/name: stock-app
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  namespace: stock-app
  name: ingress-stock-app
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/target-type: ip
spec:
  rules:
    - http:
        paths:
          - path: /*
            backend:
              serviceName: service-stock-app
              servicePort: 80

Sources: