Skip to content

Commit 48ac028

Browse files
authored
Update README.md
1 parent 02272be commit 48ac028

File tree

1 file changed

+39
-28
lines changed

1 file changed

+39
-28
lines changed

README.md

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -97,44 +97,55 @@ GET '/contents': This requires a valid jwt token, and returns the un-encrpyted c
9797

9898
### Create a Kubernetes (EKS) Cluster
9999

100-
1. Create an EKS cluster named 'simpe-jwt-api'
100+
- Create an EKS cluster named 'simpe-jwt-api'
101101

102102
### Create Pipeline
103103
You will now create a pipeline which watches your Github. When changes are checked in, it will build a new image and deploy it to your cluster.
104104

105105

106106
1. Create an IAM role that CodeBuild can use to interact with EKS. :
107-
- Set an environment variable `ACCOUNT_ID` to the value of your AWS account id. You can do this with awscli:
108-
```bash
109-
ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
110-
```
111-
- Create a role policy document that allows the actions "eks:Describe*" and "ssm:GetParameters". You can do this by setting an environment variable with the role policy:
112-
```bash
113-
TRUST="{ \"Version\": \"2012-10-17\", \"Statement\": [ { \"Effect\": \"Allow\", \"Principal\": { \"AWS\": \"arn:aws:iam::${ACCOUNT_ID}:root\" }, \"Action\": \"sts:AssumeRole\" } ] }"
114-
```
115-
- Create a role named 'UdacityFlaskDeployCBKubectlRole' using the role policy document:
116-
```bash
117-
aws iam create-role --role-name UdacityFlaskDeployCBKubectlRole --assume-role-policy-document "$TRUST" --output text --query 'Role.Arn'
118-
```
119-
- Create a role policy document that also allows the actions "eks:Describe*" and "ssm:GetParameters". You can create the document in your tmp directory:
120-
```bash
121-
echo '{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "eks:Describe*", "ssm:GetParameters" ], "Resource": "*" } ] }' > /tmp/iam-role-policy
122-
```
123-
- Attach the policy to the 'UdacityFlaskDeployCBKubectlRole'. You can do this using awscli:
124-
```bash
125-
126-
aws iam put-role-policy --role-name UdacityFlaskDeployCBKubectlRole --policy-name eks-describe --policy-document file:///tmp/iam-role-policy
127-
```
107+
- Set an environment variable `ACCOUNT_ID` to the value of your AWS account id. You can do this with awscli:
108+
```bash
109+
ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
110+
```
111+
- Create a role policy document that allows the actions "eks:Describe*" and "ssm:GetParameters". You can do this by setting an environment variable with the role policy:
112+
```bash
113+
what
114+
```
115+
```bash
116+
TRUST="{ \"Version\": \"2012-10-17\", \"Statement\": [ { \"Effect\": \"Allow\", \"Principal\": { \"AWS\": \"arn:aws:iam::${ACCOUNT_ID}:root\" }, \"Action\": \"sts:AssumeRole\" } ] }"
117+
```
118+
- Create a role named 'UdacityFlaskDeployCBKubectlRole' using the role policy document:
119+
```bash
120+
aws iam create-role --role-name UdacityFlaskDeployCBKubectlRole --assume-role-policy-document "$TRUST" --output text --query 'Role.Arn'
121+
```
122+
- Create a role policy document that also allows the actions "eks:Describe*" and "ssm:GetParameters". You can create the document in your tmp directory:
123+
```bash
124+
echo '{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "eks:Describe*", "ssm:GetParameters" ], "Resource": "*" } ] }' > /tmp/iam-role-policy
125+
```
126+
- Attach the policy to the 'UdacityFlaskDeployCBKubectlRole'. You can do this using awscli:
127+
```bash
128+
aws iam put-role-policy --role-name UdacityFlaskDeployCBKubectlRole --policy-name eks-describe --policy-document file:///tmp/iam-role-policy
129+
```
128130
You have now created a role named 'UdacityFlaskDeployCBKubectlRole'
129131

130132
2. Grant the role access to the cluster.
131133
The 'aws-auth ConfigMap' is used to grant role based access control to your cluster.
132-
133-
```bash
134-
ROLE=" - rolearn: arn:aws:iam::$ACCOUNT_ID:role/UdacityFlaskDeployCBKubectlRole\n username: build\n groups:\n - system:masters"
135-
kubectl get -n kube-system configmap/aws-auth -o yaml | awk "/mapRoles: \|/{print;print \"$ROLE\";next}1" > /tmp/aws-auth-patch.yml
136-
kubectl patch configmap/aws-auth -n kube-system --patch "$(cat /tmp/aws-auth-patch.yml)"
137-
```
134+
- Get the current configmap and save it to a file:
135+
```bash
136+
kubectl get -n kube-system configmap/aws-auth -o yaml > /tmp/aws-auth-patch.yml
137+
```
138+
- In the data/mapRoles section of this document add, replacing `<ACCOUNT ID>` with your account id:
139+
```yml
140+
- rolearn: arn:aws:iam::<ACCOUNT ID>:role/UdacityFlaskDeployCBKubectlRole
141+
username: build
142+
groups:
143+
- system:masters
144+
```
145+
- Now update your cluster's configmap:
146+
```bash
147+
kubectl patch configmap/aws-auth -n kube-system --patch "$(cat /tmp/aws-auth-patch.yml)"
148+
```
138149
139150
3. Generate a GitHub access token.
140151
A Github acces token will allow CodePipeline to monitor when a repo is changed. A token can be generated [here](https://github.com/settings/tokens/=).

0 commit comments

Comments
 (0)