Skip to content

Commit d647351

Browse files
authored
helm chart bug fixes (#69)
- Includes bug fixed in release script and helm bug fixes code-generator#141 - Updated README with latest ECR repo and some enhancements ### Testing Tested manually. Controller image is fine, only the charts had bugs
1 parent f5f5e2b commit d647351

File tree

3 files changed

+52
-57
lines changed

3 files changed

+52
-57
lines changed

README.md

+50-55
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,19 @@ The following sections will guide you to install SageMaker and Application Autos
3333
This guide assumes that you’ve the following prerequisites:
3434
- Installed the following tools on the client machine used to access your Kubernetes cluster:
3535
- [kubectl](https://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html) - A command line tool for working with Kubernetes clusters.
36-
- helm v3.2.4 - A tool for installing and managing Kubernetes applications
37-
- ```
38-
git clone https://github.com/aws-controllers-k8s/community.git community
39-
40-
./community/scripts/install-helm.sh
41-
```
36+
- [helm](https://helm.sh/docs/intro/install/) - A tool for installing and managing Kubernetes applications
4237
- [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv1.html) - A command line tool for interacting with AWS services.
4338
- [eksctl](https://docs.aws.amazon.com/eks/latest/userguide/eksctl.html) - A command line tool for working with EKS clusters that automates many individual tasks.
39+
- [yq](https://mikefarah.gitbook.io/yq) - command-line YAML processor.
40+
- Linux
41+
```
42+
sudo wget https://github.com/mikefarah/yq/releases/download/v4.9.8/yq_linux_amd64 -O /usr/bin/yq
43+
sudo chmod +x /usr/bin/yq
44+
```
45+
- Mac
46+
```
47+
brew install yq
48+
```
4449
- Have IAM permissions to create roles and attach policies to roles.
4550
- Created an EKS cluster on which to run the controllers. It should be Kubernetes version 1.16+. For automated cluster creation using eksctl, see [Create an Amazon EKS Cluster](https://docs.aws.amazon.com/eks/latest/userguide/create-cluster.html) and select eksctl option.
4651
@@ -55,8 +60,8 @@ export AWS_DEFAULT_REGION=<CLUSTER_REGION>
5560
aws eks update-kubeconfig --name $CLUSTER_NAME --region $AWS_DEFAULT_REGION
5661
5762
kubectl config get-contexts
58-
59-
kubectl get namespaces
63+
# Ensure cluster has compute
64+
kubectl get nodes
6065
```
6166

6267
#### 2.1 Setup IRSA for controller pod
@@ -73,7 +78,7 @@ eksctl utils associate-iam-oidc-provider --cluster ${CLUSTER_NAME} \
7378
Get the OIDC ID
7479
```sh
7580
AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query "Account" --output text)
76-
OIDC_PROVIDER=$(aws eks describe-cluster --name $CLUSTER_NAME --region $AWS_DEFAULT_REGION \
81+
OIDC_PROVIDER_URL=$(aws eks describe-cluster --name $CLUSTER_NAME --region $AWS_DEFAULT_REGION \
7782
--query "cluster.identity.oidc.issuer" --output text | cut -c9-)
7883
```
7984

@@ -87,13 +92,13 @@ printf '{
8792
{
8893
"Effect": "Allow",
8994
"Principal": {
90-
"Federated": "arn:aws:iam::'$AWS_ACCOUNT_ID':oidc-provider/'$OIDC_PROVIDER'"
95+
"Federated": "arn:aws:iam::'$AWS_ACCOUNT_ID':oidc-provider/'$OIDC_PROVIDER_URL'"
9196
},
9297
"Action": "sts:AssumeRoleWithWebIdentity",
9398
"Condition": {
9499
"StringEquals": {
95-
"'$OIDC_PROVIDER':aud": "sts.amazonaws.com",
96-
"'$OIDC_PROVIDER':sub": [
100+
"'$OIDC_PROVIDER_URL':aud": "sts.amazonaws.com",
101+
"'$OIDC_PROVIDER_URL':sub": [
97102
"system:serviceaccount:ack-system:ack-sagemaker-controller",
98103
"system:serviceaccount:ack-system:ack-applicationautoscaling-controller"
99104
]
@@ -107,18 +112,19 @@ printf '{
107112

108113

109114
Run the following command to create a role with the trust relationship defined in `trust.json`. This role enables the Amazon EKS cluster to get and refresh credentials from IAM.
115+
110116
```sh
111-
OIDC_ROLE_NAME=ack-sage-role-$CLUSTER_NAME
117+
OIDC_ROLE_NAME=ack-controller-role-$CLUSTER_NAME
112118

113119
aws --region $AWS_DEFAULT_REGION iam create-role --role-name $OIDC_ROLE_NAME --assume-role-policy-document file://trust.json
114120

115121
# Attach the AmazonSageMakerFullAccess Policy to the Role
116122
aws --region $AWS_DEFAULT_REGION iam attach-role-policy --role-name $OIDC_ROLE_NAME --policy-arn arn:aws:iam::aws:policy/AmazonSageMakerFullAccess
117-
export OIDC_ROLE_ARN=$(aws --region $AWS_DEFAULT_REGION iam get-role --role-name $OIDC_ROLE_NAME --output text --query 'Role.Arn')
118-
echo $OIDC_ROLE_ARN
123+
export IAM_ROLE_ARN_FOR_IRSA=$(aws --region $AWS_DEFAULT_REGION iam get-role --role-name $OIDC_ROLE_NAME --output text --query 'Role.Arn')
124+
echo $IAM_ROLE_ARN_FOR_IRSA
119125
```
120126

121-
Take note of OIDC_ROLE_ARN printed in the previous step; you will pass this value to the service account used by the controller.
127+
Take note of IAM_ROLE_ARN_FOR_IRSA printed in the previous step; you will pass this value to the service account used by the controller.
122128

123129
### 3.0 Install Controllers
124130

@@ -129,10 +135,10 @@ Take note of OIDC_ROLE_ARN printed in the previous step; you will pass this valu
129135
```sh
130136
export HELM_EXPERIMENTAL_OCI=1
131137
export SERVICE=sagemaker
132-
export RELEASE_VERSION=v0.0.1
138+
export RELEASE_VERSION=v0.0.2
133139
export CHART_EXPORT_PATH=/tmp/chart
134-
export CHART_REPO=public.ecr.aws/aws-controllers-k8s/chart
135-
export CHART_REF=$CHART_REPO:$SERVICE-$RELEASE_VERSION
140+
export CHART_REPO=public.ecr.aws/aws-controllers-k8s/$SERVICE-chart
141+
export CHART_REF=$CHART_REPO:$RELEASE_VERSION
136142

137143
mkdir -p $CHART_EXPORT_PATH
138144
helm chart pull $CHART_REF
@@ -144,50 +150,39 @@ helm chart export $CHART_REF --destination $CHART_EXPORT_PATH
144150

145151
- [Option 1] Cluster scoped deployment
146152
- ```sh
147-
# Change values in helm chart
148-
vim $CHART_EXPORT_PATH/ack-$SERVICE-controller/values.yaml
149-
150-
# line #29, #30, change the aws.region, aws.account_id
151-
aws:
152-
region: "<REGION_HERE>"
153-
account_id: "<ACCOUNT_ID_HERE>"
154-
155-
# line #46, remove {} in serviceAccount.annotations
156-
# line #47, uncomment eks.amazonaws.com/role-arn and add the OIDC_ROLE_ARN
157-
annotations: <REMOVE {}>
158-
eks.amazonaws.com/role-arn: <OIDC_ROLE_ARN_HERE>
153+
# Update values in helm chart
154+
cd $CHART_EXPORT_PATH/$SERVICE-chart
155+
yq e '.aws.region = env(SERVICE_REGION)' -i values.yaml
156+
yq e '.aws.account_id = env(AWS_ACCOUNT_ID)' -i values.yaml
157+
yq e '.serviceAccount.annotations."eks.amazonaws.com/role-arn" = env(IAM_ROLE_ARN_FOR_IRSA)' -i values.yaml
158+
cd -
159159
```
160160
- [Option 2] Namespace scoped deployment
161+
- Specify the namespace to listen to
162+
```sh
163+
export WATCH_NAMESPACE=<NAMESPACE_TO_LISTEN_TO>
164+
```
161165
- ```sh
162-
# Change values in helm chart
163-
vim $CHART_EXPORT_PATH/ack-$SERVICE-controller/values.yaml
164-
165-
# line #29, #30, change the aws.region, aws.account_id to default account and region where controller should create the resources
166-
aws:
167-
region: "<REGION_HERE>"
168-
account_id: "<ACCOUNT_ID_HERE>"
169-
170-
# Change the watchNamespace parameter
171-
# line #33
172-
watchNamespace: <Namespace_To_Listen_To>
173-
174-
# line #46, remove {} in serviceAccount.annotations
175-
# line #47, uncomment eks.amazonaws.com/role-arn and add the OIDC_ROLE_ARN
176-
annotations: <REMOVE {}>
177-
eks.amazonaws.com/role-arn: <OIDC_ROLE_ARN_HERE>
166+
# Update values in helm chart
167+
cd $CHART_EXPORT_PATH/$SERVICE-chart
168+
yq e '.aws.region = env(SERVICE_REGION)' -i values.yaml
169+
yq e '.aws.account_id = env(AWS_ACCOUNT_ID)' -i values.yaml
170+
yq e '.serviceAccount.annotations."eks.amazonaws.com/role-arn" = env(IAM_ROLE_ARN_FOR_IRSA)' -i values.yaml
171+
yq e '.watchNamespace" = env(WATCH_NAMESPACE)' -i values.yaml
172+
cd -
178173
```
179174
##### 3.1.3 Install Controller
180175

181176
Install CRDs
182177
```sh
183-
kubectl apply -f $CHART_EXPORT_PATH/ack-$SERVICE-controller/crds
178+
kubectl apply -f $CHART_EXPORT_PATH/$SERVICE-chart/crds
184179
```
185180

186181
Create a namespace and install the helm chart
187182
```sh
188183
export ACK_K8S_NAMESPACE=ack-system
189184
helm install -n $ACK_K8S_NAMESPACE --create-namespace --skip-crds ack-$SERVICE-controller \
190-
$CHART_EXPORT_PATH/ack-$SERVICE-controller
185+
$CHART_EXPORT_PATH/$SERVICE-chart
191186
```
192187

193188
Verify CRDs and helm charts were deployed
@@ -207,8 +202,8 @@ export HELM_EXPERIMENTAL_OCI=1
207202
export SERVICE=applicationautoscaling
208203
export RELEASE_VERSION=v0.0.1
209204
export CHART_EXPORT_PATH=/tmp/chart
210-
export CHART_REPO=public.ecr.aws/aws-controllers-k8s/chart
211-
export CHART_REF=$CHART_REPO:$SERVICE-$RELEASE_VERSION
205+
export CHART_REPO=public.ecr.aws/aws-controllers-k8s/$SERVICE-chart
206+
export CHART_REF=$CHART_REPO:$RELEASE_VERSION
212207
213208
mkdir -p $CHART_EXPORT_PATH
214209
helm chart pull $CHART_REF
@@ -451,7 +446,7 @@ export SERVICE=sagemaker
451446
helm uninstall -n $ACK_K8S_NAMESPACE ack-$SERVICE-controller
452447
453448
# Delete the CRDs
454-
cd $CHART_EXPORT_PATH/ack-$SERVICE-controller/crds
449+
cd $CHART_EXPORT_PATH/$SERVICE-chart/crds
455450
456451
$ ls
457452
sagemaker.services.k8s.aws_dataqualityjobdefinitions.yaml
@@ -476,7 +471,7 @@ Choose either of the options below to delete CRDs
476471
```
477472
- [Option 2] If you want to delete all CRDs
478473
- ```
479-
kubectl delete -f $CHART_EXPORT_PATH/ack-$SERVICE-controller/crds
474+
kubectl delete -f $CHART_EXPORT_PATH/$SERVICE-chart/crds
480475
```
481476

482477
#### 9.2 Uninstall applicationautoscaling controller and CRDs
@@ -489,7 +484,7 @@ export SERVICE=applicationautoscaling
489484
helm uninstall -n $ACK_K8S_NAMESPACE ack-$SERVICE-controller
490485
491486
# Delete the CRDs
492-
cd $CHART_EXPORT_PATH/ack-$SERVICE-controller/crds
487+
cd $CHART_EXPORT_PATH/$SERVICE-chart/crds
493488
$ ls
494489
applicationautoscaling.services.k8s.aws_scalabletargets.yaml
495490
applicationautoscaling.services.k8s.aws_scalingpolicies.yaml
@@ -503,7 +498,7 @@ Choose either of the options below to delete CRDs
503498
```
504499
- [Option 2] If you want to delete all CRDs
505500
- ```
506-
kubectl delete -f $CHART_EXPORT_PATH/ack-$SERVICE-controller/crds
501+
kubectl delete -f $CHART_EXPORT_PATH/$SERVICE-chart/crds
507502
```
508503

509504
#### 9.3 Verify charts were deleted

helm/templates/cluster-role-binding.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
roleRef:
66
apiGroup: rbac.authorization.k8s.io
77
kind: ClusterRole
8-
name: {{ include "app.name" . }}
8+
name: ack-sagemaker-controller
99
subjects:
1010
- kind: ServiceAccount
1111
name: {{ include "service-account.name" . }}

helm/values.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Declare variables to be passed into your templates.
44

55
image:
6-
repository: public.ecr.aws/aws-controller-k8s/sagemaker-controller
6+
repository: public.ecr.aws/aws-controllers-k8s/sagemaker-controller
77
tag: v0.0.2
88
pullPolicy: IfNotPresent
99
pullSecrets: []

0 commit comments

Comments
 (0)