Skip to content

Different versions of K8S support different cronjob versions and policy version#116

Open
wuchang0201 wants to merge 1 commit intoalipay:mainfrom
wuchang0201:fix_policy_version
Open

Different versions of K8S support different cronjob versions and policy version#116
wuchang0201 wants to merge 1 commit intoalipay:mainfrom
wuchang0201:fix_policy_version

Conversation

@wuchang0201
Copy link
Copy Markdown
Contributor

if kubernetes version < 1.21 and >1.19,cronjob and policy version should be batch/v1beta1

@wuchang0201
Copy link
Copy Markdown
Contributor Author

#93

#42

@wuchang0201
Copy link
Copy Markdown
Contributor Author

example:
image

@@ -1,8 +1,12 @@
{{- if .Values.enableAuditApiserver }}
{{- $policyVersion := default "v1beta1" -}}
{{- if semverCompare ">=1.21-0" .Capabilities.KubeVersion.GitVersion -}}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What version does "semverCompare" represent?
if it represent the version of kubernetes, i can not understand the "semver" ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

"SemverCompare" is a built-in function
image

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Has these code been tested?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Has these code been tested?

Yes, there are test result images above it

{{- if semverCompare ">=1.21-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: batch/v1
{{- else if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: batch/v1beta1
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there any other diff with "v1beta1" and "v1" of CronJob?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is there any other diff with "v1beta1" and "v1" of CronJob?

From k8s 1.19 to 1.29, there are only v1beta1 and v1

README-zh_CN.md Outdated
# install lunettes
# 该过程开启apiserver的审计功能,apiserver会发生重启
helm upgrade --install lunettes oci://registry-1.docker.io/lunettes/lunettes-chart --version [version]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please remove useless blank lines to avoid conflicts with other pr merges

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Please remove useless blank lines to avoid conflicts with other pr merges

done

```bash
helm upgrade --install lunettes oci://registry-1.docker.io/lunettes/lunettes-chart --version [version]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please remove useless blank lines to avoid conflicts with other pr merges

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Please remove useless blank lines to avoid conflicts with other pr merges

done

@@ -1,4 +1,8 @@
{{- if semverCompare ">=1.21-0" .Capabilities.KubeVersion.GitVersion -}}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why not use the same method here as in the previous policyversion?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Why not use the same method here as in the previous policyversion?

Directly using nested yaml files will result in an error and requires passing variables

@@ -1,8 +1,12 @@
{{- if .Values.enableAuditApiserver }}
{{- $policyVersion := default "v1beta1" -}}
{{- if semverCompare ">=1.21-0" .Capabilities.KubeVersion.GitVersion -}}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Has these code been tested?

@wuchang0201 wuchang0201 force-pushed the fix_policy_version branch from 029f9e8 to 6e3551b Compare May 7, 2024 02:00
Copy link
Copy Markdown
Collaborator

@linuzb linuzb left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants