-
Notifications
You must be signed in to change notification settings - Fork 403
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
[Feature] Add Kubernetes manifest validation in pre-commit. #2380
Conversation
Signed-off-by: leoliao <leoyeepaa@gmail.com>
Signed-off-by: Leo Liao <93932709+LeoLiao123@users.noreply.github.com>
Signed-off-by: Leo Liao <93932709+LeoLiao123@users.noreply.github.com>
Signed-off-by: Leo Liao <93932709+LeoLiao123@users.noreply.github.com>
scripts/validate-helm.sh
Outdated
curl -o "${KUBECONFORM_INSTALL}/crd2schema.py" https://raw.githubusercontent.com/yannh/kubeconform/master/scripts/openapi2jsonschema.py | ||
SCRIPT_PATH="${KUBECONFORM_INSTALL}/crd2schema.py" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can consider store this script in our repo so that we don't need to download it everytime.
curl -L https://github.com/yannh/kubeconform/releases/latest/download/kubeconform-linux-amd64.tar.gz | tar xz -C "${KUBECONFORM_INSTALL}" | ||
curl -o "${KUBECONFORM_INSTALL}/crd2schema.py" https://raw.githubusercontent.com/yannh/kubeconform/master/scripts/openapi2jsonschema.py | ||
SCRIPT_PATH="${KUBECONFORM_INSTALL}/crd2schema.py" | ||
RAYCLUSTER_CRD_PATH="$KUBERAY_HOME/ray-operator/config/crd/bases/ray.io_rayclusters.yaml" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why only RayCluster? How about also validate RayJob and RayService?
I think this can be done in either this PR or follow-up PRs.
he install info at 3. Store the at 4. Call , 5. check the version of in Signed-off-by: leoliao <leoyeepaa@gmail.com>
Signed-off-by: leoliao <leoyeepaa@gmail.com>
Signed-off-by: Leo Liao <93932709+LeoLiao123@users.noreply.github.com>
.pre-commit-config.yaml
Outdated
|
||
- repo: local | ||
hooks: | ||
- id: validate-helm-charts | ||
name: validate helm charts with kubeconform | ||
entry: bash -c 'version="0.6.7"; [ "$(kubeconform --v | grep -oP "(?<=v)[\d\.]+")" = "$version" ] || echo "kubeconform version is not $version"; bash scripts/validate-helm.sh' | ||
language: system | ||
pass_filenames: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signed-off-by: leoliao <leoyeepaa@gmail.com>
Signed-off-by: leoliao <leoyeepaa@gmail.com>
Signed-off-by: leoliao <leoyeepaa@gmail.com>
.pre-commit-config.yaml
Outdated
hooks: | ||
- id: check-kubeconform-version | ||
name: kubeconform version check | ||
entry: bash -c 'version="0.6.7"; [ "$(kubeconform -v | grep -oP "(?<=v)[\d\.]+")" = "$version" ] || { echo "kubeconform version is not $version"; }' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you replace this line with bash -c 'version="0.6.7"; [ "$(kubeconform -v | grep -oP "(?<=v)[\d\.]+")" = "$version" ] || { echo "kubeconform version is not $version"; exit 1; }'
Also I find that I made a mistake in line 34, can you replace it with bash -c 'version="1.60.3"; [ "$(golangci-lint --version | grep -oP "(?<=version )[\d\.]+")" = "$version" ] || { echo "golangci-lint version is not $version"; exit 1; }'
? Thanks.
Otherwise LGTM.
…alidation if the version is not validated. Signed-off-by: leoliao <leoyeepaa@gmail.com>
Signed-off-by: leoliao <leoyeepaa@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LeoLiao123 @MortalHappiness we only have RayCluster Helm chart. |
@kevin85421 Oops I didn't notice that. Thanks. |
Why are these changes needed?
To resolve issue #2254, the absence of a Kubernetes manifest validation process caused the errors listed in the issue when deploying the Helm Chart. During validation, I also discovered that running
helm template ./
inhelm-chart/ray-cluster
resulted in.template.spec.containers.ports
being set tonull
(which should either be omitted or set to an empty list[]
). I have fixed this issue as well.Related issue number
Closes #2254
#2174
#2239
Issue Reproduction and Manual Validation Results
I reproduced the error from Issue #2174. Running
helm template ./
within thehelm-chart/ray-cluster
directory generates the following output:After validation, the following output is generated:
If we consider the case mentioned earlier where
.template.spec.containers.ports
is set tonull
:After validation, the following output is generated:
Checks