learning-appmesh
Overview
- pre-requisites
- AppMesh integration with EKS
- Deploy a sample application
pre-requisites
-
Clone this repository
git clone https://github.com/saiteja313/learning-appmesh.git
-
Install jq
brew install jq -y
-
Create EKS cluster
-
export AWS_REGION="us-east-2" export AWS_DEFAULT_REGION="us-east-2" export AWS_ACCOUNT_ID=$(aws sts get-caller-identity | jq -r .Account) export CLUSTER_NAME="appmesh-l3" eksctl create cluster --name appmesh-l3 --managed --region us-east-2
-
List worker node IAM role ARN
eksctl get iamidentitymapping --cluster appmesh-l3
-
Add AppMesh policy to worker node role ARN
aws iam attach-role-policy --policy-arn arn:aws:iam::aws:policy/AWSAppMeshFullAccess --role-name <ROLE_NAME_FROM_PREVIOUS_STEP>
-
Install kubectl
-
Install Helm
export KUBBECONFIG="~/.kube/config" curl -sSL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash helm version --short
AppMesh integration with EKS
-
Deploy AppMesh Custom Resource Definitions (CRD's)
kubectl apply -k "https://github.com/aws/eks-charts/stable/appmesh-controller/crds?ref=master"
-
Create
appmesh-system
namespacekubectl create namespace appmesh-system
-
Enable IAM OIDC provider on EKS Cluster
eksctl utils associate-iam-oidc-provider --region=$AWS_REGION \ --cluster=$CLUSTER_NAME \ --approve
-
Download IAM Policy and create policy
curl -o controller-iam-policy.json https://raw.githubusercontent.com/aws/aws-app-mesh-controller-for-k8s/master/config/iam/controller-iam-policy.json aws iam create-policy \ --policy-name AWSAppMeshK8sControllerIAMPolicy \ --policy-document file://controller-iam-policy.json
-
Create Service Account
eksctl create iamserviceaccount --cluster $CLUSTER_NAME \ --namespace appmesh-system \ --name appmesh-controller \ --attach-policy-arn arn:aws:iam::$AWS_ACCOUNT_ID:policy/AWSAppMeshK8sControllerIAMPolicy \ --override-existing-serviceaccounts \ --approve
-
Deploy AppMesh Controller
export AWS_REGION=us-east-2 helm repo add eks https://aws.github.io/eks-charts helm upgrade -i appmesh-controller eks/appmesh-controller \ --namespace appmesh-system \ --set region=$AWS_REGION \ --set serviceAccount.create=false \ --set serviceAccount.name=appmesh-controller \ --set sidecar.logLevel=error
-
Validate AppMesh Controller pod is in 'Running' status
kubectl get pods -n appmesh-system
Deploy a Sample application
-
Deploy Sample application manifests in EKS
-
kubectl apply -f https://raw.githubusercontent.com/aws/aws-app-mesh-examples/master/walkthroughs/eks-getting-started/infrastructure/yelb_initial_deployment.yaml
-
-
Validate that application is running.
kubectl get svc -n yelb
- Copy Load Balancer URL
Deploy sample application with AppMesh resources
-
Label namespace
kubectl label namespace yelb mesh=yelb kubectl label namespace yelb appmesh.k8s.aws/sidecarInjectorWebhook=enabled
-
Create AppMesh resources in AWS using YAML manifests
kubectl apply -f https://raw.githubusercontent.com/saiteja313/learning-appmesh/master/yelb-mesh.yml kubectl apply -f https://raw.githubusercontent.com/aws/aws-app-mesh-examples/master/walkthroughs/eks-getting-started/infrastructure/appmesh_templates/appmesh-yelb-redis.yaml kubectl apply -f https://raw.githubusercontent.com/aws/aws-app-mesh-examples/master/walkthroughs/eks-getting-started/infrastructure/appmesh_templates/appmesh-yelb-db.yaml kubectl apply -f https://raw.githubusercontent.com/aws/aws-app-mesh-examples/master/walkthroughs/eks-getting-started/infrastructure/appmesh_templates/appmesh-yelb-appserver.yaml kubectl apply -f https://raw.githubusercontent.com/aws/aws-app-mesh-examples/master/walkthroughs/eks-getting-started/infrastructure/appmesh_templates/appmesh-yelb-ui.yaml
-
Re-deploy Yelb application
kubectl delete -f delete_yelb_initial_deployment.yaml kubectl apply -f https://raw.githubusercontent.com/aws/aws-app-mesh-examples/master/walkthroughs/eks-getting-started/infrastructure/yelb_initial_deployment.yaml
Rolling update deployment for Yelb application
- Create a new Virtual Node in AppMesh
kubectl apply -f https://raw.githubusercontent.com/aws/aws-app-mesh-examples/master/walkthroughs/eks-getting-started/infrastructure/appmesh_templates/appmesh-yelb-appserver-v2.yaml
- Create a new Deployment in EKS
kubectl apply -f https://raw.githubusercontent.com/saiteja313/learning-appmesh/master/yelb_appserver_v2_deployment.yml
- Update Virtual Route in AppMesh to send 50% traffic to new Deployment
kubectl apply -f https://raw.githubusercontent.com/aws/aws-app-mesh-examples/master/walkthroughs/eks-getting-started/infrastructure/appmesh_templates/appmesh-virtual-router-appserver-v1-v2.yaml
-
Update Virtual Route in AppMesh to send 100% traffic to new Deployment
kubectl apply -f https://raw.githubusercontent.com/aws/aws-app-mesh-examples/master/walkthroughs/eks-getting-started/infrastructure/appmesh_templates/appmesh-virtual-router-appserver-v2.yaml