# 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: Create IAM permissions for AWS X-Ray daemon ¶
# List k8s Service Accounts
kubectl get sa
# Describe Service Account (Verify IAM Role annotated)
kubectl describe sa xray-daemon
# List IAM Roles on eksdemo1 Cluster created with eksctl
eksctl get iamserviceaccount --cluster eksdemo1
AWS EKS - Elastic Kubernetes Service - Masterclass ¶
Step-04: Update IAM Role ARN in xray-k8s-daemonset.yml ¶
apiVersion:v1kind:ServiceAccountmetadata:labels:app:xray-daemonname:xray-daemonnamespace:default# Update IAM Role ARN created for X-Ray accessannotations:eks.amazonaws.com/role-arn:arn:aws:iam::180789647333:role/eksctl-eksdemo1-addon-iamserviceaccount-defa-Role1-20F5AWU2J61F
#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:3.0.0-AWS-XRay-MySQLDBports:-containerPort:8095imagePullPolicy:Alwaysenv:-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"-name:AWS_XRAY_TRACING_NAMEvalue:"User-Management-Microservice"-name:AWS_XRAY_DAEMON_ADDRESSvalue:"xray-service.default:2000"-name:AWS_XRAY_CONTEXT_MISSINGvalue:"LOG_ERROR"# Log an error and continue, Ideally RUNTIME_ERROR – Throw a runtime exception which is default option if not configured 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
#04-NotificationMicroservice-Deployment.ymlapiVersion:apps/v1kind:Deploymentmetadata:name:v1-notification-microservicelabels:app:notification-restapptrack:stablespec:replicas:1selector:matchLabels:app:notification-restapptemplate:metadata:labels:app:notification-restapptrack:stablespec:containers:-name:notification-serviceimage:stacksimplify/kube-notifications-microservice:3.0.0-AWS-XRayports:-containerPort:8096imagePullPolicy:Alwaysenv:-name:AWS_MAIL_SERVER_HOSTvalue:"smtp-service"-name:AWS_MAIL_SERVER_USERNAMEvalue:"AKIASUF7HC7SQJ6BCLVS"-name:AWS_MAIL_SERVER_PASSWORDvalue:"BARcmLiC68wgmhTy/cQvz/E8vFzeizGqdeASNtCs6+Nv"-name:AWS_MAIL_SERVER_FROM_ADDRESSvalue:"stacksimplify@gmail.com"-name:AWS_XRAY_TRACING_NAMEvalue:"V1-Notification-Microservice"-name:AWS_XRAY_DAEMON_ADDRESSvalue:"xray-service.default:2000"-name:AWS_XRAY_CONTEXT_MISSINGvalue:"LOG_ERROR"# Log an error and continue, Ideally RUNTIME_ERROR – Throw a runtime exception which is default option if not configured
#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.
# Change-1: Image Tag is 3.0.0-AWS-XRay-MySQLDBcontainers:-name:usermgmt-restappimage:stacksimplify/kube-usermanagement-microservice:3.0.0-AWS-XRay-MySQLDB# Change-2: New Environment Variables related to AWS X-Ray-name:AWS_XRAY_TRACING_NAMEvalue:"User-Management-Microservice"-name:AWS_XRAY_DAEMON_ADDRESSvalue:"xray-service.default:2000"-name:AWS_XRAY_CONTEXT_MISSINGvalue:"LOG_ERROR"# Log an error and continue, Ideally RUNTIME_ERROR – Throw a runtime exception which is default option if not configured
04-NotificationMicroservice-Deployment.yml
# Change-1: Image Tag is 3.0.0-AWS-XRayspec:containers:-name:notification-serviceimage:stacksimplify/kube-notifications-microservice:3.0.0-AWS-XRay# Change-2: New Environment Variables related to AWS X-Ray-name:AWS_XRAY_TRACING_NAMEvalue:"V1-Notification-Microservice"-name:AWS_XRAY_DAEMON_ADDRESSvalue:"xray-service.default:2000"-name:AWS_XRAY_CONTEXT_MISSINGvalue:"LOG_ERROR"# Log an error and continue, Ideally RUNTIME_ERROR – Throw a runtime exception which is default option if not configured
# Change-1-For-You: Update with your SSL Cert ARN when using templatealb.ingress.kubernetes.io/certificate-arn:arn:aws:acm:us-east-1:180789647333:certificate/9f042b5d-86fd-4fad-96d0-c81c5abc71e1# Change-2-For-You: Update with your "yourdomainname.com"# External DNS - For creating a Record Set in Route53external-dns.alpha.kubernetes.io/hostname:services-xray.kubeoncloud.com, xraydemo.kubeoncloud.com
# Test
https://xraydemo.kubeoncloud.com/usermgmt/notification-xray
https://xraydemo.kubeoncloud.com/usermgmt/notification-xray
# Your Domain Name
https://<Replace-your-domain-name>/usermgmt/notification-xray