Skip to content

Commit 62d65f3

Browse files
authored
eks cluster mgmt example: readme update and fixes on argocd applications (#142)
* fix(examples-eks): add architecture diagram, fix env var names/paths, add note about CARMv2, remove known issues section, and other improvements * fix(examples-eks): shorten workload cluster names * fix(examples-eks): correct argocd applications repo url/namespace and add finalizers * fix(examples-eks): correct workload cluster sample manifest reference in readme
1 parent 77c7dd3 commit 62d65f3

File tree

8 files changed

+35
-40
lines changed

8 files changed

+35
-40
lines changed

examples/eks-cluster-mgmt/README.md

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ A hub-spoke model is used in this example; a management cluster (hub) is created
88
as part of the initial setup and the controllers needed for provisioning and
99
bootstrapping workload clusters (spokes) are installed on top.
1010

11+
![EKS cluster management using kro & ACK](docs/eks-cluster-mgmt-central.drawio.png)
12+
1113
**NOTE:** As this example evolves, some of the instructions below will be
1214
detailed further (e.g. the creation of the management cluster), others (e.g.
1315
controllers installation) will be automated via the GitOps flow.
@@ -48,7 +50,7 @@ controllers installation) will be automated via the GitOps flow.
4850

4951
```sh
5052
export KRO_REPO_URL="https://github.com/awslabs/kro.git"
51-
export WORKSPACE_PATH=<workspace-path> #the directory where repos will be cloned e.g. ~/environment/
53+
export WORKSPACE_PATH=<workspace-path> #the directory where repos will be cloned e.g. ~/environment
5254
export ACCOUNT_ID=$(aws sts get-caller-identity --output text --query Account)
5355
export AWS_REGION=<region> #e.g. us-west-2
5456
export CLUSTER_NAME=mgmt
@@ -67,15 +69,26 @@ eksctl utils associate-iam-oidc-provider --cluster $CLUSTER_NAME --approve
6769
4. Save OIDC provider URL in an environment variable:
6870

6971
```sh
70-
OIDC_PROVIDER=$(aws eks describe-cluster --name $EKS_CLUSTER_NAME --region $AWS_REGION --query "cluster.identity.oidc.issuer" --output text | sed -e "s/^https:\/\///")
72+
OIDC_PROVIDER=$(aws eks describe-cluster --name $CLUSTER_NAME --region $AWS_REGION --query "cluster.identity.oidc.issuer" --output text | sed -e "s/^https:\/\///")
7173
```
7274

7375
5. Install the following ACK controllers on the management cluster:
7476
- ACK IAM controller
7577
- ACK EC2 controller
7678
- ACK EKS controller
79+
80+
**NOTES:**
81+
- Make sure to enable CARMv2 by setting the feature flags `ServiceLevelCARM` and `TeamLevelCARM` to true.
82+
- Make sure to grant IAM permissions to assume role in workload cluster accounts
83+
7784
6. Install kro on the management cluster. Please note that this example is
78-
tested on 0.1.0-rc.3.
85+
tested on 0.1.0.
86+
```sh
87+
helm install kro oci://public.ecr.aws/kro/kro \
88+
--namespace kro \
89+
--create-namespace \
90+
--version=0.1.0
91+
```
7992
7. Install EKS pod identity add-on:
8093

8194
```sh
@@ -94,8 +107,6 @@ git clone $KRO_REPO_URL $WORKSPACE_PATH/kro
94107
the clusters definition, and it will be reconciled to the management cluster
95108
via the GitOps flow
96109

97-
**NOTE:** Until kro is released, make sure the repo you create is private.
98-
99110
10. Save the URL of the created repo in an environment variable:
100111

