Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating outdated Kustomize syntax to be in line with Kustomize v5 syntax #67

Merged

Conversation

KillianGolds
Copy link

@KillianGolds KillianGolds commented Aug 7, 2024

Motivation

The main motivation for this update is to keep our manifests up to date with Kustomize v5. This ensures that we are using the latest syntax, which improves the compatibility and maintainability of our Kubernetes configurations.

Modifications

1. Replacements Section:

  • Added a replacements section to dynamically change values in the deployment configuration.
  • Corrected the field path to ensure the replacement does not break when patches are used.
  • Specifically, it replaces the environment variable value in the model-mesh deployment with the service name.

Old Syntax:

vars:
  - name: MM_SERVICE_NAME
    objref:
      kind: Service
      name: model-mesh
      apiVersion: v1
    fieldref:
      fieldpath: metadata.name

New Syntax:

replacements:
- source:
    kind: Service
    name: model-mesh
    fieldPath: metadata.name
  targets:
  - select:
      kind: Deployment
      name: model-mesh
    fieldPaths:
    - spec.template.spec.containers.0.env.[name=MM_SERVICE_NAME].value

2. Patch Paths:

  • I updated the commented-out patches section to use the correct path syntax when they are needed.
# patches:
#  - path: patches/etcd.yaml
#  - path: patches/logger.yaml
#  - path: patches/tls.yaml
#  - path: patches/uds.yaml
#  - path: patches/max_msg_size.yaml
#  - path: patches/prometheus_metrics.yaml

How I Tested

To ensure the correctness of these changes, the following steps were taken:

  1. Ran the kustomize build command on the original manifests to produce the current state of the resources.
  2. Updated to Kustomize v5 labels.
  3. Ran the kustomize build command again on the updated manifests.
  4. Compared the output of the kustomize build command from both the original and updated manifests.
  5. Verified that there was no difference between the outputs.

Gist of all kustomize build pre-changes and post-changes: https://gist.github.com/KillianGolds/522e22734d547a90e69a619498ab71ca

Result

These changes ensure that our Kustomize labels are up to date with version 5 syntax. Everything works as it should, with no changes to functionality other than updated syntax and corrected field paths for replacements and patches.

Copy link

openshift-ci bot commented Aug 7, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@KillianGolds KillianGolds marked this pull request as ready for review August 7, 2024 13:30
@KillianGolds
Copy link
Author

/retest

Copy link
Member

@terrytangyuan terrytangyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did you upgrade kustomize from v4 to v5?

@terrytangyuan
Copy link
Member

I see. We are already using v5 but we are just using outdated syntax. Could you update the title/description to clarify that?

@KillianGolds KillianGolds changed the title Updated deprecated manifest labels for kustomize v5 upgrade Updating outdated Kustomize syntax to be in line with Kustomize v5 syntax Aug 13, 2024
Copy link
Member

@terrytangyuan terrytangyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Copy link

openshift-ci bot commented Aug 13, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: KillianGolds, terrytangyuan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 13ae7c8 into opendatahub-io:main Aug 13, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants