Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ When adding a new handler, or modifying an existing one, pay close attention to
when a new version of this extension is deployed in the management cluster,
and avoid rollouts of Machines in those existing clusters.

If a change to a handler is unavoidable, you must:

1. Update the version of the handlers, e.g. from `v4` to `v5`.
This is done by updating the `..ClusterV4ConfigPatch` in the handler files in `pkg/handlers/../mutation/`.
And `..clusterv4configpatch` in `hack/examples/overlays/clusterclasses/../kustomization.yaml.tmpl`
2. Update the version of the handler in the `pkg/handlers/v3` package, e.g. from `v3` to `v4`.
3. Copy the existing implementation of the handler to `pkg/handlers/../v4/`.

During CAPI provider upgrades, and periodically, all managed clusters are reconciled and mutation handler patches
are applied.
Any new handlers that return a new set of patches, or updated handlers that return a different set of patches,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ spec:
patches:
- external:
discoverVariablesExtension: awsclusterconfigvars-dv.cluster-api-runtime-extensions-nutanix
generateExtension: awsclusterv3configpatch-gp.cluster-api-runtime-extensions-nutanix
generateExtension: awsclusterv4configpatch-gp.cluster-api-runtime-extensions-nutanix
name: cluster-config
- external:
discoverVariablesExtension: awsworkerconfigvars-dv.cluster-api-runtime-extensions-nutanix
generateExtension: awsworkerv3configpatch-gp.cluster-api-runtime-extensions-nutanix
generateExtension: awsworkerv4configpatch-gp.cluster-api-runtime-extensions-nutanix
name: worker-config
- definitions:
- jsonPatches:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ spec:
patches:
- external:
discoverVariablesExtension: dockerclusterconfigvars-dv.cluster-api-runtime-extensions-nutanix
generateExtension: dockerclusterv3configpatch-gp.cluster-api-runtime-extensions-nutanix
generateExtension: dockerclusterv4configpatch-gp.cluster-api-runtime-extensions-nutanix
name: cluster-config
- external:
discoverVariablesExtension: dockerworkerconfigvars-dv.cluster-api-runtime-extensions-nutanix
generateExtension: dockerworkerv3configpatch-gp.cluster-api-runtime-extensions-nutanix
generateExtension: dockerworkerv4configpatch-gp.cluster-api-runtime-extensions-nutanix
name: worker-config
workers:
machineDeployments:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ spec:
patches:
- external:
discoverVariablesExtension: nutanixclusterconfigvars-dv.cluster-api-runtime-extensions-nutanix
generateExtension: nutanixclusterv3configpatch-gp.cluster-api-runtime-extensions-nutanix
generateExtension: nutanixclusterv4configpatch-gp.cluster-api-runtime-extensions-nutanix
name: cluster-config
- external:
discoverVariablesExtension: nutanixworkerconfigvars-dv.cluster-api-runtime-extensions-nutanix
generateExtension: nutanixworkerv3configpatch-gp.cluster-api-runtime-extensions-nutanix
generateExtension: nutanixworkerv4configpatch-gp.cluster-api-runtime-extensions-nutanix
name: worker-config
workers:
machineDeployments:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ The required values are shown below per provider.
patches:
- external:
discoverVariablesExtension: awsclusterconfigvars.cluster-api-runtime-extensions-nutanix
generateExtension: awsclusterv3configpatch.cluster-api-runtime-extensions-nutanix
generateExtension: awsclusterv4configpatch.cluster-api-runtime-extensions-nutanix
name: cluster-config
- external:
discoverVariablesExtension: awsworkerconfigvars.cluster-api-runtime-extensions-nutanix
generateExtension: awsworkerv3configpatch.cluster-api-runtime-extensions-nutanix
generateExtension: awsworkerv4configpatch.cluster-api-runtime-extensions-nutanix
name: worker-config
```

Expand All @@ -35,11 +35,11 @@ The required values are shown below per provider.
patches:
- external:
discoverVariablesExtension: nutanixclusterconfigvars.cluster-api-runtime-extensions-nutanix
generateExtension: nutanixclusterv3configpatch.cluster-api-runtime-extensions-nutanix
generateExtension: nutanixclusterv4configpatch.cluster-api-runtime-extensions-nutanix
name: cluster-config
- external:
discoverVariablesExtension: nutanixworkerconfigvars.cluster-api-runtime-extensions-nutanix
generateExtension: nutanixworkerv3configpatch.cluster-api-runtime-extensions-nutanix
generateExtension: nutanixworkerv4configpatch.cluster-api-runtime-extensions-nutanix
name: worker-config
```

