From c7db5039b59aef0068929b76472337d9ce032cbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=91=B8=E9=B1=BC=E5=96=B5?= Date: Sun, 8 Oct 2023 23:42:10 +0800 Subject: [PATCH] refactor: create yurt-iot-dock helm chart (#1717) * fix: crd generation for yurtappoverriders Signed-off-by: LavenderQAQ * refactor: create yurt-iot-dock helm chart Signed-off-by: LavenderQAQ --------- Signed-off-by: LavenderQAQ --- charts/yurt-iot-dock/.helmignore | 23 ++ charts/yurt-iot-dock/Chart.yaml | 24 ++ .../crds/iot.openyurt.io_deviceprofiles.yaml | 0 .../crds/iot.openyurt.io_devices.yaml | 0 .../crds/iot.openyurt.io_deviceservices.yaml | 0 charts/yurt-iot-dock/templates/_helpers.tpl | 62 +++++ .../yurt-iot-dock-auto-generated.yaml} | 0 charts/yurt-iot-dock/values.yaml | 5 + .../apps.openyurt.io_yurtappoverriders.yaml | 222 +++++++++--------- hack/lib/sync-charts.sh | 11 + hack/make-rules/kustomize_to_chart.sh | 11 +- 11 files changed, 244 insertions(+), 114 deletions(-) create mode 100644 charts/yurt-iot-dock/.helmignore create mode 100644 charts/yurt-iot-dock/Chart.yaml rename charts/{yurt-manager => yurt-iot-dock}/crds/iot.openyurt.io_deviceprofiles.yaml (100%) rename charts/{yurt-manager => yurt-iot-dock}/crds/iot.openyurt.io_devices.yaml (100%) rename charts/{yurt-manager => yurt-iot-dock}/crds/iot.openyurt.io_deviceservices.yaml (100%) create mode 100644 charts/yurt-iot-dock/templates/_helpers.tpl rename charts/{yurt-manager/templates/yurt-manager-iot.yaml => yurt-iot-dock/templates/yurt-iot-dock-auto-generated.yaml} (100%) create mode 100644 charts/yurt-iot-dock/values.yaml diff --git a/charts/yurt-iot-dock/.helmignore b/charts/yurt-iot-dock/.helmignore new file mode 100644 index 00000000000..0e8a0eb36f4 --- /dev/null +++ b/charts/yurt-iot-dock/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/yurt-iot-dock/Chart.yaml b/charts/yurt-iot-dock/Chart.yaml new file mode 100644 index 00000000000..d8908d70368 --- /dev/null +++ b/charts/yurt-iot-dock/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: yurt-iot-dock +description: A Helm chart for OpenYurt yurt-iot-dock component. + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 1.4.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.4.0" diff --git a/charts/yurt-manager/crds/iot.openyurt.io_deviceprofiles.yaml b/charts/yurt-iot-dock/crds/iot.openyurt.io_deviceprofiles.yaml similarity index 100% rename from charts/yurt-manager/crds/iot.openyurt.io_deviceprofiles.yaml rename to charts/yurt-iot-dock/crds/iot.openyurt.io_deviceprofiles.yaml diff --git a/charts/yurt-manager/crds/iot.openyurt.io_devices.yaml b/charts/yurt-iot-dock/crds/iot.openyurt.io_devices.yaml similarity index 100% rename from charts/yurt-manager/crds/iot.openyurt.io_devices.yaml rename to charts/yurt-iot-dock/crds/iot.openyurt.io_devices.yaml diff --git a/charts/yurt-manager/crds/iot.openyurt.io_deviceservices.yaml b/charts/yurt-iot-dock/crds/iot.openyurt.io_deviceservices.yaml similarity index 100% rename from charts/yurt-manager/crds/iot.openyurt.io_deviceservices.yaml rename to charts/yurt-iot-dock/crds/iot.openyurt.io_deviceservices.yaml diff --git a/charts/yurt-iot-dock/templates/_helpers.tpl b/charts/yurt-iot-dock/templates/_helpers.tpl new file mode 100644 index 00000000000..bf061172ab3 --- /dev/null +++ b/charts/yurt-iot-dock/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "yurt-iot-dock.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "yurt-iot-dock.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "yurt-iot-dock.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "yurt-iot-dock.labels" -}} +helm.sh/chart: {{ include "yurt-iot-dock.chart" . }} +{{ include "yurt-iot-dock.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "yurt-iot-dock.selectorLabels" -}} +app.kubernetes.io/name: {{ include "yurt-iot-dock.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "yurt-iot-dock.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "yurt-iot-dock.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/yurt-manager/templates/yurt-manager-iot.yaml b/charts/yurt-iot-dock/templates/yurt-iot-dock-auto-generated.yaml similarity index 100% rename from charts/yurt-manager/templates/yurt-manager-iot.yaml rename to charts/yurt-iot-dock/templates/yurt-iot-dock-auto-generated.yaml diff --git a/charts/yurt-iot-dock/values.yaml b/charts/yurt-iot-dock/values.yaml new file mode 100644 index 00000000000..3849c8dd784 --- /dev/null +++ b/charts/yurt-iot-dock/values.yaml @@ -0,0 +1,5 @@ +# Default values for yurt-iot-dock. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +# The yurt-iot-dock is controlled by platformadmin CR. Do not need to specify values at this place! \ No newline at end of file diff --git a/charts/yurt-manager/crds/apps.openyurt.io_yurtappoverriders.yaml b/charts/yurt-manager/crds/apps.openyurt.io_yurtappoverriders.yaml index d2b08cbd0a0..e8af4427ba3 100644 --- a/charts/yurt-manager/crds/apps.openyurt.io_yurtappoverriders.yaml +++ b/charts/yurt-manager/crds/apps.openyurt.io_yurtappoverriders.yaml @@ -12,130 +12,130 @@ spec: listKind: YurtAppOverriderList plural: yurtappoverriders shortNames: - - yao + - yao singular: yurtappoverrider scope: Namespaced versions: - - additionalPrinterColumns: - - description: The subject kind of this overrider. - jsonPath: .subject.kind - name: Subject - type: string - - description: The subject name of this overrider. - jsonPath: .subject.name - name: Name - type: string - - description: CreationTimestamp is a timestamp representing the server time when - this object was created. It is not guaranteed to be set in happens-before - order across separate operations. Clients may not set this value. It is represented - in RFC3339 form and is in UTC. - jsonPath: .metadata.creationTimestamp - name: AGE - type: date - name: v1alpha1 - schema: - openAPIV3Schema: - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation + - additionalPrinterColumns: + - description: The subject kind of this overrider. + jsonPath: .subject.kind + name: Subject + type: string + - description: The subject name of this overrider. + jsonPath: .subject.name + name: Name + type: string + - description: CreationTimestamp is a timestamp representing the server time when + this object was created. It is not guaranteed to be set in happens-before + order across separate operations. Clients may not set this value. It is represented + in RFC3339 form and is in UTC. + jsonPath: .metadata.creationTimestamp + name: AGE + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - entries: - items: - description: Describe detailed multi-region configuration of the subject - Entry describe a set of nodepools and their shared or identical configurations - properties: + type: string + entries: + items: + description: Describe detailed multi-region configuration of the subject + Entry describe a set of nodepools and their shared or identical configurations + properties: + items: + items: + description: Item represents configuration to be injected. Only + one of its members may be specified. + properties: + image: + description: ImageItem specifies the corresponding container + and the claimed image + properties: + containerName: + description: ContainerName represents name of the container + in which the Image will be replaced + type: string + imageClaim: + description: ImageClaim represents the claimed image name + which is injected into the container above + type: string + required: + - containerName + - imageClaim + type: object + replicas: + format: int32 + type: integer + type: object + type: array + patches: + description: Convert Patch struct into json patch operation + items: + properties: + operation: + description: Operation represents the operation + enum: + - add + - remove + - replace + type: string + path: + description: Path represents the path in the json patch + type: string + value: + description: Indicates the value of json patch + x-kubernetes-preserve-unknown-fields: true + required: + - operation + - path + type: object + type: array + pools: items: - items: - description: Item represents configuration to be injected. Only - one of its members may be specified. - properties: - image: - description: ImageItem specifies the corresponding container - and the claimed image - properties: - containerName: - description: ContainerName represents name of the container - in which the Image will be replaced - type: string - imageClaim: - description: ImageClaim represents the claimed image name - which is injected into the container above - type: string - required: - - containerName - - imageClaim - type: object - replicas: - format: int32 - type: integer - type: object - type: array - patches: - description: Convert Patch struct into json patch operation - items: - properties: - operation: - description: Operation represents the operation - enum: - - add - - remove - - replace - type: string - path: - description: Path represents the path in the json patch - type: string - value: - description: Indicates the value of json patch - x-kubernetes-preserve-unknown-fields: true - required: - - operation - - path - type: object - type: array - pools: - items: - type: string - type: array - required: - - pools - type: object - type: array - kind: - description: 'Kind is a string value representing the REST resource this + type: string + type: array + required: + - pools + type: object + type: array + kind: + description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - subject: - description: Describe the object Entries belongs - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation + type: string + metadata: + type: object + subject: + description: Describe the object Entries belongs + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource + type: string + kind: + description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - name: - description: Name is the name of YurtAppSet or YurtAppDaemon - type: string - required: - - name - type: object - required: - - entries - - subject - type: object - served: true - storage: true - subresources: {} + type: string + name: + description: Name is the name of YurtAppSet or YurtAppDaemon + type: string + required: + - name + type: object + required: + - entries + - subject + type: object + served: true + storage: true + subresources: {} status: acceptedNames: kind: "" diff --git a/hack/lib/sync-charts.sh b/hack/lib/sync-charts.sh index 7a4fad7d250..bc28d86e859 100644 --- a/hack/lib/sync-charts.sh +++ b/hack/lib/sync-charts.sh @@ -58,11 +58,22 @@ else mkdir -p openyurt-helm/charts/yurthub fi +echo "clear openyurt-helm charts/yurt-iot-dock" + +if [ -d "openyurt-helm/charts/yurt-iot-dock" ] +then + echo "charts yurt-iot-dock exists, remove it" + rm -r openyurt-helm/charts/yurt-iot-dock/* +else + mkdir -p openyurt-helm/charts/yurt-iot-dock +fi + echo "copy folder openyurt/charts to openyurt-helm/charts" cp -R openyurt/charts/yurt-coordinator/* openyurt-helm/charts/yurt-coordinator/ cp -R openyurt/charts/yurt-manager/* openyurt-helm/charts/yurt-manager/ cp -R openyurt/charts/yurthub/* openyurt-helm/charts/yurthub/ +cp -R openyurt/charts/yurt-iot-dock/* openyurt-helm/charts/yurt-iot-dock/ echo "push to openyurt-helm" echo "version: $VERSION, commit: $COMMIT_ID, tag: $TAG" diff --git a/hack/make-rules/kustomize_to_chart.sh b/hack/make-rules/kustomize_to_chart.sh index e5df0c8fa28..be671b465b7 100755 --- a/hack/make-rules/kustomize_to_chart.sh +++ b/hack/make-rules/kustomize_to_chart.sh @@ -193,11 +193,16 @@ EOF mv ${crd_dir}/apiextensions.k8s.io_v1_customresourcedefinition_yurtstaticsets.apps.openyurt.io.yaml ${crd_dir}/apps.openyurt.io_yurtstaticsets.yaml mv ${crd_dir}/apiextensions.k8s.io_v1_customresourcedefinition_yurtappdaemons.apps.openyurt.io.yaml ${crd_dir}/apps.openyurt.io_yurtappdaemons.yaml mv ${crd_dir}/apiextensions.k8s.io_v1_customresourcedefinition_yurtappsets.apps.openyurt.io.yaml ${crd_dir}/apps.openyurt.io_yurtappsets.yaml + mv ${crd_dir}/apiextensions.k8s.io_v1_customresourcedefinition_yurtappoverriders.apps.openyurt.io.yaml ${crd_dir}/apps.openyurt.io_yurtappoverriders.yaml mv ${crd_dir}/apiextensions.k8s.io_v1_customresourcedefinition_gateways.raven.openyurt.io.yaml ${crd_dir}/raven.openyurt.io_gateways.yaml mv ${crd_dir}/apiextensions.k8s.io_v1_customresourcedefinition_platformadmins.iot.openyurt.io.yaml ${crd_dir}/iot.openyurt.io_platformadmins.yaml - mv ${crd_dir}/apiextensions.k8s.io_v1_customresourcedefinition_devices.iot.openyurt.io.yaml ${crd_dir}/iot.openyurt.io_devices.yaml - mv ${crd_dir}/apiextensions.k8s.io_v1_customresourcedefinition_deviceservices.iot.openyurt.io.yaml ${crd_dir}/iot.openyurt.io_deviceservices.yaml - mv ${crd_dir}/apiextensions.k8s.io_v1_customresourcedefinition_deviceprofiles.iot.openyurt.io.yaml ${crd_dir}/iot.openyurt.io_deviceprofiles.yaml + # TODO: In the future, the crd generation process of yurt-manager and yurt-iot-dock will be split. For now, manually remove it from the yurt-manager script + # mv ${crd_dir}/apiextensions.k8s.io_v1_customresourcedefinition_devices.iot.openyurt.io.yaml ${crd_dir}/iot.openyurt.io_devices.yaml + # mv ${crd_dir}/apiextensions.k8s.io_v1_customresourcedefinition_deviceservices.iot.openyurt.io.yaml ${crd_dir}/iot.openyurt.io_deviceservices.yaml + # mv ${crd_dir}/apiextensions.k8s.io_v1_customresourcedefinition_deviceprofiles.iot.openyurt.io.yaml ${crd_dir}/iot.openyurt.io_deviceprofiles.yaml + rm -f ${crd_dir}/apiextensions.k8s.io_v1_customresourcedefinition_devices.iot.openyurt.io.yaml + rm -f ${crd_dir}/apiextensions.k8s.io_v1_customresourcedefinition_deviceservices.iot.openyurt.io.yaml + rm -f ${crd_dir}/apiextensions.k8s.io_v1_customresourcedefinition_deviceprofiles.iot.openyurt.io.yaml # add conversion for crds for file in "${Conversion_Files[@]}"