Test deployment of sample webapp on AWS EKS:

In the future post, I will explain all the steps required to install the K8s infra (both on-premise and cloud) and document detailed steps for the deployments of web apps. For now, I am sharing here some of the commands I used to test deployments of containerized webapp (frontend app and backend db) on the AWS Kubernetes platform:

A little busy at work at this moment, but I will try to update the blog as soon as I can. Please stay tuned for updates...

aws sts get-caller-identity
eksctl create cluster --ssh-access --ssh-public-key=ekstestkey --region=ap-southeast-2
eksctl get cluster --region ap-southeast-2
aws eks list-clusters --region ap-southeast-2
kubectl get nodes
kubectl get nodes --show-labels

kubectl get rc,services
kubectl get nodes --watch
kubectl cluster-info
kubectl config view
kubectl get rs --all-namespaces


--- Creating Frontend
kubectl apply -f deployment_AWSEKSFE.txt

kubectl get pods --show-labels
kubectl describe deployments
kubectl get deployments
kubectl get pod -o wide

kubectl get pod -l app=eksappfe
kubectl get pod -L app

kubectl describe pod app-fe-deployment-xxx
kubectl get Pods app-fe-deployment-xxx -o yaml
kubectl get pod -o wide | Select-String -Pattern ip-192-

kubectl port-forward pod/app-fe-deployment-xxx 8080:4567
curl.exe  localhost:8080
# run one command
kubectl exec app-fe-deployment-xxx cat /etc/hostname
# run with console connected to pod
kubectl exec -it app-fe-deployment-xxx -- bash
netstat -tulpn | grep LISTEN
kubectl.exe logs app-fe-deployment-xxx

Scale out the deployment
kubectl scale deployment app-fe-deployment --replicas=5
kubectl edit deployment app-fe-deployment
# set spec.replicas to 3

kubectl get services
kubectl describe svc app-fe-service

kubectl edit svc app-fe-service
# change spec.type from 'ClusterIP' to 'LoadBalancer'

kubectl get svc app-fe-service
kubectl get services app-fe-service

kubectl get services -o wide
kubectl get svc --all-namespaces

ping a685d205c31e111e9b81b06a9bc74ebe-575346284.ap-southeast-2.elb.amazonaws.com

--- Creating Backend
kubectl apply -f deployment_AWSEKSBE.txt

kubectl describe svc db-be-service
kubectl edit svc db-be-service
# change spec.type from 'ClusterIP' to 'LoadBalancer'

kubectl get rs --all-namespaces
kubectl get pod -o wide

--- Test app to db connection.

--- Check FE and BE pod logs
kubectl logs app-fe-deployment-xxx
kubectl logs db-be-deployment-xxx

kubectl exec -it app-fe-deployment-xxx -- bash  (hit app and see what you see in STDOUT)
kubectl exec -it db-be-deployment-xxx -- bash  (hit app and see what you see in STDOUT)

--- Check ENV vars in FE and BE pods.
---- Create new pods so the env vars inside the pods backend services
kubectl apply -f deployment_AWSEKSFE-Label.txt

--- Create 2 ENV VARs in 2 worker nodes
	mongo_service_host=db-be-service
	mongo_service_port=27017

--- Check ENV vars in FE pods.
--- Test app to db connection.
--- Deploy FE pods agian so they can take the ENV vars.
--- Check ENV vars in FE pods.
--- Test app to db connection. Should work i.e. app connects to mongo db

--- deployment_AWSEKSFEenvVars.txt

apiVersion: apps/v1
kind: Deployment
metadata:
  name: app-fe-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
     app: appfe
  template:
    metadata:
      labels:
        env: test
        app: appfe
    spec:
      containers:
      - name: appcontainer
        image: <$dockeruser>/nodejsapp
        env:
        - name: mongo_service_host
          value: "10.108.77.88"
        - name: mongo_service_port
          value: "27017"

---- create env var using this method

https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/

kubectl apply -f deployment_AWSEKSFEenvVars.txt

Please stay tuned...