From 45e454f63ca08e1980b477f717fc359a5bd1be86 Mon Sep 17 00:00:00 2001 From: Lin Yang Date: Thu, 26 Jan 2023 16:03:40 +0800 Subject: [PATCH] feat: enhance NamespacedIngress API (#48) * chore: bump version to v0.1.0-beta.6 Signed-off-by: Lin Yang * feat: enhance NamespacedIngress API Signed-off-by: Lin Yang Signed-off-by: Lin Yang --- README.md | 6 +++--- VERSION | 4 ++-- .../v1alpha1/namespacedingress_types.go | 8 ++++++++ .../v1alpha1/zz_generated.deepcopy.go | 14 ++++++++++++++ charts/erie-canal/Chart.lock | 6 +++--- charts/erie-canal/Chart.yaml | 6 +++--- .../apis/flomesh.io_namespacedingresses.yaml | 11 +++++++++++ charts/namespaced-ingress/Chart.lock | 6 +++--- charts/namespaced-ingress/Chart.yaml | 6 +++--- charts/namespaced-ingress/templates/_helpers.tpl | 15 +++++++++++++++ .../namespaced-ingress/templates/deployment.yaml | 11 ++++++++--- charts/namespaced-ingress/templates/service.yaml | 5 ++++- charts/tpls/Chart.yaml | 4 ++-- charts/tpls/templates/_services.tpl | 5 +++-- samples/setup/readme.md | 6 +++--- 15 files changed, 85 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 4c4949f..183f0b8 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ To install the chart with the release name `ec` run: ```bash helm repo add ec https://ec.flomesh.io -helm install ec ec/erie-canal --namespace erie-canal --create-namespace --version=0.1.0-beta.5 +helm install ec ec/erie-canal --namespace erie-canal --create-namespace --version=0.1.0-beta.6 ``` The command deploys ErieCanal on the Kubernetes cluster using the default configuration in namespace `erie-canal` and creates the namespace if it doesn't exist. The [configuration](#configuration) section lists the parameters that can be configured during installation. @@ -55,7 +55,7 @@ Specify each parameter using the `--set key=value[,key=value]` argument to `helm helm install ec ec/erie-canal \ --namespace erie-canal \ --create-namespace \ - --version=0.1.0-beta.5 \ + --version=0.1.0-beta.6 \ --set ec.image.pullPolicy=Always ``` @@ -65,6 +65,6 @@ Alternatively, a YAML file that specifies the values for the parameters can be p helm install ec ec/erie-canal \ --namespace erie-canal \ --create-namespace \ - --version=0.1.0-beta.5 \ + --version=0.1.0-beta.6 \ -f values-override.yaml ``` diff --git a/VERSION b/VERSION index 0672b1e..ff17ecc 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ -APP_VERSION=0.1.0-beta.5 -HELM_CHART_VERSION=0.1.0-beta.5 +APP_VERSION=0.1.0-beta.6 +HELM_CHART_VERSION=0.1.0-beta.6 K8S_VERSION=1.25.5 ENVTEST_K8S_VERSION=1.25 \ No newline at end of file diff --git a/apis/namespacedingress/v1alpha1/namespacedingress_types.go b/apis/namespacedingress/v1alpha1/namespacedingress_types.go index 5f0fd2a..4af23b5 100644 --- a/apis/namespacedingress/v1alpha1/namespacedingress_types.go +++ b/apis/namespacedingress/v1alpha1/namespacedingress_types.go @@ -31,10 +31,18 @@ type NamespacedIngressSpec struct { // +optional ServiceAnnotations map[string]string `json:"serviceAnnotations,omitempty"` + // ServiceLabels, those annotations are applied to Ingress Service + // +optional + ServiceLabels map[string]string `json:"serviceLabels,omitempty"` + // PodAnnotations, those annotations are applied to Ingress POD // +optional PodAnnotations map[string]string `json:"podAnnotations,omitempty"` + // PodAnnotations, those labels are applied to Ingress POD + // +optional + PodLabels map[string]string `json:"podLabels,omitempty"` + // +kubebuilder:default={enabled: true, port: {name: http, protocol: TCP, port: 80, targetPort: 8000}} // The http configuration of this ingress controller. diff --git a/apis/namespacedingress/v1alpha1/zz_generated.deepcopy.go b/apis/namespacedingress/v1alpha1/zz_generated.deepcopy.go index 560c363..5569be5 100644 --- a/apis/namespacedingress/v1alpha1/zz_generated.deepcopy.go +++ b/apis/namespacedingress/v1alpha1/zz_generated.deepcopy.go @@ -111,6 +111,13 @@ func (in *NamespacedIngressSpec) DeepCopyInto(out *NamespacedIngressSpec) { (*out)[key] = val } } + if in.ServiceLabels != nil { + in, out := &in.ServiceLabels, &out.ServiceLabels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } if in.PodAnnotations != nil { in, out := &in.PodAnnotations, &out.PodAnnotations *out = make(map[string]string, len(*in)) @@ -118,6 +125,13 @@ func (in *NamespacedIngressSpec) DeepCopyInto(out *NamespacedIngressSpec) { (*out)[key] = val } } + if in.PodLabels != nil { + in, out := &in.PodLabels, &out.PodLabels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } in.HTTP.DeepCopyInto(&out.HTTP) in.TLS.DeepCopyInto(&out.TLS) if in.Env != nil { diff --git a/charts/erie-canal/Chart.lock b/charts/erie-canal/Chart.lock index c848561..a37c612 100644 --- a/charts/erie-canal/Chart.lock +++ b/charts/erie-canal/Chart.lock @@ -1,9 +1,9 @@ dependencies: - name: tpls repository: file://../tpls - version: 0.1.0-beta.5 + version: 0.1.0-beta.6 - name: cert-manager repository: https://charts.jetstack.io version: v1.7.3 -digest: sha256:93c6f6d9dc73e3c5529d69518f7b9c7e9a089087238e5b2a4c888506e611c3ed -generated: "2023-01-14T12:34:28.235983+08:00" +digest: sha256:a53aa295cc96451554a85c8c50f5705baa618de288527f7887ae518fad4735f6 +generated: "2023-01-26T15:14:17.805532+08:00" diff --git a/charts/erie-canal/Chart.yaml b/charts/erie-canal/Chart.yaml index 1fe5e8d..09dbbb9 100644 --- a/charts/erie-canal/Chart.yaml +++ b/charts/erie-canal/Chart.yaml @@ -18,13 +18,13 @@ 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: 0.1.0-beta.5 +version: 0.1.0-beta.6 # 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: "0.1.0-beta.5" +appVersion: "0.1.0-beta.6" keywords: - kubernetes @@ -48,7 +48,7 @@ sources: dependencies: - name: tpls - version: 0.1.0-beta.5 + version: 0.1.0-beta.6 repository: file://../tpls - name: cert-manager version: 1.7.3 diff --git a/charts/erie-canal/apis/flomesh.io_namespacedingresses.yaml b/charts/erie-canal/apis/flomesh.io_namespacedingresses.yaml index f0020b5..b63a401 100644 --- a/charts/erie-canal/apis/flomesh.io_namespacedingresses.yaml +++ b/charts/erie-canal/apis/flomesh.io_namespacedingresses.yaml @@ -1073,6 +1073,11 @@ spec: description: PodAnnotations, those annotations are applied to Ingress POD type: object + podLabels: + additionalProperties: + type: string + description: PodAnnotations, those labels are applied to Ingress POD + type: object podSecurityContext: description: 'PodSecurityContext holds pod-level security attributes and common container settings. Optional: Defaults to empty. See @@ -1444,6 +1449,12 @@ spec: description: ServiceAnnotations, those annotations are applied to Ingress Service type: object + serviceLabels: + additionalProperties: + type: string + description: ServiceLabels, those annotations are applied to Ingress + Service + type: object serviceType: description: ServiceType determines how the Ingress is exposed. For an Ingress the most used types are NodePort, and LoadBalancer diff --git a/charts/namespaced-ingress/Chart.lock b/charts/namespaced-ingress/Chart.lock index 360344e..c4d2f56 100644 --- a/charts/namespaced-ingress/Chart.lock +++ b/charts/namespaced-ingress/Chart.lock @@ -1,6 +1,6 @@ dependencies: - name: tpls repository: file://../tpls - version: 0.1.0-beta.5 -digest: sha256:bde69f6d74986a34ca742d912215e9a6e143862379cc24e7a547484b2b3a0655 -generated: "2023-01-14T12:34:35.91228+08:00" + version: 0.1.0-beta.6 +digest: sha256:d0177b3090b73c04abd82bfca7e02374866c774f61a1184acce51b9286b0cdd9 +generated: "2023-01-26T15:14:22.767827+08:00" diff --git a/charts/namespaced-ingress/Chart.yaml b/charts/namespaced-ingress/Chart.yaml index f91dd6d..39f9b51 100644 --- a/charts/namespaced-ingress/Chart.yaml +++ b/charts/namespaced-ingress/Chart.yaml @@ -16,15 +16,15 @@ 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: 0.1.0-beta.5 +version: 0.1.0-beta.6 # 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: "0.1.0-beta.5" +appVersion: "0.1.0-beta.6" dependencies: - name: tpls - version: 0.1.0-beta.5 + version: 0.1.0-beta.6 repository: file://../tpls diff --git a/charts/namespaced-ingress/templates/_helpers.tpl b/charts/namespaced-ingress/templates/_helpers.tpl index 996d096..1668a8e 100644 --- a/charts/namespaced-ingress/templates/_helpers.tpl +++ b/charts/namespaced-ingress/templates/_helpers.tpl @@ -4,3 +4,18 @@ ServiceAccountName - namespaced-ingress {{- define "ec.namespaced-ingress.serviceAccountName" -}} {{ default "erie-canal-namespaced-ingress" .Values.nsig.spec.serviceAccountName }} {{- end }} + + +{{- define "ec.namespaced-ingress.heath.port" -}} +{{- if and .Values.ec.ingress.enabled .Values.ec.ingress.namespaced }} +{{- if .Values.nsig.spec.http.enabled }} +{{- default .Values.ec.ingress.http.containerPort .Values.nsig.spec.http.port.targetPort }} +{{- else if and .Values.nsig.spec.tls.enabled }} +{{- default .Values.ec.ingress.tls.containerPort .Values.nsig.spec.tls.port.targetPort }} +{{- else }} +8081 +{{- end }} +{{- else }} +8081 +{{- end }} +{{- end }} diff --git a/charts/namespaced-ingress/templates/deployment.yaml b/charts/namespaced-ingress/templates/deployment.yaml index bbdeec2..b86b1c2 100644 --- a/charts/namespaced-ingress/templates/deployment.yaml +++ b/charts/namespaced-ingress/templates/deployment.yaml @@ -1,5 +1,5 @@ {{- if and .Values.ec.ingress.enabled (semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion) }} -{{- if .Values.ec.ingress.namespaced }} +{{- if and .Values.ec.ingress.namespaced (or .Values.nsig.spec.http.enabled .Values.nsig.spec.tls.enabled)}} apiVersion: apps/v1 kind: Deployment metadata: @@ -26,6 +26,9 @@ spec: {{- include "ec.ingress-pipy.selectorLabels" . | nindent 8 }} ingress.flomesh.io/namespaced: {{ .Values.ec.ingress.namespaced | quote }} ingress.flomesh.io/ns: {{ .Values.nsig.metadata.namespace }} + {{- with .Values.nsig.spec.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} {{- with .Values.nsig.spec.podAnnotations }} annotations: {{- toYaml . | nindent 8 }} @@ -63,6 +66,8 @@ spec: args: - --v={{ default .Values.ec.logLevel .Values.nsig.spec.logLevel }} env: + - name: GIN_MODE + value: release {{- include "ec.common-env" . | nindent 10 }} {{- with .Values.nsig.spec.env }} {{- toYaml . | nindent 10 }} @@ -84,12 +89,12 @@ spec: initialDelaySeconds: 5 timeoutSeconds: 5 tcpSocket: - port: {{ .Values.ec.ingress.http.containerPort }} + port: {{ include "ec.namespaced-ingress.heath.port" . }} readinessProbe: initialDelaySeconds: 5 timeoutSeconds: 5 tcpSocket: - port: {{ .Values.ec.ingress.http.containerPort }} + port: {{ include "ec.namespaced-ingress.heath.port" . }} terminationGracePeriodSeconds: 60 {{- with .Values.nsig.spec.podSecurityContext }} securityContext: diff --git a/charts/namespaced-ingress/templates/service.yaml b/charts/namespaced-ingress/templates/service.yaml index bea6af0..ec3cc11 100644 --- a/charts/namespaced-ingress/templates/service.yaml +++ b/charts/namespaced-ingress/templates/service.yaml @@ -1,5 +1,5 @@ {{- if and .Values.ec.ingress.enabled (semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion) }} -{{- if .Values.ec.ingress.namespaced }} +{{- if and .Values.ec.ingress.namespaced (or .Values.nsig.spec.http.enabled .Values.nsig.spec.tls.enabled)}} apiVersion: v1 kind: Service metadata: @@ -7,6 +7,9 @@ metadata: namespace: {{ .Values.nsig.metadata.namespace }} labels: {{- include "ec.ingress-pipy.labels" . | nindent 4 }} + {{- with .Values.nsig.spec.serviceLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} {{- with .Values.nsig.spec.serviceAnnotations }} annotations: {{- toYaml . | nindent 4 }} diff --git a/charts/tpls/Chart.yaml b/charts/tpls/Chart.yaml index 6ef6d01..e5ebdeb 100644 --- a/charts/tpls/Chart.yaml +++ b/charts/tpls/Chart.yaml @@ -15,10 +15,10 @@ type: library # 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: 0.1.0-beta.5 +version: 0.1.0-beta.6 # 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: "0.1.0-beta.5" +appVersion: "0.1.0-beta.6" diff --git a/charts/tpls/templates/_services.tpl b/charts/tpls/templates/_services.tpl index 179b0b4..e364293 100644 --- a/charts/tpls/templates/_services.tpl +++ b/charts/tpls/templates/_services.tpl @@ -66,10 +66,11 @@ Service Host - ingress-pipy Heath port - ingress-pipy */}} {{- define "ec.ingress-pipy.heath.port" -}} -{{- if .Values.ec.ingress.enabled}} +{{- if .Values.ec.ingress.enabled }} {{- if and .Values.ec.ingress.http.enabled (not (empty .Values.ec.ingress.http.containerPort)) }} -{{- .Values.ec.ingress.http.containerPort}} +{{- .Values.ec.ingress.http.containerPort }} {{- else if and .Values.ec.ingress.tls.enabled (not (empty .Values.ec.ingress.tls.containerPort)) }} +{{- .Values.ec.ingress.tls.containerPort }} {{- else }} 8081 {{- end }} diff --git a/samples/setup/readme.md b/samples/setup/readme.md index 4dd84e9..5bfc589 100644 --- a/samples/setup/readme.md +++ b/samples/setup/readme.md @@ -44,7 +44,7 @@ Not sure what to do next? 😅 Check out https://kind.sigs.k8s.io/docs/user/qui #### Install ErieCanal to Control Plane ```shell -helm install --namespace erie-canal --create-namespace --set ec.version=0.1.0-beta.5-dev --set ec.logLevel=5 --set ec.serviceLB.enabled=true erie-canal charts/erie-canal/ +helm install --namespace erie-canal --create-namespace --set ec.version=0.1.0-beta.6-dev --set ec.logLevel=5 --set ec.serviceLB.enabled=true erie-canal charts/erie-canal/ ``` ### Cluster 1 @@ -73,7 +73,7 @@ Not sure what to do next? 😅 Check out https://kind.sigs.k8s.io/docs/user/qui #### Install ErieCanal to Cluster1 ```shell -helm install --namespace erie-canal --create-namespace --set ec.version=0.1.0-beta.5-dev --set ec.logLevel=5 --set ec.serviceLB.enabled=true erie-canal charts/erie-canal/ +helm install --namespace erie-canal --create-namespace --set ec.version=0.1.0-beta.6-dev --set ec.logLevel=5 --set ec.serviceLB.enabled=true erie-canal charts/erie-canal/ ``` ### Cluster 2 @@ -102,7 +102,7 @@ Not sure what to do next? 😅 Check out https://kind.sigs.k8s.io/docs/user/qui #### Install ErieCanal to Cluster2 ```shell -helm install --namespace erie-canal --create-namespace --set ec.version=0.1.0-beta.5-dev --set ec.logLevel=5 --set ec.serviceLB.enabled=true erie-canal charts/erie-canal/ +helm install --namespace erie-canal --create-namespace --set ec.version=0.1.0-beta.6-dev --set ec.logLevel=5 --set ec.serviceLB.enabled=true erie-canal charts/erie-canal/ ``` ## Create/Update Cluster CRD yamls