From efd6843ffa00f858634d0429bbdeb73e8724f391 Mon Sep 17 00:00:00 2001 From: Rohit Rajak <39493074+Rohitrajak1807@users.noreply.github.com> Date: Sat, 1 Oct 2022 10:49:01 +0530 Subject: [PATCH] Use ignoreDifferences in AWSMachineTemplate.Spec to avoid out-of-sync baseclusters (#251) * ignore diffs AWSMachineTemplate.spec * add doc changes to mention immutability --- docs/baseclusters.md | 3 +++ docs/design.md | 6 +++--- pkg/cluster/cluster_app.go | 12 ++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/docs/baseclusters.md b/docs/baseclusters.md index d5bf882d..26a3f690 100644 --- a/docs/baseclusters.md +++ b/docs/baseclusters.md @@ -193,4 +193,7 @@ yet have an exhaustive list). - Changing the Kubernetes version of the control plane or data plane *is* supported, so long as the new version is supported by the relevant providers. If accepted, such a change will result in a rolling update of the corresponding plane. +- Specific to AWS: the `AWSMachineTemplate.spec` is immutable and a CAPI webhook disallows such updates. The user is advised to not make such modifications to a basecluster manifest. +In the event that such an event does happen, the user is advised to not manually sync in those changes via `argocd`. If a new cluster with a different `AWSMachineTemplate.spec` is desired, +the recommended approach is to make a copy of the manifests in the workspace repository and then issue an `arlon cluster create` command which would then consume this manifest. diff --git a/docs/design.md b/docs/design.md index 8b49f701..ecafefef 100644 --- a/docs/design.md +++ b/docs/design.md @@ -17,7 +17,7 @@ definition of *tool types*. Consequently, the list of supported bundle types mirrors ArgoCD's supported set of manifest-producing tools. Each bundle is defined using a Kubernetes ConfigMap resource in the arlo namespace. Additionally, a bundle can embed the data itself ("static bundle"), or contain a reference -to the data ("dynamic bundle"). A reference can be a URL, github location, or Helm repo location. +to the data ("dynamic bundle"). A reference can be a URL, GitHub location, or Helm repo location. The current list of supported bundle types is: * manifest_inline: a single manifest yaml file embedded in the resource @@ -31,7 +31,7 @@ The current list of supported bundle types is: Bundles can specify an optional *purpose* to help classify and organize them. In the future, Arlo may order bundle installation by purpose order (for e.g. install bundles with purpose=*networking* before others) but that is not the -case today. The currenty *suggested* purpose values are: +case today. The currently *suggested* purpose values are: - networking - add-on - data-service @@ -75,7 +75,7 @@ management cluster. Here is a summary of the kinds of resources generated and deployed by the chart: - A unique namespace with a name based on the cluster's name. All subsequent - resources below are created inside of that namespace. + resources below are created inside that namespace. - The stack-specific resources to create the cluster (for e.g. Cluster API resources) - A ClusterRegistration to automatically register the cluster with ArgoCD - A GitRepoDir to automatically create a git repo and/or directory to host a copy diff --git a/pkg/cluster/cluster_app.go b/pkg/cluster/cluster_app.go index 0b6db751..1debc439 100644 --- a/pkg/cluster/cluster_app.go +++ b/pkg/cluster/cluster_app.go @@ -83,10 +83,22 @@ func constructClusterApp( Kind: "AWSManagedControlPlane", JSONPointers: []string{"/spec/version"}, }) + + ignoreDiffs = append(ignoreDiffs, argoappv1.ResourceIgnoreDifferences{ + Group: "infrastructure.cluster.x-k8s.io", + Kind: "AWSMachineTemplate", + JSONPointers: []string{"/spec"}, + }) app.Spec.IgnoreDifferences = ignoreDiffs app.Spec.Source.Kustomize = &argoappv1.ApplicationSourceKustomize{ NamePrefix: clusterName + "-", } + app.Spec.SyncPolicy = &argoappv1.SyncPolicy{ + Automated: &argoappv1.SyncPolicyAutomated{ + Prune: true, + }, + SyncOptions: []string{"Prune=true", "RespectIgnoreDifferences=true"}, + } app.Spec.Source.RepoURL = repoUrl app.Spec.Source.TargetRevision = repoRevision app.Spec.Source.Path = repoPath