101112
```sh
@@ -111,8 +122,7 @@ git clone $MY_REPO_URL $WORKSPACE_PATH/cluster-mgmt
111122
12. Populate the repo:
112123

113124
```sh
114-
cp -r $WORKSPACE_PATH/kro/examples/cluster-mgmt/* $WORKSPACE_PATH/cluster-mgmt
115-
find /path/to/directory -type f -exec sed -i "s/search_string/$REPLACE_STRING/g" {} +
125+
cp -r $WORKSPACE_PATH/kro/examples/eks-cluster-mgmt/* $WORKSPACE_PATH/cluster-mgmt
116126

117127
find $WORKSPACE_PATH/cluster-mgmt -type f -exec sed -i "s~ACCOUNT_ID~$ACCOUNT_ID~g" {} +
118128
find $WORKSPACE_PATH/cluster-mgmt -type f -exec sed -i "s~MY_REPO_URL~$MY_REPO_URL~g" {} +
@@ -202,30 +212,12 @@ kubectl apply -f $WORKSPACE_PATH/cluster-mgmt/gitops/bootstrap.yaml
202212

203213
### Adding workload clusters
204214

205-
The initial configuration creates one workload cluster named
206-
`workload-cluster1`.
207-
208-
**TODO:** add steps for cluster/account mapping
209-
210-
18. Add a workload cluster by adding a manifest for it under `clusters/`. Refer
211-
to `clusters/workload-cluster1.yaml` as an example.
212-
19. Include the new cluster manifest in `clusters/kustomization.yaml`.
213-
20. Add the cluster name and corresponding account number in
215+
18. Add the cluster name and corresponding account number in
214216
`charts-values/ack-multi-account/values.yaml`.
215-
21. Commit/push the changes to Git.
216-
217-
## Known issues
218-
219-
1. You will need to restart the kro controller when you add a new workload
220-
cluster due to a bug in the controller. Once the resource group
221-
`eksclusterwithvpc` is applied, the controller is able to apply the
222-
corresponding VPC resources, but it is not able to recognize the generated
223-
ids (e.g. subnet id), and feed that into EKS resources. Refer to
224-
[this issue](https://github.com/awslabs/kro/issues/8) for more details.
225-
2. Deleting a cluster does not properly clean up all cluster resources i.e.
226-
subnets, routetables are left strangling. ACK EC2 controller keep reporting
227-
dependencies preventing deletion. To work around this issue, attempt restart
228-
ACK EC2 controller, and/or manually deleting the resources.
217+
19. Commit/push the changes to Git, then wait for the sync operation to complete by checking ArgoCD UI.
218+
20. Add a workload cluster by adding a manifest for it under `clusters/`. Refer to `clusters/workload1.yaml` as an example.
219+
21. Include the new cluster manifest in `clusters/kustomization.yaml`.
220+
22. Commit/push the changes to Git, then wait for the sync operation to complete by checking ArgoCD UI. Finally, log on to the workload cluster account to confirm that the cluster is created as expected.
229221

230222
## Clean-up
231223

examples/eks-cluster-mgmt/clusters/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ resources:
44
- rg/vpc.yaml
55
- rg/eks.yaml
66
- rg/eks-w-vpc.yaml
7-
- workload-cluster1.yaml
7+
88

99

examples/eks-cluster-mgmt/clusters/workload-cluster2.yaml renamed to examples/eks-cluster-mgmt/clusters/workload1.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
apiVersion: kro.run/v1alpha1
22
kind: EksclusterWithVpc
33
metadata:
4-
name: workload-cluster2
4+
name: workload1
55
spec:
6-
name: workload-cluster2
6+
name: workload1
77
region: AWS_REGION
88
k8sVersion: '1.30'
9+
accountId: '111222333444'
910
nodesCount: 3
1011
cidr:
1112
vpcCidr: "10.0.0.0/16"

examples/eks-cluster-mgmt/clusters/workload-cluster1.yaml renamed to examples/eks-cluster-mgmt/clusters/workload2.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
apiVersion: kro.run/v1alpha1
22
kind: EksclusterWithVpc
33
metadata:
4-
name: workload-cluster1
5-
annotations:
6-
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
7-
argocd.argoproj.io/sync-wave: "2"
4+
name: workload2
85
spec:
9-
name: workload-cluster1
6+
name: workload2
107
region: AWS_REGION
118
k8sVersion: '1.30'
9+
accountId: '111222333444'
1210
nodesCount: 3
1311
cidr:
1412
vpcCidr: "10.0.0.0/16"
170 KB
Loading

examples/eks-cluster-mgmt/gitops/bootstrap/ack-multi-account.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ spec:
1111
namespace: default
1212
project: default
1313
source:
14-
repoURL: https://github.com/iamahgoub/argocd-test.git
14+
repoURL: MY_REPO_URL
1515
targetRevision: HEAD
1616
path: charts/ack-multi-account
1717
helm:

examples/eks-cluster-mgmt/gitops/bootstrap/karpenter-iam.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ spec:
1717
template:
1818
metadata:
1919
name: '{{.name}}-karpenter-iam' # 'name' field of the Secret
20+
finalizers:
21+
- resources-finalizer.argocd.argoproj.io/foreground
2022
spec:
2123
project: default
2224
source:
@@ -35,7 +37,7 @@ spec:
3537
value: '{{trimPrefix "https://" .metadata.annotations.oidcProvider}}'
3638
destination:
3739
server: 'https://kubernetes.default.svc'
38-
namespace: argocd
40+
namespace: '{{.name}}'
3941
syncPolicy:
4042
automated:
4143
prune: true

examples/eks-cluster-mgmt/gitops/bootstrap/karpenter.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ spec:
1717
template:
1818
metadata:
1919
name: '{{.name}}-karpenter' # 'name' field of the Secret
20+
finalizers:
21+
- resources-finalizer.argocd.argoproj.io/foreground
2022
spec:
2123
project: default
2224
source:

0 commit comments

Comments
 (0)