Saturday, April 1, 2023

Step by Step EKS with AWS Resilience Hub

 This video is step by step demo to setup EKS cluster in AWS resilience hub and check RTO and RPO of microservice. The source code is also below:




Step 1: Create an IAM role named AwsResilienceHubAssessmentEKSAccessRole. export ACCOUNT_ID=$(aws sts get-caller-identity --output text --query Account) export POLICY=$(echo -n '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"AWS":"arn:aws:iam::'; echo -n "$ACCOUNT_ID"; echo -n ':root"},"Action":"sts:AssumeRole","Condition":{}}]}') aws iam create-role \ --role-name AwsResilienceHubAssessmentEKSAccessRole \ --description="Amazon Resilience Hub read only role (for AWS IAM Authenticator for Kubernetes)." \ --assume-role-policy-document "$POLICY" Step 2: Create a Resilience Hub ClusterRole and RoleBinding/ClusterRoleBinding cat <<EOF | kubectl apply -f - apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: resilience-hub-eks-access-cluster-role rules: - apiGroups: - "" resources: - pods - replicationcontrollers - nodes verbs: - get - list - apiGroups: - apps resources: - deployments - replicasets verbs: - get - list - apiGroups: - policy resources: - poddisruptionbudgets verbs: - get - list - apiGroups: - autoscaling.k8s.io resources: - verticalpodautoscalers verbs: - get - list - apiGroups: - autoscaling resources: - horizontalpodautoscalers verbs: - get - list - apiGroups: - karpenter.sh resources: - provisioners verbs: - get - list - apiGroups: - karpenter.k8s.aws resources: - awsnodetemplates verbs: - get - list --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: resilience-hub-eks-access-cluster-role-binding subjects: - kind: Group name: resilience-hub-eks-access-group apiGroup: rbac.authorization.k8s.io roleRef: kind: ClusterRole name: resilience-hub-eks-access-cluster-role apiGroup: rbac.authorization.k8s.io --- EOF Bash ==================== Step 3: Then create a mapping between the IAM role

AwsResilienceHubAssessmentEKSAccessRole , with the Kubernetes group resilience-hub-eks-access-group eksctl create iamidentitymapping \ --cluster eks-resilience-cluster \ --region=us-east-2 \ --arn arn:aws:iam::"$ACCOUNT_ID":role/AwsResilienceHubAssessmentEKSAccessRole \ --group resilience-hub-eks-access-group \ --username AwsResilienceHubAssessmentEKSAccessRole

No comments: