gridsuite / deployment

GridSuite deployment configuration
Mozilla Public License 2.0
5 stars 7 forks source link

[k8s] Update deprecated `patchesJson6902`, `patchesStrategicMerge` and `bases` #435

Closed Tristan-WorkGH closed 3 weeks ago

Tristan-WorkGH commented 1 month ago

Informations

https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/bases/

The bases field was deprecated in v2.1.0. [...] You can run kustomize edit fix to automatically convert bases to resources.

https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/patches/

https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/patchesjson6902/

Please move your patchesJson6902 into the patches field. This field supports patchesJson6902, but with slightly different syntax. You can run kustomize edit fix to automatically convert patchesJson6902 to patches.

https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/patchesstrategicmerge/

Please move your patchesStrategicMerge into the patches field. This field supports patchesStrategicMerge, but with slightly different syntax. You can run kustomize edit fix to automatically convert patchesStrategicMerge to patches.

An explanation of the difference at https://stackoverflow.com/a/63605421

patchesStrategicMerge requires a duplicate structure of the kubernetes resource to identify the base resource that is being patched followed by the modified portion of the spec to denote what gets changed (or deleted). [...] The patches directive is newer and accepts more elements (annotation selector and label selector as well). In addition, namespace and name can be regexes. The target for patches can match more than one resource, all of which will be patched. In addition, with patches, it will attempt to parse patch files as a Json6902 patch, and if that does not work, it will fall back to attempting the patch as a strategic merge. Therefore, in many cases patches can obviate the need of using patchesStrategicMerge as well.


Update

CLI version used:

$ kustomize version
v5.0.3
live/local ```shell user@pc:.../deployment/k8s$ cd live/local user@pc:.../deployment/k8s/live/local$ kustomize edit fix # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. Fixed fields: patchesJson6902 -> patches patchesStrategicMerge -> patches commonLabels -> labels # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. ```
live/azure-dev ```shell user@pc:.../deployment/k8s/live/local$ cd ../azure-dev user@pc:.../deployment/k8s/live/azure-dev$ kustomize edit fix # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'patchesJson6902' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'patchesStrategicMerge' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'patchesStrategicMerge' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically. Fixed fields: patchesJson6902 -> patches patchesStrategicMerge -> patches commonLabels -> labels # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'patchesStrategicMerge' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'patchesStrategicMerge' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically. ```
live/azure-integ ```shell user@pc:.../deployment/k8s/live/azure-dev$ cd ../azure-integ user@pc:.../deployment/k8s/live/azure-integ$ kustomize edit fix # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'patchesJson6902' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'patchesStrategicMerge' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'patchesStrategicMerge' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically. Fixed fields: patchesJson6902 -> patches patchesStrategicMerge -> patches commonLabels -> labels # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'patchesStrategicMerge' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'patchesStrategicMerge' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically. ```
components/gridsuite ```shell user@pc:.../deployment/k8s/live/azure-integ$ cd ../../components/gridsuite user@pc:.../deployment/k8s/components/gridsuite$ kustomize edit fix Fixed fields: patchesJson6902 -> patches patchesStrategicMerge -> patches commonLabels -> labels ```
components/azure ```shell user@pc:.../deployment/k8s/components/gridsuite$ cd ../azure user@pc:.../deployment/k8s/components/azure$ kustomize edit fix # Warning: 'patchesStrategicMerge' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically. Fixed fields: patchesJson6902 -> patches patchesStrategicMerge -> patches commonLabels -> labels Warning: 'Fixed' kustomization now produces the error when running `kustomize build`: no matches for Id Deployment.v1.apps/case-server.[noNs]; failed to find unique target for patch Deployment.v1.apps/case-server.[noNs] ```
overlays/azure ```shell user@pc:.../deployment/k8s/components/azure$ cd ../../overlays/azure user@pc:.../deployment/k8s/overlays/azure$ kustomize edit fix # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'patchesStrategicMerge' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. Fixed fields: patchesJson6902 -> patches patchesStrategicMerge -> patches commonLabels -> labels # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. ```
bases/admingridsuite ```shell user@pc:.../deployment/k8s/overlays/azure$ cd ../../bases/admingridsuite user@pc:.../deployment/k8s/bases/admingridsuite$ kustomize edit fix # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. Fixed fields: patchesJson6902 -> patches patchesStrategicMerge -> patches commonLabels -> labels # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. ```
bases/gridsuite ```shell user@pc:.../deployment/k8s/bases/admingridsuite$ cd ../gridsuite user@pc:.../deployment/k8s/bases/gridsuite$ kustomize edit fix # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. Fixed fields: patchesJson6902 -> patches patchesStrategicMerge -> patches commonLabels -> labels ```
bases/gridstudy ```shell user@pc:.../deployment/k8s/bases/gridsuite$ cd ../gridstudy user@pc:.../deployment/k8s/bases/gridstudy$ kustomize edit fix # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. Fixed fields: patchesJson6902 -> patches patchesStrategicMerge -> patches commonLabels -> labels ```
bases/griddyna ```shell user@pc:.../deployment/k8s/bases/gridstudy$ cd ../griddyna user@pc:.../deployment/k8s/bases/griddyna$ kustomize edit fix # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. Fixed fields: patchesJson6902 -> patches patchesStrategicMerge -> patches commonLabels -> labels ```
bases/gridmerge ```shell user@pc:.../deployment/k8s/bases/griddyna$ cd ../gridmerge user@pc:.../deployment/k8s/bases/gridmerge$ kustomize edit fix # Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically. Fixed fields: patchesJson6902 -> patches patchesStrategicMerge -> patches commonLabels -> labels ```
resources/common ```shell user@pc:.../deployment/k8s/bases/gridmerge$ cd ../../resources/common user@pc:.../deployment/k8s/resources/common$ kustomize edit fix Fixed fields: patchesJson6902 -> patches patchesStrategicMerge -> patches commonLabels -> labels ```
resources/admin ```shell user@pc:.../deployment/k8s/resources/common$ cd ../admin user@pc:.../deployment/k8s/resources/admin$ kustomize edit fix Fixed fields: patchesJson6902 -> patches patchesStrategicMerge -> patches commonLabels -> labels ```
resources/dynamic-mapping ```shell user@pc:.../deployment/k8s/resources/admin$ cd ../dynamic-mapping user@pc:.../deployment/k8s/resources/dynamic-mapping$ kustomize edit fix Fixed fields: patchesJson6902 -> patches patchesStrategicMerge -> patches commonLabels -> labels ```
resources/merging ```shell user@pc:.../deployment/k8s/resources/dynamic-mapping$ cd ../merging user@pc:.../deployment/k8s/resources/merging$ kustomize edit fix Fixed fields: patchesJson6902 -> patches patchesStrategicMerge -> patches commonLabels -> labels ```
resources/study ```shell user@pc:.../deployment/k8s/resources/merging$ cd ../study user@pc:.../deployment/k8s/resources/study$ kustomize edit fix Fixed fields: patchesJson6902 -> patches patchesStrategicMerge -> patches commonLabels -> labels ```