Expand All @@ -49,11 +49,11 @@ The required values are shown below per provider.
patches:
- external:
discoverVariablesExtension: dockerclusterconfigvars.cluster-api-runtime-extensions-nutanix
generateExtension: dockerclusterv3configpatch.cluster-api-runtime-extensions-nutanix
generateExtension: dockerclusterv4configpatch.cluster-api-runtime-extensions-nutanix
name: cluster-config
- external:
discoverVariablesExtension: dockerworkerconfigvars.cluster-api-runtime-extensions-nutanix
generateExtension: dockerworkerv3configpatch.cluster-api-runtime-extensions-nutanix
generateExtension: dockerworkerv4configpatch.cluster-api-runtime-extensions-nutanix
name: worker-config
```

Expand All @@ -63,7 +63,7 @@ The required values are shown below per provider.
patches:
- external:
discoverVariablesExtension: genericclusterconfigvars.cluster-api-runtime-extensions-nutanix
generateExtension: genericclusterv3configpatch.cluster-api-runtime-extensions-nutanix
generateExtension: genericclusterv4configpatch.cluster-api-runtime-extensions-nutanix
name: cluster-config
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ patches:
value:
- name: "cluster-config"
external:
generateExtension: "awsclusterv3configpatch-gp.cluster-api-runtime-extensions-nutanix"
generateExtension: "awsclusterv4configpatch-gp.cluster-api-runtime-extensions-nutanix"
discoverVariablesExtension: "awsclusterconfigvars-dv.cluster-api-runtime-extensions-nutanix"
- name: "worker-config"
external:
generateExtension: "awsworkerv3configpatch-gp.cluster-api-runtime-extensions-nutanix"
generateExtension: "awsworkerv4configpatch-gp.cluster-api-runtime-extensions-nutanix"
discoverVariablesExtension: "awsworkerconfigvars-dv.cluster-api-runtime-extensions-nutanix"
- name: identityRef
definitions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ patches:
value:
- name: "cluster-config"
external:
generateExtension: "dockerclusterv3configpatch-gp.cluster-api-runtime-extensions-nutanix"
generateExtension: "dockerclusterv4configpatch-gp.cluster-api-runtime-extensions-nutanix"
discoverVariablesExtension: "dockerclusterconfigvars-dv.cluster-api-runtime-extensions-nutanix"
- name: "worker-config"
external:
generateExtension: "dockerworkerv3configpatch-gp.cluster-api-runtime-extensions-nutanix"
generateExtension: "dockerworkerv4configpatch-gp.cluster-api-runtime-extensions-nutanix"
discoverVariablesExtension: "dockerworkerconfigvars-dv.cluster-api-runtime-extensions-nutanix"

# BEGIN CIS patches
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ patches:
value:
- name: "cluster-config"
external:
generateExtension: "nutanixclusterv3configpatch-gp.cluster-api-runtime-extensions-nutanix"
generateExtension: "nutanixclusterv4configpatch-gp.cluster-api-runtime-extensions-nutanix"
discoverVariablesExtension: "nutanixclusterconfigvars-dv.cluster-api-runtime-extensions-nutanix"
- name: "worker-config"
external:
generateExtension: "nutanixworkerv3configpatch-gp.cluster-api-runtime-extensions-nutanix"
generateExtension: "nutanixworkerv4configpatch-gp.cluster-api-runtime-extensions-nutanix"
discoverVariablesExtension: "nutanixworkerconfigvars-dv.cluster-api-runtime-extensions-nutanix"

# BEGIN CIS patches
Expand Down
6 changes: 3 additions & 3 deletions pkg/handlers/aws/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
awsmutation "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/aws/mutation"
awsworkerconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/aws/workerconfig"
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/options"
v2awsmutation "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/v2/aws/mutation"
awsmutationvprev "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/v3/aws/mutation"
)

type Handlers struct{}
Expand All @@ -28,9 +28,9 @@ func (h *Handlers) AllHandlers(mgr manager.Manager) []handlers.Named {
awsclusterconfig.NewVariable(),
awsworkerconfig.NewVariable(),
awsmutation.MetaPatchHandler(mgr),
v2awsmutation.MetaPatchHandler(mgr),
awsmutationvprev.MetaPatchHandler(mgr),
awsmutation.MetaWorkerPatchHandler(mgr),
v2awsmutation.MetaWorkerPatchHandler(mgr),
awsmutationvprev.MetaWorkerPatchHandler(mgr),
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/handlers/aws/mutation/metapatch_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func MetaPatchHandler(mgr manager.Manager) handlers.Named {
patchHandlers = append(patchHandlers, genericmutation.ControlPlaneMetaMutators()...)

return mutation.NewMetaGeneratePatchesHandler(
"awsClusterV3ConfigPatch",
"awsClusterV4ConfigPatch",
mgr.GetClient(),
patchHandlers...,
)
Expand All @@ -52,7 +52,7 @@ func MetaWorkerPatchHandler(mgr manager.Manager) handlers.Named {
patchHandlers = append(patchHandlers, genericmutation.WorkerMetaMutators()...)

return mutation.NewMetaGeneratePatchesHandler(
"awsWorkerv3ConfigPatch",
"awsWorkerV4ConfigPatch",
mgr.GetClient(),
patchHandlers...,
)
Expand Down
6 changes: 3 additions & 3 deletions pkg/handlers/docker/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
dockermutation "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/docker/mutation"
dockerworkerconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/docker/workerconfig"
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/options"
v2dockermutation "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/v2/docker/mutation"
dockermutationvprev "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/v3/docker/mutation"
)

type Handlers struct{}
Expand All @@ -28,9 +28,9 @@ func (h *Handlers) AllHandlers(mgr manager.Manager) []handlers.Named {
dockerclusterconfig.NewVariable(),
dockerworkerconfig.NewVariable(),
dockermutation.MetaPatchHandler(mgr),
v2dockermutation.MetaPatchHandler(mgr),
dockermutationvprev.MetaPatchHandler(mgr),
dockermutation.MetaWorkerPatchHandler(mgr),
v2dockermutation.MetaWorkerPatchHandler(mgr),
dockermutationvprev.MetaWorkerPatchHandler(mgr),
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/handlers/docker/mutation/metapatch_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func MetaPatchHandler(mgr manager.Manager) handlers.Named {
patchHandlers = append(patchHandlers, genericmutation.ControlPlaneMetaMutators()...)

return mutation.NewMetaGeneratePatchesHandler(
"dockerClusterV3ConfigPatch",
"dockerClusterV4ConfigPatch",
mgr.GetClient(),
patchHandlers...,
)
Expand All @@ -35,7 +35,7 @@ func MetaWorkerPatchHandler(mgr manager.Manager) handlers.Named {
patchHandlers = append(patchHandlers, genericmutation.WorkerMetaMutators()...)

return mutation.NewMetaGeneratePatchesHandler(
"dockerWorkerV3ConfigPatch",
"dockerWorkerV4ConfigPatch",
mgr.GetClient(),
patchHandlers...,
)
Expand Down
6 changes: 3 additions & 3 deletions pkg/handlers/generic/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers"
genericclusterconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/clusterconfig"
genericmutation "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/mutation"
v2genericmutation "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/v2/generic/mutation"
genericmutationvprev "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/v3/generic/mutation"
)

type Handlers struct{}
Expand All @@ -22,8 +22,8 @@ func (h *Handlers) AllHandlers(mgr manager.Manager) []handlers.Named {
return []handlers.Named{
genericclusterconfig.NewVariable(),
genericmutation.MetaPatchHandler(mgr),
v2genericmutation.MetaPatchHandler(mgr),
genericmutationvprev.MetaPatchHandler(mgr),
genericmutation.MetaWorkerPatchHandler(mgr),
v2genericmutation.MetaWorkerPatchHandler(mgr),
genericmutationvprev.MetaWorkerPatchHandler(mgr),
}
}
4 changes: 2 additions & 2 deletions pkg/handlers/generic/mutation/metapatch_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func MetaPatchHandler(mgr manager.Manager) handlers.Named {
patchHandlers := MetaMutators(mgr)
patchHandlers = append(patchHandlers, ControlPlaneMetaMutators()...)
return mutation.NewMetaGeneratePatchesHandler(
"genericClusterV3ConfigPatch",
"genericClusterV4ConfigPatch",
mgr.GetClient(),
patchHandlers...,
)
Expand All @@ -26,7 +26,7 @@ func MetaWorkerPatchHandler(mgr manager.Manager) handlers.Named {
patchHandlers := WorkerMetaMutators()

return mutation.NewMetaGeneratePatchesHandler(
"genericWorkerV3ConfigPatch",
"genericWorkerV4ConfigPatch",
mgr.GetClient(),
patchHandlers...,
)
Expand Down
22 changes: 7 additions & 15 deletions pkg/handlers/nutanix/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,26 @@ import (
nutanixmutation "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/nutanix/mutation"
nutanixworkerconfig "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/nutanix/workerconfig"
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/options"
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/v2/generic/mutation/controlplanevirtualip"
v2nutanixmutation "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/v2/nutanix/mutation"
nutanixmutationvprev "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/handlers/v3/nutanix/mutation"
)

type Handlers struct {
// kubeVIPConfig holds the configuration for the kube-vip control-plane virtual IP.
controlPlaneVirtualIPConfig *controlplanevirtualip.Config
}
type Handlers struct{}

func New(
globalOptions *options.GlobalOptions,
_ *options.GlobalOptions,
) *Handlers {
return &Handlers{
controlPlaneVirtualIPConfig: &controlplanevirtualip.Config{GlobalOptions: globalOptions},
}
return &Handlers{}
}

func (h *Handlers) AllHandlers(mgr manager.Manager) []handlers.Named {
return []handlers.Named{
nutanixclusterconfig.NewVariable(),
nutanixworkerconfig.NewVariable(),
nutanixmutation.MetaPatchHandler(mgr),
v2nutanixmutation.MetaPatchHandler(mgr, h.controlPlaneVirtualIPConfig),
nutanixmutationvprev.MetaPatchHandler(mgr),
nutanixmutation.MetaWorkerPatchHandler(mgr),
v2nutanixmutation.MetaWorkerPatchHandler(mgr),
nutanixmutationvprev.MetaWorkerPatchHandler(mgr),
}
}

func (h *Handlers) AddFlags(flagSet *pflag.FlagSet) {
h.controlPlaneVirtualIPConfig.AddFlags("nutanix", flagSet)
}
func (h *Handlers) AddFlags(_ *pflag.FlagSet) {}
4 changes: 2 additions & 2 deletions pkg/handlers/nutanix/mutation/metapatch_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func MetaPatchHandler(mgr manager.Manager) handlers.Named {
patchHandlers = append(patchHandlers, genericmutation.ControlPlaneMetaMutators()...)

return mutation.NewMetaGeneratePatchesHandler(
"nutanixClusterV3ConfigPatch",
"nutanixClusterV4ConfigPatch",
mgr.GetClient(),
patchHandlers...,
)
Expand All @@ -41,7 +41,7 @@ func MetaWorkerPatchHandler(mgr manager.Manager) handlers.Named {
patchHandlers = append(patchHandlers, genericmutation.WorkerMetaMutators()...)

return mutation.NewMetaGeneratePatchesHandler(
"nutanixWorkerV3ConfigPatch",
"nutanixWorkerV4ConfigPatch",
mgr.GetClient(),
patchHandlers...,
)
Expand Down
Loading