#02-UserManagementMicroservice-Deployment.ymlapiVersion:apps/v1kind:Deploymentmetadata:name:usermgmt-microservicelabels:app:usermgmt-restappspec:replicas:1selector:matchLabels:app:usermgmt-restapptemplate:metadata:labels:app:usermgmt-restappspec:initContainers:-name:init-dbimage:busybox:1.31command:['sh','-c','echo-e"CheckingfortheavailabilityofMySQLServerdeployment";while!nc-zmysql3306;dosleep1;printf"-";done;echo-e">>MySQLDBServerhasstarted";']containers:-name:usermgmt-restappimage:stacksimplify/kube-usermanagement-microservice:1.0.0ports:-containerPort:8095env:-name:DB_HOSTNAMEvalue:"mysql"-name:DB_PORTvalue:"3306"-name:DB_NAMEvalue:"usermgmt"-name:DB_USERNAMEvalue:"dbadmin"-name:DB_PASSWORDvalueFrom:secretKeyRef:name:mysql-db-passwordkey:db-password-name:NOTIFICATION_SERVICE_HOSTvalue:"notification-clusterip-service"-name:NOTIFICATION_SERVICE_PORTvalue:"8096"livenessProbe:exec:command:-/bin/sh--c-nc -z localhost 8095initialDelaySeconds:60periodSeconds:10readinessProbe:httpGet:path:/usermgmt/health-statusport:8095initialDelaySeconds:60periodSeconds:10---# Kubernetes SecretsapiVersion:v1kind:Secretmetadata:name:mysql-db-password#type: Opaque means that from kubernetes's point of view the contents of this Secret is unstructured, it can contain arbitrary key-value pairs. In contrast, there is the Secret storing ServiceAccount credentials, or the ones used as ImagePullSecret . These have a constrained contents.type:Opaquedata:# Output of echo -n 'dbpassword11' | base64db-password:ZGJwYXNzd29yZDEx
#03-UserManagement-NodePort-Service.ymlapiVersion:v1kind:Servicemetadata:name:usermgmt-restapp-nodeport-servicelabels:app:usermgmt-restappannotations:#Important Note: Need to add health check path annotations in service level if we are planning to use multiple targets in a load balancer alb.ingress.kubernetes.io/healthcheck-path:/usermgmt/health-statusspec:type:NodePortselector:app:usermgmt-restappports:-port:8095targetPort:8095
#07-ALB-Ingress-SSL-Redirect-ExternalDNS.yml# Annotations Reference: https://kubernetes-sigs.github.io/aws-alb-ingress-controller/guide/ingress/annotation/apiVersion:extensions/v1beta1kind:Ingressmetadata:name:eks-microservices-demolabels:app:usermgmt-restappannotations:# Ingress Core Settings kubernetes.io/ingress.class:"alb"alb.ingress.kubernetes.io/scheme:internet-facing# Health Check Settingsalb.ingress.kubernetes.io/healthcheck-protocol:HTTPalb.ingress.kubernetes.io/healthcheck-port:traffic-portalb.ingress.kubernetes.io/healthcheck-interval-seconds:'15'alb.ingress.kubernetes.io/healthcheck-timeout-seconds:'5'alb.ingress.kubernetes.io/success-codes:'200'alb.ingress.kubernetes.io/healthy-threshold-count:'2'alb.ingress.kubernetes.io/unhealthy-threshold-count:'2'## SSL Settingsalb.ingress.kubernetes.io/listen-ports:'[{"HTTPS":443},{"HTTP":80}]'alb.ingress.kubernetes.io/certificate-arn:arn:aws:acm:us-east-1:180789647333:certificate/9f042b5d-86fd-4fad-96d0-c81c5abc71e1#alb.ingress.kubernetes.io/ssl-policy: ELBSecurityPolicy-TLS-1-1-2017-01 #Optional (Picks default if not used) # SSL Redirect Settingalb.ingress.kubernetes.io/actions.ssl-redirect:'{"Type":"redirect","RedirectConfig":{"Protocol":"HTTPS","Port":"443","StatusCode":"HTTP_301"}}'# External DNS - For creating a Record Set in Route53external-dns.alpha.kubernetes.io/hostname:services.kubeoncloud.com, ums.kubeoncloud.comspec:rules:-http:paths:-path:/*# SSL Redirect Settingbackend:serviceName:ssl-redirectservicePort:use-annotation-path:/*backend:serviceName:usermgmt-restapp-nodeport-serviceservicePort:8095# Important Note-1: In path based routing order is very important, if we are going to use "/*", try to use it at the end of all rules.
Step-01: What are we going to learn in this section? ¶
# Verify alb-ingress-controller pod running in namespace kube-system
kubectl get pods -n kube-system
# Verify external-dns pod running in default namespace
kubectl get pods
Step-03: Pre-requisite-2: Create Simple Email Service - SES SMTP Credentials ¶
IAM User Name: append the default generated name with microservice or something so we have a reference of this IAM user created for our ECS Microservice deployment
Download the credentials and update the same for below environment variables which you are going to provide in kubernetes manifest 04-NotificationMicroservice-Deployment.yml
Step-08: Update ALB Ingress Service Kubernetes Manifest ¶
Update Ingress Service to ensure only target it is going to have is User Management Service
Remove /app1, /app2 contexts
# External DNS - For creating a Record Set in Route53external-dns.alpha.kubernetes.io/hostname:services.kubeoncloud.com, ums.kubeoncloud.comspec:rules:-http:paths:-path:/*# SSL Redirect Settingbackend:serviceName:ssl-redirectservicePort:use-annotation-path:/*backend:serviceName:usermgmt-restapp-nodeport-serviceservicePort:8095
# List Pods
kubectl get pods
# User Management Microservice Logs
kubectl logs -f $(kubectl get po | egrep -o 'usermgmt-microservice-[A-Za-z0-9-]+')
# Notification Microservice Logs
kubectl logs -f $(kubectl get po | egrep -o 'notification-microservice-[A-Za-z0-9-]+')
# External DNS Logs
kubectl logs -f $(kubectl get po | egrep -o 'external-dns-[A-Za-z0-9-]+')
# List Ingress
kubectl get ingress
Step-11: Verify Microservices health-status via browser ¶
# User Management Service Health-Status
https://services.kubeoncloud.com/usermgmt/health-status
# Notification Microservice Health-Status via User Management
https://services.kubeoncloud.com/usermgmt/notification-health-status
https://services.kubeoncloud.com/usermgmt/notification-service-info
Step-12: Import postman project to Postman client on our desktop. ¶
Import postman project
Add environment url
https://services.kubeoncloud.com (Replace with your ALB DNS registered url on your environment)
Verify the email id to confirm account creation email received.
List User
Verify if newly created user got listed.
Step-14: Rollout New Deployment - Set Image Option ¶
# Rollout New Deployment using Set Image
kubectl set image deployment/notification-microservice notification-service=stacksimplify/kube-notifications-microservice:2.0.0 --record=true
# Verify Rollout Status
kubectl rollout status deployment/notification-microservice
# Verify ReplicaSets
kubectl get rs
# Verify Rollout History
kubectl rollout history deployment/notification-microservice
# Access Application (Should see V2)
https://services.kubeoncloud.com/usermgmt/notification-health-status
# Roll back to Previous Version
kubectl rollout undo deployment/notification-microservice
# Access Application (Should see V1)
https://services.kubeoncloud.com/usermgmt/notification-health-status
# Rollout New Deployment using kubectl edit, change image version to 2.0.0
kubectl edit deployment/notification-microservice
# Verify Rollout Status
kubectl rollout status deployment/notification-microservice
# Verify ReplicaSets
kubectl get rs
# Verify Rollout History
kubectl rollout history deployment/notification-microservice
# Access Application (Should see V2)
https://services.kubeoncloud.com/usermgmt/notification-health-status
# Roll back to Previous Version
kubectl rollout undo deployment/notification-microservice
# Access Application (Should see V1)
https://services.kubeoncloud.com/usermgmt/notification-health-status
# Rollout New Deployment by updating yaml manifest 2.0.0
kubectl apply -f kube-manifests/
# Verify Rollout Status
kubectl rollout status deployment/notification-microservice
# Verify ReplicaSets
kubectl get rs
# Verify Rollout History
kubectl rollout history deployment/notification-microservice
# Access Application (Should see V2)
https://services.kubeoncloud.com/usermgmt/notification-health-status
# Roll back to Previous Version
kubectl rollout undo deployment/notification-microservice
# Access Application (Should see V1)
https://services.kubeoncloud.com/usermgmt/notification-health-status