[!NOTE]
The warning about converting vars has been remove from CLI output to not pollute logs.

To convert vars -> replacements, run the command `kustomize edit fix --vars`

WARNING: Converting vars to replacements will potentially overwrite many resource files 
and the resulting files may not produce the same output when `kustomize build` is run. 
We recommend doing this in a clean git repository where the change is easy to undo.

It has been run on another branch but no modifications has been observed.

[!IMPORTANT] A problem has been reported during the update of one file:

user@pc:.../deployment/k8s/components/azure$ kustomize edit fix
[...]
Warning: 'Fixed' kustomization now produces the error when running `kustomize build`: no matches for Id Deployment.v1.apps/case-server.[noNs]; failed to find unique target for patch Deployment.v1.apps/case-server.[noNs]

But no error when building with kubectl kustomize live/azure-dev.


Check no regression

user@pc:.../deployment/k8s$ git checkout main
Basculement sur la branche 'main'
Votre branche est à jour avec 'origin/main'.
user@pc:.../deployment/k8s$ mkdir main
user@pc:.../deployment/k8s$ kubectl kustomize live/local -o ./main/local.yml
# Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
# Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
# Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
user@pc:.../deployment/k8s$ kubectl kustomize live/azure-dev -o ./main/azuredev.yml
# Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
# Warning: 'patchesJson6902' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
# Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
# Warning: 'patchesStrategicMerge' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
# Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
# Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
# Warning: 'patchesStrategicMerge' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
user@pc:.../deployment/k8s$ kubectl kustomize live/azure-integ -o ./main/azureinteg.yml
# Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
# Warning: 'patchesJson6902' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
# Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
# Warning: 'patchesStrategicMerge' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
# Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
# Warning: 'bases' is deprecated. Please use 'resources' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
# Warning: 'patchesStrategicMerge' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
user@pc:.../deployment/k8s$ git checkout k8s/update/patches
Basculement sur la branche 'k8s/update/patches'
user@pc:.../deployment/k8s$ mkdir new
user@pc:.../deployment/k8s$ kubectl kustomize live/local -o ./new/local.yml
user@pc:.../deployment/k8s$ kubectl kustomize live/azure-dev -o ./new/azuredev.yml
user@pc:.../deployment/k8s$ kubectl kustomize live/azure-integ -o ./new/azureinteg.yml
user@pc:.../deployment/k8s$ diff ./main/local.yml ./new/local.yml
user@pc:.../deployment/k8s$ diff ./main/azuredev.yml ./new/azuredev.yml
user@pc:.../deployment/k8s$ diff ./main/azureinteg.yml ./new/azureinteg.yml
user@pc:.../deployment/k8s$ rm -rf ./main ./new
jonenst commented 1 month ago

maybe the duplicated label app:gridsuite can be removed ? not sure if it needs to be in a component to be applied after other resources have been added.

EDIT: we can't remove commonLabels from the components (otherwise it doesn't get applied to the downstream resources) but we can remove it from the resources

jonenst commented 1 month ago

does this have any effect on downstream users that import from this repo ?

Tristan-WorkGH commented 1 month ago

@jonenst commented on Oct 3, 2024, 8:36 PM GMT+2:

does this have any effect on downstream users that import from this repo ?

Haven't try for now. Will do that before merging.

Tristan-WorkGH commented 1 month ago

@Tristan-WorkGH commented on Oct 3, 2024, 8:42 PM GMT+2:

@jonenst commented on Oct 3, 2024, 8:36 PM GMT+2:

does this have any effect on downstream users that import from this repo ?

Haven't try for now. Will do that before merging.

Tested and no problems found.