From b8e6ce3dd3c38208c32310740a6fedf5794d6100 Mon Sep 17 00:00:00 2001 From: bin Date: Mon, 4 Jul 2022 15:20:52 +0800 Subject: [PATCH 1/4] add helm charts --- deploy/charts/neuron/Chart.yaml | 24 ++ deploy/charts/neuron/sample.yaml | 305 ++++++++++++++++++ deploy/charts/neuron/templates/NOTES.txt | 22 ++ deploy/charts/neuron/templates/_helpers.tpl | 69 ++++ deploy/charts/neuron/templates/ingress.yaml | 61 ++++ .../neuron/templates/serviceaccount.yaml | 12 + .../charts/neuron/templates/statefulset.yaml | 102 ++++++ .../charts/neuron/templates/svc-headless.yaml | 23 ++ deploy/charts/neuron/templates/svc.yaml | 39 +++ .../templates/tests/test-connection.yaml | 15 + .../charts/neuron/templates/tls-secrets.yaml | 15 + deploy/charts/neuron/values.yaml | 204 ++++++++++++ 12 files changed, 891 insertions(+) create mode 100644 deploy/charts/neuron/Chart.yaml create mode 100644 deploy/charts/neuron/sample.yaml create mode 100644 deploy/charts/neuron/templates/NOTES.txt create mode 100644 deploy/charts/neuron/templates/_helpers.tpl create mode 100644 deploy/charts/neuron/templates/ingress.yaml create mode 100644 deploy/charts/neuron/templates/serviceaccount.yaml create mode 100644 deploy/charts/neuron/templates/statefulset.yaml create mode 100644 deploy/charts/neuron/templates/svc-headless.yaml create mode 100644 deploy/charts/neuron/templates/svc.yaml create mode 100644 deploy/charts/neuron/templates/tests/test-connection.yaml create mode 100644 deploy/charts/neuron/templates/tls-secrets.yaml create mode 100644 deploy/charts/neuron/values.yaml diff --git a/deploy/charts/neuron/Chart.yaml b/deploy/charts/neuron/Chart.yaml new file mode 100644 index 00000000..e463f249 --- /dev/null +++ b/deploy/charts/neuron/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: neuron +description: A Helm chart for Kubernetes + +# 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: 0.1.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: "2.0.1" diff --git a/deploy/charts/neuron/sample.yaml b/deploy/charts/neuron/sample.yaml new file mode 100644 index 00000000..20937ddd --- /dev/null +++ b/deploy/charts/neuron/sample.yaml @@ -0,0 +1,305 @@ +NAME: neuron +LAST DEPLOYED: Fri Jul 1 16:23:38 2022 +NAMESPACE: default +STATUS: pending-install +REVISION: 1 +USER-SUPPLIED VALUES: +{} + +COMPUTED VALUES: +affinity: {} +autoscaling: + enabled: false + maxReplicas: 100 + minReplicas: 1 + targetCPUUtilizationPercentage: 80 +clusterDomain: cluster.local +containerPorts: + api: 7001 + web: 7000 +fullnameOverride: "" +image: + pullPolicy: IfNotPresent + repository: emqx/neuron + tag: "" +imagePullSecrets: [] +ingress: + annotations: {} + className: "" + enabled: false + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] +nameOverride: "" +nodeSelector: {} +persistence: + accessMode: ReadWriteOnce + enabled: true + existingClaim: "" + size: 20Mi + storageClassName: "" +podAnnotations: {} +podSecurityContext: {} +readinessProbe: + enabled: true + initialDelaySeconds: 5 + periodSeconds: 5 +replicaCount: 1 +resources: {} +securityContext: {} +service: + annotations: {} + loadBalancerSourceRanges: [] + nodePorts: + api: null + web: null + portNames: + api: api + web: web + ports: + api: 7001 + web: 7000 + type: ClusterIP +serviceAccount: + annotations: {} + create: true + name: "" +tls: + enabled: true + privateKey: | + -----BEGIN RSA PRIVATE KEY----- + MIIEpAIBAAKCAQEAzrO7FUz4GGKl4nP5lwKMh5uageJAAHnLZpVxTR1wXA9E870s + U03gHnPWsh2bXCCx85ymYaiu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rxwV+RBynpPRyMCsVto0B8kKQ + bKWqPBYURb/4/Hgkw7v4yMtx1jWTPDfYryd2JptJKsOk7mtK/Nqp+wpypa9cfyc5 + p44PVdqauco96Jk7zzohjlrVAoGAfjQDrJaH5DDpTjYIeckYdtFSh9+fi3LdnYk/ + bnoYNRJqAE5Fhs5ccih0Z7TgX3L3fFMKL/Pe5kxyIYzuWRZcAvctVSIJPamNjShB + 9UQ9EBe+lJHej54VBP+s6YuHbcg4GtxNvnVy4L5Bah1T0AEQXrQFbv8jbXU/YEJi + NuXQ7GECgYA0UNvuZxVSDn8fBxARcX3ub5aok5owdLL3SOCPMpNrmOBQj8iJGT+5 + nv7fH1TWVh9yUdRwhd81s5H/PO3/myLmgq0TcPvewtEEwY+++QpsYZwHTDXgxbbw + ++lmJali4fzmd/72JqocGABYhZFt0jbcQ1QEcqUYcD380+cNVZPO+w== + -----END RSA PRIVATE KEY----- + publicKey: | + -----BEGIN PUBLIC KEY----- + MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzrO7FUz4GGKl4nP5lwKM + h5uageJAAHnLZpVxTR1wXA9E870sU03gHnPWsh2bXCCx85ymYaiu/5VlptgnU0rQ + B1I3xGRG8eHmHPrhHNWDRKpY6oY8AnTPqXvfa/Z4u+njJzDSqi4qM8Gwfqlgpjlg + 8DUF+sheLx8hL+x9XFzovTxafrmyJRRAVQTkhB7esKKqRF8BMjdOdYZxJEv9jxa0 + BwXcjprPDlj5TV6k3wJqbq4UtnEEVbjEQKqFVkfY4FuJ5NSPHpGEix94PGQGRsiW + kGX0vx5udHJ0SlXM6qpMLny18FhWbwKNX3urc3mImn/j3zcJ5x1d+FlXAXs1NBSe + TQIDAQAB + -----END PUBLIC KEY----- +tolerations: [] + +HOOKS: +--- +# Source: neuron/templates/tests/test-connection.yaml +apiVersion: v1 +kind: Pod +metadata: + name: "neuron-test-connection" + labels: + helm.sh/chart: neuron-0.1.0 + app.kubernetes.io/name: neuron + app.kubernetes.io/instance: neuron + app.kubernetes.io/version: "2.0.1" + app.kubernetes.io/managed-by: Helm + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['neuron:'] + restartPolicy: Never +MANIFEST: +--- +# Source: neuron/templates/serviceaccount.yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + name: neuron + labels: + helm.sh/chart: neuron-0.1.0 + app.kubernetes.io/name: neuron + app.kubernetes.io/instance: neuron + app.kubernetes.io/version: "2.0.1" + app.kubernetes.io/managed-by: Helm +--- +# Source: neuron/templates/tls-secrets.yaml +apiVersion: v1 +kind: Secret +metadata: + name: neuron-certs + namespace: default + labels: + helm.sh/chart: neuron-0.1.0 + app.kubernetes.io/name: neuron + app.kubernetes.io/instance: neuron + app.kubernetes.io/version: "2.0.1" + app.kubernetes.io/managed-by: Helm +type: Opaque +data: + neuron.pem: "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUF6ck83RlV6NEdHS2w0blA1bHdLTQpoNXVhZ2VKQUFIbkxacFZ4VFIxd1hBOUU4NzBzVTAzZ0huUFdzaDJiWENDeDg1eW1ZYWl1LzVWbHB0Z25VMHJRCkIxSTN4R1JHOGVIbUhQcmhITldEUktwWTZvWThBblRQcVh2ZmEvWjR1K25qSnpEU3FpNHFNOEd3ZnFsZ3BqbGcKOERVRitzaGVMeDhoTCt4OVhGem92VHhhZnJteUpSUkFWUVRraEI3ZXNLS3FSRjhCTWpkT2RZWnhKRXY5anhhMApCd1hjanByUERsajVUVjZrM3dKcWJxNFV0bkVFVmJqRVFLcUZWa2ZZNEZ1SjVOU1BIcEdFaXg5NFBHUUdSc2lXCmtHWDB2eDV1ZEhKMFNsWE02cXBNTG55MThGaFdid0tOWDN1cmMzbUltbi9qM3pjSjV4MWQrRmxYQVhzMU5CU2UKVFFJREFRQUIKLS0tLS1FTkQgUFVCTElDIE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URFhneGJidworK2xtSmFsaTRmem1kLzcySnFvY0dBQlloWkZ0MGpiY1ExUUVjcVVZY0QzODArY05WWlBPK3c9PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo=" +--- +# Source: neuron/templates/svc-headless.yaml +apiVersion: v1 +kind: Service +metadata: + name: neuron-headless + namespace: default + labels: + helm.sh/chart: neuron-0.1.0 + app.kubernetes.io/name: neuron + app.kubernetes.io/instance: neuron + app.kubernetes.io/version: "2.0.1" + app.kubernetes.io/managed-by: Helm +spec: + type: ClusterIP + sessionAffinity: None + clusterIP: None + publishNotReadyAddresses: true + ports: + - name: web + port: 7000 + protocol: TCP + targetPort: web + - name: api + port: 7001 + protocol: TCP + targetPort: api + selector: + app.kubernetes.io/name: neuron + app.kubernetes.io/instance: neuron +--- +# Source: neuron/templates/svc.yaml +apiVersion: v1 +kind: Service +metadata: + name: neuron + namespace: default + labels: + helm.sh/chart: neuron-0.1.0 + app.kubernetes.io/name: neuron + app.kubernetes.io/instance: neuron + app.kubernetes.io/version: "2.0.1" + app.kubernetes.io/managed-by: Helm +spec: + type: ClusterIP + ports: + - name: web + port: 7000 + protocol: TCP + targetPort: web + nodePort: null + - name: api + port: 7001 + protocol: TCP + targetPort: api + nodePort: null + selector: + app.kubernetes.io/name: neuron + app.kubernetes.io/instance: neuron +--- +# Source: neuron/templates/statefulset.yaml +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: neuron + namespace: default + labels: + helm.sh/chart: neuron-0.1.0 + app.kubernetes.io/name: neuron + app.kubernetes.io/instance: neuron + app.kubernetes.io/version: "2.0.1" + app.kubernetes.io/managed-by: Helm +spec: + replicas: 1 + serviceName: neuron-headless + volumeClaimTemplates: + - metadata: + name: neuron-persistence + namespace: default + labels: + app.kubernetes.io/name: neuron + app.kubernetes.io/instance: neuron + app.kubernetes.io/managed-by: Helm + spec: + accessModes: + - "ReadWriteOnce" + resources: + requests: + storage: "20Mi" + selector: + matchLabels: + app.kubernetes.io/name: neuron + app.kubernetes.io/instance: neuron + template: + metadata: + labels: + app.kubernetes.io/name: neuron + app.kubernetes.io/instance: neuron + spec: + volumes: + - name: certs + secret: + secretName: neuron-certs + items: + - key: neuron.pem + path: neuron.pem + - key: neuron.key + path: neuron.key + containers: + - name: neuron + image: "emqx/neuron:2.0.1" + imagePullPolicy: IfNotPresent + readinessProbe: + httpGet: + port: 7000 + initialDelaySeconds: 5 + periodSeconds: 5 + ports: + - name: web + containerPort: 7000 + - name: api + containerPort: 7001 + volumeMounts: + - name: neuron-persistence + mountPath: "/opt/neuron/persistence" + - name: certs + mountPath: "/opt/neuron/config/neuron.pem" + subPath: "neuron.pem" + readOnly: true + - name: certs + mountPath: "/opt/neuron/config/neuron.key" + subPath: "neuron.key" + readOnly: true + resources: + {} + +NOTES: +1. Get the application URL by running these commands: + export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=neuron,app.kubernetes.io/instance=neuron" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT diff --git a/deploy/charts/neuron/templates/NOTES.txt b/deploy/charts/neuron/templates/NOTES.txt new file mode 100644 index 00000000..b9da9c87 --- /dev/null +++ b/deploy/charts/neuron/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "neuron.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "neuron.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "neuron.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "neuron.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/deploy/charts/neuron/templates/_helpers.tpl b/deploy/charts/neuron/templates/_helpers.tpl new file mode 100644 index 00000000..05c35f74 --- /dev/null +++ b/deploy/charts/neuron/templates/_helpers.tpl @@ -0,0 +1,69 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "neuron.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 "neuron.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 "neuron.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "neuron.labels" -}} +helm.sh/chart: {{ include "neuron.chart" . }} +{{ include "neuron.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "neuron.selectorLabels" -}} +app.kubernetes.io/name: {{ include "neuron.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "neuron.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "neuron.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} + +{{/* +Get the TLS secret. +*/}} +{{- define "neuron.tlsSecretName" -}} + {{- printf "%s-certs" (include "neuron.fullname" .) -}} +{{- end -}} \ No newline at end of file diff --git a/deploy/charts/neuron/templates/ingress.yaml b/deploy/charts/neuron/templates/ingress.yaml new file mode 100644 index 00000000..a0984fe7 --- /dev/null +++ b/deploy/charts/neuron/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "neuron.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "neuron.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/deploy/charts/neuron/templates/serviceaccount.yaml b/deploy/charts/neuron/templates/serviceaccount.yaml new file mode 100644 index 00000000..4786c25a --- /dev/null +++ b/deploy/charts/neuron/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "neuron.serviceAccountName" . }} + labels: + {{- include "neuron.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/deploy/charts/neuron/templates/statefulset.yaml b/deploy/charts/neuron/templates/statefulset.yaml new file mode 100644 index 00000000..0c637f26 --- /dev/null +++ b/deploy/charts/neuron/templates/statefulset.yaml @@ -0,0 +1,102 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ include "neuron.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "neuron.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + serviceName: {{ include "neuron.fullname" . }}-headless + {{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }} + volumeClaimTemplates: + - metadata: + name: neuron-persistence + namespace: {{ .Release.Namespace }} + labels: + {{- include "neuron.selectorLabels" . | nindent 10 }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + spec: + {{- if .Values.persistence.storageClassName }} + storageClassName: {{ .Values.persistence.storageClassName | quote }} + {{- end }} + accessModes: + - {{ .Values.persistence.accessMode | quote }} + resources: + requests: + storage: {{ .Values.persistence.size | quote }} + {{- end }} + selector: + matchLabels: + {{- include "neuron.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "neuron.selectorLabels" . | nindent 8 }} + spec: + volumes: + {{- if not .Values.persistence.enabled }} + - name: neuron-persistence + emptyDir: {} + {{- else if .Values.persistence.existingClaim }} + - name: neuron-persistence + persistentVolumeClaim: + {{- with .Values.persistence.existingClaim }} + claimName: {{ tpl . $ }} + {{- end }} + {{- end }} + {{- if .Values.tls.enabled }} + - name: certs + secret: + secretName: {{ include "neuron.tlsSecretName" . }} + items: + - key: neuron.pem + path: neuron.pem + - key: neuron.key + path: neuron.key + {{- end}} + containers: + - name: neuron + image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if .Values.readinessProbe.enabled }} + readinessProbe: + httpGet: + port: {{ .Values.service.web | default 7000 }} + initialDelaySeconds: 5 + periodSeconds: 5 + {{- end }} + ports: + - name: web + containerPort: {{ .Values.containerPorts.web | default 7000 }} + - name: api + containerPort: {{ .Values.containerPorts.api | default 7001 }} + volumeMounts: + - name: neuron-persistence + mountPath: "/opt/neuron/persistence" + {{- if .Values.tls.enabled }} + - name: certs + mountPath: "/opt/neuron/config/neuron.pem" + subPath: "neuron.pem" + readOnly: true + - name: certs + mountPath: "/opt/neuron/config/neuron.key" + subPath: "neuron.key" + readOnly: true + {{- end }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + + diff --git a/deploy/charts/neuron/templates/svc-headless.yaml b/deploy/charts/neuron/templates/svc-headless.yaml new file mode 100644 index 00000000..8cecc6f2 --- /dev/null +++ b/deploy/charts/neuron/templates/svc-headless.yaml @@ -0,0 +1,23 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "neuron.fullname" . }}-headless + namespace: {{ .Release.Namespace }} + labels: + {{- include "neuron.labels" . | nindent 4 }} +spec: + type: ClusterIP + sessionAffinity: None + clusterIP: None + publishNotReadyAddresses: true + ports: + - name: {{ .Values.service.portNames.web }} + port: {{ .Values.service.ports.web | default 7000 }} + protocol: TCP + targetPort: web + - name: {{ .Values.service.portNames.api }} + port: {{ .Values.service.ports.api | default 7001 }} + protocol: TCP + targetPort: api + selector: + {{- include "neuron.selectorLabels" . | nindent 4 }} diff --git a/deploy/charts/neuron/templates/svc.yaml b/deploy/charts/neuron/templates/svc.yaml new file mode 100644 index 00000000..f493aec0 --- /dev/null +++ b/deploy/charts/neuron/templates/svc.yaml @@ -0,0 +1,39 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "neuron.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "neuron.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + {{- if eq .Values.service.type "LoadBalancer" }} + {{- if .Values.service.loadBalancerIP }} + loadBalancerIP: {{ .Values.service.loadBalancerIP }} + {{- end }} + {{- if .Values.service.loadBalancerSourceRanges }} + loadBalancerSourceRanges: {{- toYaml .Values.service.loadBalancerSourceRanges | nindent 4 }} + {{- end }} + {{- end }} + ports: + - name: {{ .Values.service.portNames.web }} + port: {{ .Values.service.ports.web | default 7000 }} + protocol: TCP + targetPort: web + {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.web)) }} + nodePort: {{ .Values.service.nodePorts.web }} + {{- else if eq .Values.service.type "ClusterIP" }} + nodePort: null + {{- end }} + - name: {{ .Values.service.portNames.api }} + port: {{ .Values.service.ports.api | default 7001 }} + protocol: TCP + targetPort: api + {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.api)) }} + nodePort: {{ .Values.service.nodePorts.api }} + {{- else if eq .Values.service.type "ClusterIP" }} + nodePort: null + {{- end }} + selector: + {{- include "neuron.selectorLabels" . | nindent 4 }} + diff --git a/deploy/charts/neuron/templates/tests/test-connection.yaml b/deploy/charts/neuron/templates/tests/test-connection.yaml new file mode 100644 index 00000000..cb202f41 --- /dev/null +++ b/deploy/charts/neuron/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "neuron.fullname" . }}-test-connection" + labels: + {{- include "neuron.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "neuron.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/deploy/charts/neuron/templates/tls-secrets.yaml b/deploy/charts/neuron/templates/tls-secrets.yaml new file mode 100644 index 00000000..ced8668d --- /dev/null +++ b/deploy/charts/neuron/templates/tls-secrets.yaml @@ -0,0 +1,15 @@ +{{- if .Values.tls.enabled }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "neuron.fullname" . }}-certs + namespace: {{ .Release.Namespace }} + labels: + {{- include "neuron.labels" . | nindent 4 }} +type: Opaque +data: + {{- if and .Values.tls.publicKey .Values.tls.privateKey }} + neuron.pem: {{ required "A valid .Values.tls.publicKey entry required!" .Values.tls.publicKey | b64enc | quote }} + neuron.key: {{ required "A valid .Values.tls.privateKey entry required!" .Values.tls.privateKey | b64enc | quote }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/deploy/charts/neuron/values.yaml b/deploy/charts/neuron/values.yaml new file mode 100644 index 00000000..11aef050 --- /dev/null +++ b/deploy/charts/neuron/values.yaml @@ -0,0 +1,204 @@ +# Default values for neuron. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: emqx/neuron + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + + ## Service ports + ## @param service.ports.web Neuron Dashboard port + ## @param service.ports.api Neuron API port + ## + ports: + web: 7000 + api: 7001 + + ## Service ports name + ## @param service.portNames.web Neuron Dashboard port name + ## @param service.portNames.api Neuron API port name + ## + portNames: + web: "web" + api: "api" + + ## Specify the nodePort(s) value for the LoadBalancer and NodePort service types. + ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport + ## + nodePorts: + web: + api: + ## Set the LoadBalancer service type to internal only. + ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer + ## + # loadBalancerIP: + ## Load Balancer sources + ## ref: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/#restrict-access-for-loadbalancer-service + ## Example: + ## loadBalancerSourceRanges: + ## - 10.10.10.0/24 + ## + loadBalancerSourceRanges: [] + ## Provide any additional annotations which may be required. Evaluated as a template + ## + annotations: {} + + ## Set the LoadBalancer service type to internal only. + ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer + ## + # loadBalancerIP: + ## Load Balancer sources + ## ref: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/#restrict-access-for-loadbalancer-service + ## Example: + ## loadBalancerSourceRanges: + ## - 10.10.10.0/24 + ## + loadBalancerSourceRanges: [] + ## Provide any additional annotations which may be required. Evaluated as a template + ## + annotations: {} + + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + + +persistence: + enabled: true + size: 20Mi + storageClassName: "" + accessMode: ReadWriteOnce + ## Existing PersistentVolumeClaims + ## The value is evaluated as a template + ## So, for example, the name can depend on .Release or .Chart + existingClaim: "" + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +## @param clusterDomain Kubernetes Cluster Domain +## +clusterDomain: cluster.local + +tls: + enabled: true + publicKey: | + -----BEGIN PUBLIC KEY----- + MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzrO7FUz4GGKl4nP5lwKM + h5uageJAAHnLZpVxTR1wXA9E870sU03gHnPWsh2bXCCx85ymYaiu/5VlptgnU0rQ + B1I3xGRG8eHmHPrhHNWDRKpY6oY8AnTPqXvfa/Z4u+njJzDSqi4qM8Gwfqlgpjlg + 8DUF+sheLx8hL+x9XFzovTxafrmyJRRAVQTkhB7esKKqRF8BMjdOdYZxJEv9jxa0 + BwXcjprPDlj5TV6k3wJqbq4UtnEEVbjEQKqFVkfY4FuJ5NSPHpGEix94PGQGRsiW + kGX0vx5udHJ0SlXM6qpMLny18FhWbwKNX3urc3mImn/j3zcJ5x1d+FlXAXs1NBSe + TQIDAQAB + -----END PUBLIC KEY----- + privateKey: | + -----BEGIN RSA PRIVATE KEY----- + MIIEpAIBAAKCAQEAzrO7FUz4GGKl4nP5lwKMh5uageJAAHnLZpVxTR1wXA9E870s + U03gHnPWsh2bXCCx85ymYaiu/5VlptgnU0rQB1I3xGRG8eHmHPrhHNWDRKpY6oY8 + AnTPqXvfa/Z4u+njJzDSqi4qM8Gwfqlgpjlg8DUF+sheLx8hL+x9XFzovTxafrmy + JRRAVQTkhB7esKKqRF8BMjdOdYZxJEv9jxa0BwXcjprPDlj5TV6k3wJqbq4UtnEE + VbjEQKqFVkfY4FuJ5NSPHpGEix94PGQGRsiWkGX0vx5udHJ0SlXM6qpMLny18FhW + bwKNX3urc3mImn/j3zcJ5x1d+FlXAXs1NBSeTQIDAQABAoIBAQDJOT8PZXbAhohn + A/AeimS0P08S0mbsD6VroGBEajxP4q2FeswD7PQZsTt4+kmcTlfuiLmQqN50AcSL + wDHIbDRIbEnN7rECGKAj5jfwEgtQdWVKKpOQ8JaYr/a466BtjyuLo4PyGC8NY6mm + JM3qBEHSlkvT7+uAhBWSye7gU7JfRPoCeFRpaMMC3Ad0DaIt/Pdt9CddNwj56+9j + gl//blNnBImjvA7/kh9gL69SYVrQoG9vm/UgFbdIwd+w2hhhpx6kuHjRJ21xIV/y + Yh9k4QhPr7zIkhQ8yn11ZhyZkMC8XAMy7NKCmAFIPNJ8jwvgBkunPEk2aYBeDUaq + a30VwlIhAoGBAOnm8DW5DROcfSj4Q8zsvgmvhGM0zzF5zmA+4E+tEbf4t6sDUjSs + ADo2EaiJZz75vLsD7UZHKzFEV/wnuT7SiNCbrJafx8Tp2UgijTkW8gEhAWREJDn5 + FS375RKFdEcpmVHWgsuz4z/0L3BGxmyYWQxx5pD2NL49ZpTIHAHm/XETAoGBAOI6 + 8Y08TmM2bnXbL/MggYMJlqOyv27ueVYz9of3FYFAMIe7ebSgrlSCOwsoDZYmegBM + OrowR3AAnoP4fjGNbIPjNYbiv1qLOdtnvPxYotEz+ZaUBSn9V/gUEVFlgrKxgTKr + sqi/QMyyJplBTUkUuqYRDuv6TZ3OWKiDUoXTdv8fAoGBAIbbyf+PlESMY3Vtvtm2 + XdODyRbR6ewiyKShW/9UT/T8iBknrwwDZ5YoeoHrxwV+RBynpPRyMCsVto0B8kKQ + bKWqPBYURb/4/Hgkw7v4yMtx1jWTPDfYryd2JptJKsOk7mtK/Nqp+wpypa9cfyc5 + p44PVdqauco96Jk7zzohjlrVAoGAfjQDrJaH5DDpTjYIeckYdtFSh9+fi3LdnYk/ + bnoYNRJqAE5Fhs5ccih0Z7TgX3L3fFMKL/Pe5kxyIYzuWRZcAvctVSIJPamNjShB + 9UQ9EBe+lJHej54VBP+s6YuHbcg4GtxNvnVy4L5Bah1T0AEQXrQFbv8jbXU/YEJi + NuXQ7GECgYA0UNvuZxVSDn8fBxARcX3ub5aok5owdLL3SOCPMpNrmOBQj8iJGT+5 + nv7fH1TWVh9yUdRwhd81s5H/PO3/myLmgq0TcPvewtEEwY+++QpsYZwHTDXgxbbw + ++lmJali4fzmd/72JqocGABYhZFt0jbcQ1QEcqUYcD380+cNVZPO+w== + -----END RSA PRIVATE KEY----- + + +readinessProbe: + enabled: true + initialDelaySeconds: 5 + periodSeconds: 5 + +## Container Ports +## @param containerPorts.web +## @param containerPorts.api +## +containerPorts: + web: 7000 + api: 7001 From 3e8d59e3733e2bd9fa66aef748f06d0a96d15ec6 Mon Sep 17 00:00:00 2001 From: bin Date: Sun, 10 Jul 2022 14:54:35 +0800 Subject: [PATCH 2/4] faet: add a helm chart Signed-off-by: bin --- .gitignore | 1 + deploy/charts/neuron/Chart.yaml | 2 +- deploy/charts/neuron/README.md | 71 ++++ deploy/charts/neuron/sample.yaml | 305 ------------------ deploy/charts/neuron/templates/NOTES.txt | 22 -- .../{statefulset.yaml => deployment.yaml} | 41 +-- .../charts/neuron/templates/svc-headless.yaml | 23 -- deploy/charts/neuron/templates/svc.yaml | 3 +- deploy/charts/neuron/values.yaml | 86 +++-- 9 files changed, 125 insertions(+), 429 deletions(-) create mode 100644 deploy/charts/neuron/README.md delete mode 100644 deploy/charts/neuron/sample.yaml delete mode 100644 deploy/charts/neuron/templates/NOTES.txt rename deploy/charts/neuron/templates/{statefulset.yaml => deployment.yaml} (68%) delete mode 100644 deploy/charts/neuron/templates/svc-headless.yaml diff --git a/.gitignore b/.gitignore index 1d5af33c..95cd7bc4 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ tmp *.deb *.rpm neuron-sdk +.vscode \ No newline at end of file diff --git a/deploy/charts/neuron/Chart.yaml b/deploy/charts/neuron/Chart.yaml index e463f249..939fa39a 100644 --- a/deploy/charts/neuron/Chart.yaml +++ b/deploy/charts/neuron/Chart.yaml @@ -15,7 +15,7 @@ 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 +version: 1.0.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 diff --git a/deploy/charts/neuron/README.md b/deploy/charts/neuron/README.md new file mode 100644 index 00000000..62c9e98c --- /dev/null +++ b/deploy/charts/neuron/README.md @@ -0,0 +1,71 @@ +# neuron + +![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.0.1](https://img.shields.io/badge/AppVersion-2.0.1-informational?style=flat-square) + +A Helm chart for Kubernetes + +## Install the Chart + +- From Github +``` +git clone https://github.com/emqx/neuron.git +cd deploy/charts/neuron +helm install my-neuron . +``` + +## Uninstall Chart +``` +helm uninstall my-neuron +``` + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| affinity | object | `{}` | | +| autoscaling.enabled | bool | `false` | | +| autoscaling.maxReplicas | int | `100` | | +| autoscaling.minReplicas | int | `1` | | +| autoscaling.targetCPUUtilizationPercentage | int | `80` | | +| clusterDomain | string | `"cluster.local"` | Kubernetes Cluster Domain | +| containerPorts | object | `{"api":7001,"web":7000}` | Container Ports | +| containerPorts.api | int | `7001` | containerPorts.api | +| containerPorts.web | int | `7000` | containerPorts.web | +| fullnameOverride | string | `""` | | +| hostPorts | object | `{"api":30371,"enabled":true,"web":30370}` | only for KubeEdge deployment | +| image.pullPolicy | string | `"IfNotPresent"` | | +| image.repository | string | `"emqx/neuron"` | | +| image.tag | string | `""` | | +| imagePullSecrets | list | `[]` | | +| ingress.annotations | object | `{}` | | +| ingress.className | string | `""` | | +| ingress.enabled | bool | `false` | | +| ingress.hosts[0].host | string | `"chart-example.local"` | | +| ingress.hosts[0].paths[0].path | string | `"/"` | | +| ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | | +| ingress.tls | list | `[]` | | +| nameOverride | string | `""` | | +| nodeSelector | object | `{}` | | +| persistence.enabled | bool | `false` | | +| persistence.existingClaim | string | `""` | Existing PersistentVolumeClaims The value is evaluated as a template So, for example, the name can depend on .Release or .Chart | +| podAnnotations | object | `{}` | | +| readinessProbe.enabled | bool | `true` | | +| readinessProbe.initialDelaySeconds | int | `5` | | +| readinessProbe.periodSeconds | int | `5` | | +| resources | object | `{}` | | +| service.annotations | object | `{}` | Provide any additional annotations which may be required. Evaluated as a template | +| service.enabled | bool | `false` | | +| service.loadBalancerSourceRanges | list | `[]` | loadBalancerSourceRanges: - 10.10.10.0/24 | +| service.nodePorts | object | `{"api":null,"web":null}` | Specify the nodePort(s) value for the LoadBalancer and NodePort service types. ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport | +| service.portNames | object | `{"api":"api","web":"web"}` | Service ports name | +| service.portNames.api | string | `"api"` | service.portNames.api Neuron API port name | +| service.portNames.web | string | `"web"` | service.portNames.web Neuron Dashboard port name | +| service.ports | object | `{"api":7001,"web":7000}` | Service ports | +| service.ports.api | int | `7001` | service.ports.api Neuron API port | +| service.ports.web | int | `7000` | service.ports.web Neuron Dashboard port | +| service.type | string | `"ClusterIP"` | | +| serviceAccount.annotations | object | `{}` | Annotations to add to the service account | +| serviceAccount.create | bool | `true` | Specifies whether a service account should be created | +| serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template | +| tolerations | list | `[]` | | + diff --git a/deploy/charts/neuron/sample.yaml b/deploy/charts/neuron/sample.yaml deleted file mode 100644 index 20937ddd..00000000 --- a/deploy/charts/neuron/sample.yaml +++ /dev/null @@ -1,305 +0,0 @@ -NAME: neuron -LAST DEPLOYED: Fri Jul 1 16:23:38 2022 -NAMESPACE: default -STATUS: pending-install -REVISION: 1 -USER-SUPPLIED VALUES: -{} - -COMPUTED VALUES: -affinity: {} -autoscaling: - enabled: false - maxReplicas: 100 - minReplicas: 1 - targetCPUUtilizationPercentage: 80 -clusterDomain: cluster.local -containerPorts: - api: 7001 - web: 7000 -fullnameOverride: "" -image: - pullPolicy: IfNotPresent - repository: emqx/neuron - tag: "" -imagePullSecrets: [] -ingress: - annotations: {} - className: "" - enabled: false - hosts: - - host: chart-example.local - paths: - - path: / - pathType: ImplementationSpecific - tls: [] -nameOverride: "" -nodeSelector: {} -persistence: - accessMode: ReadWriteOnce - enabled: true - existingClaim: "" - size: 20Mi - storageClassName: "" -podAnnotations: {} -podSecurityContext: {} -readinessProbe: - enabled: true - initialDelaySeconds: 5 - periodSeconds: 5 -replicaCount: 1 -resources: {} -securityContext: {} -service: - annotations: {} - loadBalancerSourceRanges: [] - nodePorts: - api: null - web: null - portNames: - api: api - web: web - ports: - api: 7001 - web: 7000 - type: ClusterIP -serviceAccount: - annotations: {} - create: true - name: "" -tls: - enabled: true - privateK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xgTKr - sqi/QMyyJplBTUkUuqYRDuv6TZ3OWKiDUoXTdv8fAoGBAIbbyf+PlESMY3Vtvtm2 - XdODyRbR6ewiyKShW/9UT/T8iBknrwwDZ5YoeoHrxwV+RBynpPRyMCsVto0B8kKQ - bKWqPBYURb/4/Hgkw7v4yMtx1jWTPDfYryd2JptJKsOk7mtK/Nqp+wpypa9cfyc5 - p44PVdqauco96Jk7zzohjlrVAoGAfjQDrJaH5DDpTjYIeckYdtFSh9+fi3LdnYk/ - bnoYNRJqAE5Fhs5ccih0Z7TgX3L3fFMKL/Pe5kxyIYzuWRZcAvctVSIJPamNjShB - 9UQ9EBe+lJHej54VBP+s6YuHbcg4GtxNvnVy4L5Bah1T0AEQXrQFbv8jbXU/YEJi - NuXQ7GECgYA0UNvuZxVSDn8fBxARcX3ub5aok5owdLL3SOCPMpNrmOBQj8iJGT+5 - nv7fH1TWVh9yUdRwhd81s5H/PO3/myLmgq0TcPvewtEEwY+++QpsYZwHTDXgxbbw - ++lmJali4fzmd/72JqocGABYhZFt0jbcQ1QEcqUYcD380+cNVZPO+w== - -----END RSA PRIVATE KEY----- - publicKey: | - -----BEGIN PUBLIC KEY----- - MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzrO7FUz4GGKl4nP5lwKM - h5uageJAAHnLZpVxTR1wXA9E870sU03gHnPWsh2bXCCx85ymYaiu/5VlptgnU0rQ - B1I3xGRG8eHmHPrhHNWDRKpY6oY8AnTPqXvfa/Z4u+njJzDSqi4qM8Gwfqlgpjlg - 8DUF+sheLx8hL+x9XFzovTxafrmyJRRAVQTkhB7esKKqRF8BMjdOdYZxJEv9jxa0 - BwXcjprPDlj5TV6k3wJqbq4UtnEEVbjEQKqFVkfY4FuJ5NSPHpGEix94PGQGRsiW - kGX0vx5udHJ0SlXM6qpMLny18FhWbwKNX3urc3mImn/j3zcJ5x1d+FlXAXs1NBSe - TQIDAQAB - -----END PUBLIC KEY----- -tolerations: [] - -HOOKS: ---- -# Source: neuron/templates/tests/test-connection.yaml -apiVersion: v1 -kind: Pod -metadata: - name: "neuron-test-connection" - labels: - helm.sh/chart: neuron-0.1.0 - app.kubernetes.io/name: neuron - app.kubernetes.io/instance: neuron - app.kubernetes.io/version: "2.0.1" - app.kubernetes.io/managed-by: Helm - annotations: - "helm.sh/hook": test -spec: - containers: - - name: wget - image: busybox - command: ['wget'] - args: ['neuron:'] - restartPolicy: Never -MANIFEST: ---- -# Source: neuron/templates/serviceaccount.yaml -apiVersion: v1 -kind: ServiceAccount -metadata: - name: neuron - labels: - helm.sh/chart: neuron-0.1.0 - app.kubernetes.io/name: neuron - app.kubernetes.io/instance: neuron - app.kubernetes.io/version: "2.0.1" - app.kubernetes.io/managed-by: Helm ---- -# Source: neuron/templates/tls-secrets.yaml -apiVersion: v1 -kind: Secret -metadata: - name: neuron-certs - namespace: default - labels: - helm.sh/chart: neuron-0.1.0 - app.kubernetes.io/name: neuron - app.kubernetes.io/instance: neuron - app.kubernetes.io/version: "2.0.1" - app.kubernetes.io/managed-by: Helm -type: Opaque -data: - neuron.pem: "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUF6ck83RlV6NEdHS2w0blA1bHdLTQpoNXVhZ2VKQUFIbkxacFZ4VFIxd1hBOUU4NzBzVTAzZ0huUFdzaDJiWENDeDg1eW1ZYWl1LzVWbHB0Z25VMHJRCkIxSTN4R1JHOGVIbUhQcmhITldEUktwWTZvWThBblRQcVh2ZmEvWjR1K25qSnpEU3FpNHFNOEd3ZnFsZ3BqbGcKOERVRitzaGVMeDhoTCt4OVhGem92VHhhZnJteUpSUkFWUVRraEI3ZXNLS3FSRjhCTWpkT2RZWnhKRXY5anhhMApCd1hjanByUERsajVUVjZrM3dKcWJxNFV0bkVFVmJqRVFLcUZWa2ZZNEZ1SjVOU1BIcEdFaXg5NFBHUUdSc2lXCmtHWDB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1b3dkTEwzU09DUE1wTnJtT0JRajhpSkdUKzUKbnY3ZkgxVFdWaDl5VWRSd2hkODFzNUgvUE8zL215TG1ncTBUY1B2ZXd0RUV3WSsrK1Fwc1lad0hURFhneGJidworK2xtSmFsaTRmem1kLzcySnFvY0dBQlloWkZ0MGpiY1ExUUVjcVVZY0QzODArY05WWlBPK3c9PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo=" ---- -# Source: neuron/templates/svc-headless.yaml -apiVersion: v1 -kind: Service -metadata: - name: neuron-headless - namespace: default - labels: - helm.sh/chart: neuron-0.1.0 - app.kubernetes.io/name: neuron - app.kubernetes.io/instance: neuron - app.kubernetes.io/version: "2.0.1" - app.kubernetes.io/managed-by: Helm -spec: - type: ClusterIP - sessionAffinity: None - clusterIP: None - publishNotReadyAddresses: true - ports: - - name: web - port: 7000 - protocol: TCP - targetPort: web - - name: api - port: 7001 - protocol: TCP - targetPort: api - selector: - app.kubernetes.io/name: neuron - app.kubernetes.io/instance: neuron ---- -# Source: neuron/templates/svc.yaml -apiVersion: v1 -kind: Service -metadata: - name: neuron - namespace: default - labels: - helm.sh/chart: neuron-0.1.0 - app.kubernetes.io/name: neuron - app.kubernetes.io/instance: neuron - app.kubernetes.io/version: "2.0.1" - app.kubernetes.io/managed-by: Helm -spec: - type: ClusterIP - ports: - - name: web - port: 7000 - protocol: TCP - targetPort: web - nodePort: null - - name: api - port: 7001 - protocol: TCP - targetPort: api - nodePort: null - selector: - app.kubernetes.io/name: neuron - app.kubernetes.io/instance: neuron ---- -# Source: neuron/templates/statefulset.yaml -apiVersion: apps/v1 -kind: StatefulSet -metadata: - name: neuron - namespace: default - labels: - helm.sh/chart: neuron-0.1.0 - app.kubernetes.io/name: neuron - app.kubernetes.io/instance: neuron - app.kubernetes.io/version: "2.0.1" - app.kubernetes.io/managed-by: Helm -spec: - replicas: 1 - serviceName: neuron-headless - volumeClaimTemplates: - - metadata: - name: neuron-persistence - namespace: default - labels: - app.kubernetes.io/name: neuron - app.kubernetes.io/instance: neuron - app.kubernetes.io/managed-by: Helm - spec: - accessModes: - - "ReadWriteOnce" - resources: - requests: - storage: "20Mi" - selector: - matchLabels: - app.kubernetes.io/name: neuron - app.kubernetes.io/instance: neuron - template: - metadata: - labels: - app.kubernetes.io/name: neuron - app.kubernetes.io/instance: neuron - spec: - volumes: - - name: certs - secret: - secretName: neuron-certs - items: - - key: neuron.pem - path: neuron.pem - - key: neuron.key - path: neuron.key - containers: - - name: neuron - image: "emqx/neuron:2.0.1" - imagePullPolicy: IfNotPresent - readinessProbe: - httpGet: - port: 7000 - initialDelaySeconds: 5 - periodSeconds: 5 - ports: - - name: web - containerPort: 7000 - - name: api - containerPort: 7001 - volumeMounts: - - name: neuron-persistence - mountPath: "/opt/neuron/persistence" - - name: certs - mountPath: "/opt/neuron/config/neuron.pem" - subPath: "neuron.pem" - readOnly: true - - name: certs - mountPath: "/opt/neuron/config/neuron.key" - subPath: "neuron.key" - readOnly: true - resources: - {} - -NOTES: -1. Get the application URL by running these commands: - export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=neuron,app.kubernetes.io/instance=neuron" -o jsonpath="{.items[0].metadata.name}") - export CONTAINER_PORT=$(kubectl get pod --namespace default $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl --namespace default port-forward $POD_NAME 8080:$CONTAINER_PORT diff --git a/deploy/charts/neuron/templates/NOTES.txt b/deploy/charts/neuron/templates/NOTES.txt deleted file mode 100644 index b9da9c87..00000000 --- a/deploy/charts/neuron/templates/NOTES.txt +++ /dev/null @@ -1,22 +0,0 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range $host := .Values.ingress.hosts }} - {{- range .paths }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} - {{- end }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "neuron.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "neuron.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "neuron.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "neuron.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT -{{- end }} diff --git a/deploy/charts/neuron/templates/statefulset.yaml b/deploy/charts/neuron/templates/deployment.yaml similarity index 68% rename from deploy/charts/neuron/templates/statefulset.yaml rename to deploy/charts/neuron/templates/deployment.yaml index 0c637f26..3ae21897 100644 --- a/deploy/charts/neuron/templates/statefulset.yaml +++ b/deploy/charts/neuron/templates/deployment.yaml @@ -1,31 +1,12 @@ apiVersion: apps/v1 -kind: StatefulSet +kind: Deployment metadata: name: {{ include "neuron.fullname" . }} namespace: {{ .Release.Namespace }} labels: {{- include "neuron.labels" . | nindent 4 }} spec: - replicas: {{ .Values.replicaCount }} - serviceName: {{ include "neuron.fullname" . }}-headless - {{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }} - volumeClaimTemplates: - - metadata: - name: neuron-persistence - namespace: {{ .Release.Namespace }} - labels: - {{- include "neuron.selectorLabels" . | nindent 10 }} - app.kubernetes.io/managed-by: {{ .Release.Service }} - spec: - {{- if .Values.persistence.storageClassName }} - storageClassName: {{ .Values.persistence.storageClassName | quote }} - {{- end }} - accessModes: - - {{ .Values.persistence.accessMode | quote }} - resources: - requests: - storage: {{ .Values.persistence.size | quote }} - {{- end }} + replicas: 1 selector: matchLabels: {{- include "neuron.selectorLabels" . | nindent 6 }} @@ -34,17 +15,15 @@ spec: labels: {{- include "neuron.selectorLabels" . | nindent 8 }} spec: + serviceAccountName: {{ include "neuron.serviceAccountName" . }} volumes: - {{- if not .Values.persistence.enabled }} - - name: neuron-persistence - emptyDir: {} - {{- else if .Values.persistence.existingClaim }} - name: neuron-persistence + {{- if .Values.persistence.enabled }} persistentVolumeClaim: - {{- with .Values.persistence.existingClaim }} - claimName: {{ tpl . $ }} + claimName: {{ (tpl .Values.persistence.existingClaim $) | default (include "neuron.fullname" .) }} + {{- else }} + emptyDir: {} {{- end }} - {{- end }} {{- if .Values.tls.enabled }} - name: certs secret: @@ -69,8 +48,14 @@ spec: ports: - name: web containerPort: {{ .Values.containerPorts.web | default 7000 }} + {{- if .Values.hostPorts.enabled }} + hostPort: {{ .Values.hostPorts.web | default 7000 }} + {{- end}} - name: api containerPort: {{ .Values.containerPorts.api | default 7001 }} + {{- if .Values.hostPorts.enabled }} + hostPort: {{ .Values.hostPorts.api | default 7001 }} + {{- end}} volumeMounts: - name: neuron-persistence mountPath: "/opt/neuron/persistence" diff --git a/deploy/charts/neuron/templates/svc-headless.yaml b/deploy/charts/neuron/templates/svc-headless.yaml deleted file mode 100644 index 8cecc6f2..00000000 --- a/deploy/charts/neuron/templates/svc-headless.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "neuron.fullname" . }}-headless - namespace: {{ .Release.Namespace }} - labels: - {{- include "neuron.labels" . | nindent 4 }} -spec: - type: ClusterIP - sessionAffinity: None - clusterIP: None - publishNotReadyAddresses: true - ports: - - name: {{ .Values.service.portNames.web }} - port: {{ .Values.service.ports.web | default 7000 }} - protocol: TCP - targetPort: web - - name: {{ .Values.service.portNames.api }} - port: {{ .Values.service.ports.api | default 7001 }} - protocol: TCP - targetPort: api - selector: - {{- include "neuron.selectorLabels" . | nindent 4 }} diff --git a/deploy/charts/neuron/templates/svc.yaml b/deploy/charts/neuron/templates/svc.yaml index f493aec0..0798a2e4 100644 --- a/deploy/charts/neuron/templates/svc.yaml +++ b/deploy/charts/neuron/templates/svc.yaml @@ -1,3 +1,4 @@ +{{- if .Values.service.enabled }} apiVersion: v1 kind: Service metadata: @@ -36,4 +37,4 @@ spec: {{- end }} selector: {{- include "neuron.selectorLabels" . | nindent 4 }} - +{{- end }} \ No newline at end of file diff --git a/deploy/charts/neuron/values.yaml b/deploy/charts/neuron/values.yaml index 11aef050..20ac2e1b 100644 --- a/deploy/charts/neuron/values.yaml +++ b/deploy/charts/neuron/values.yaml @@ -2,7 +2,6 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. -replicaCount: 1 image: repository: emqx/neuron @@ -15,19 +14,21 @@ nameOverride: "" fullnameOverride: "" serviceAccount: - # Specifies whether a service account should be created + # -- Specifies whether a service account should be created create: true - # Annotations to add to the service account + # -- Annotations to add to the service account annotations: {} - # The name of the service account to use. + # -- The name of the service account to use. # If not set and create is true, a name is generated using the fullname template name: "" podAnnotations: {} +# @ignored podSecurityContext: {} # fsGroup: 2000 +# @ignored securityContext: {} # capabilities: # drop: @@ -37,27 +38,25 @@ securityContext: {} # runAsUser: 1000 service: + enabled: false type: ClusterIP - ## Service ports - ## @param service.ports.web Neuron Dashboard port - ## @param service.ports.api Neuron API port - ## + # -- Service ports ports: + # -- service.ports.web Neuron Dashboard port web: 7000 + # -- service.ports.api Neuron API port api: 7001 - ## Service ports name - ## @param service.portNames.web Neuron Dashboard port name - ## @param service.portNames.api Neuron API port name - ## + # -- Service ports name portNames: + # -- service.portNames.web Neuron Dashboard port name web: "web" + # -- service.portNames.api Neuron API port name api: "api" - ## Specify the nodePort(s) value for the LoadBalancer and NodePort service types. - ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport - ## + # -- Specify the nodePort(s) value for the LoadBalancer and NodePort service types. + # ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport nodePorts: web: api: @@ -68,30 +67,14 @@ service: ## Load Balancer sources ## ref: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/#restrict-access-for-loadbalancer-service ## Example: - ## loadBalancerSourceRanges: - ## - 10.10.10.0/24 - ## - loadBalancerSourceRanges: [] - ## Provide any additional annotations which may be required. Evaluated as a template - ## - annotations: {} - ## Set the LoadBalancer service type to internal only. - ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer - ## - # loadBalancerIP: - ## Load Balancer sources - ## ref: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/#restrict-access-for-loadbalancer-service - ## Example: - ## loadBalancerSourceRanges: - ## - 10.10.10.0/24 - ## + # -- loadBalancerSourceRanges: + # - 10.10.10.0/24 + # loadBalancerSourceRanges: [] - ## Provide any additional annotations which may be required. Evaluated as a template - ## + # -- Provide any additional annotations which may be required. Evaluated as a template annotations: {} - ingress: enabled: false className: "" @@ -110,13 +93,10 @@ ingress: persistence: - enabled: true - size: 20Mi - storageClassName: "" - accessMode: ReadWriteOnce - ## Existing PersistentVolumeClaims - ## The value is evaluated as a template - ## So, for example, the name can depend on .Release or .Chart + enabled: false + # -- Existing PersistentVolumeClaims + # The value is evaluated as a template + # So, for example, the name can depend on .Release or .Chart existingClaim: "" resources: {} @@ -144,12 +124,13 @@ tolerations: [] affinity: {} -## @param clusterDomain Kubernetes Cluster Domain -## +# -- Kubernetes Cluster Domain clusterDomain: cluster.local +# @ignored tls: - enabled: true + enabled: false + # -- neuron public key publicKey: | -----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzrO7FUz4GGKl4nP5lwKM @@ -160,6 +141,7 @@ tls: kGX0vx5udHJ0SlXM6qpMLny18FhWbwKNX3urc3mImn/j3zcJ5x1d+FlXAXs1NBSe TQIDAQAB -----END PUBLIC KEY----- + # -- neuron private key privateKey: | -----BEGIN RSA PRIVATE KEY----- MIIEpAIBAAKCAQEAzrO7FUz4GGKl4nP5lwKMh5uageJAAHnLZpVxTR1wXA9E870s @@ -195,10 +177,16 @@ readinessProbe: initialDelaySeconds: 5 periodSeconds: 5 -## Container Ports -## @param containerPorts.web -## @param containerPorts.api -## +# -- Container Ports containerPorts: + # -- containerPorts.web web: 7000 + # -- containerPorts.api api: 7001 + +# -- only for kubeedge deployment +hostPorts: + enabled: true + web: 30370 + api: 30371 + From 15abb406811b4ba0f2fcfad571753f2d143351c7 Mon Sep 17 00:00:00 2001 From: bin Date: Sun, 10 Jul 2022 22:14:00 +0800 Subject: [PATCH 3/4] refactor: refactor ports value Signed-off-by: bin --- deploy/charts/neuron/README.md | 20 +++++++++--------- deploy/charts/neuron/templates/svc.yaml | 8 ++++---- deploy/charts/neuron/values.yaml | 27 ++++++++++++------------- 3 files changed, 26 insertions(+), 29 deletions(-) diff --git a/deploy/charts/neuron/README.md b/deploy/charts/neuron/README.md index 62c9e98c..06ce7de4 100644 --- a/deploy/charts/neuron/README.md +++ b/deploy/charts/neuron/README.md @@ -32,10 +32,10 @@ helm uninstall my-neuron | containerPorts.api | int | `7001` | containerPorts.api | | containerPorts.web | int | `7000` | containerPorts.web | | fullnameOverride | string | `""` | | -| hostPorts | object | `{"api":30371,"enabled":true,"web":30370}` | only for KubeEdge deployment | +| hostPorts | object | `{"api":30371,"enabled":false,"web":30370}` | only for kubeedge deployment | | image.pullPolicy | string | `"IfNotPresent"` | | | image.repository | string | `"emqx/neuron"` | | -| image.tag | string | `""` | | +| image.tag | string | `""` | Overrides the image tag whose default is the chart appVersion. | | imagePullSecrets | list | `[]` | | | ingress.annotations | object | `{}` | | | ingress.className | string | `""` | | @@ -54,18 +54,16 @@ helm uninstall my-neuron | readinessProbe.periodSeconds | int | `5` | | | resources | object | `{}` | | | service.annotations | object | `{}` | Provide any additional annotations which may be required. Evaluated as a template | -| service.enabled | bool | `false` | | +| service.enabled | bool | `true` | | | service.loadBalancerSourceRanges | list | `[]` | loadBalancerSourceRanges: - 10.10.10.0/24 | | service.nodePorts | object | `{"api":null,"web":null}` | Specify the nodePort(s) value for the LoadBalancer and NodePort service types. ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport | -| service.portNames | object | `{"api":"api","web":"web"}` | Service ports name | -| service.portNames.api | string | `"api"` | service.portNames.api Neuron API port name | -| service.portNames.web | string | `"web"` | service.portNames.web Neuron Dashboard port name | -| service.ports | object | `{"api":7001,"web":7000}` | Service ports | -| service.ports.api | int | `7001` | service.ports.api Neuron API port | -| service.ports.web | int | `7000` | service.ports.web Neuron Dashboard port | +| service.ports | object | `{"api":{"name":"api","port":7001},"web":{"name":"web","port":7000}}` | Service ports | +| service.ports.api.name | string | `"api"` | Neuron API port name | +| service.ports.api.port | int | `7001` | Neuron API port | +| service.ports.web.name | string | `"web"` | Neuron Dashboard port name | +| service.ports.web.port | int | `7000` | Neuron Dashboard port | | service.type | string | `"ClusterIP"` | | | serviceAccount.annotations | object | `{}` | Annotations to add to the service account | | serviceAccount.create | bool | `true` | Specifies whether a service account should be created | | serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template | -| tolerations | list | `[]` | | - +| tolerations | list | `[]` | | \ No newline at end of file diff --git a/deploy/charts/neuron/templates/svc.yaml b/deploy/charts/neuron/templates/svc.yaml index 0798a2e4..24f783e9 100644 --- a/deploy/charts/neuron/templates/svc.yaml +++ b/deploy/charts/neuron/templates/svc.yaml @@ -17,8 +17,8 @@ spec: {{- end }} {{- end }} ports: - - name: {{ .Values.service.portNames.web }} - port: {{ .Values.service.ports.web | default 7000 }} + - name: {{ .Values.service.ports.web.name }} + port: {{ .Values.service.ports.web.port | default 7000 }} protocol: TCP targetPort: web {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.web)) }} @@ -26,8 +26,8 @@ spec: {{- else if eq .Values.service.type "ClusterIP" }} nodePort: null {{- end }} - - name: {{ .Values.service.portNames.api }} - port: {{ .Values.service.ports.api | default 7001 }} + - name: {{ .Values.service.ports.api.name }} + port: {{ .Values.service.ports.api.port | default 7001 }} protocol: TCP targetPort: api {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.api)) }} diff --git a/deploy/charts/neuron/values.yaml b/deploy/charts/neuron/values.yaml index 20ac2e1b..7f127d1e 100644 --- a/deploy/charts/neuron/values.yaml +++ b/deploy/charts/neuron/values.yaml @@ -6,7 +6,7 @@ image: repository: emqx/neuron pullPolicy: IfNotPresent - # Overrides the image tag whose default is the chart appVersion. + # -- Overrides the image tag whose default is the chart appVersion. tag: "" imagePullSecrets: [] @@ -38,22 +38,21 @@ securityContext: {} # runAsUser: 1000 service: - enabled: false + enabled: true type: ClusterIP # -- Service ports ports: - # -- service.ports.web Neuron Dashboard port - web: 7000 - # -- service.ports.api Neuron API port - api: 7001 - - # -- Service ports name - portNames: - # -- service.portNames.web Neuron Dashboard port name - web: "web" - # -- service.portNames.api Neuron API port name - api: "api" + web: + # -- Neuron Dashboard port name + name: "web" + # -- Neuron Dashboard port + port: 7000 + api: + # -- Neuron API port name + name: "api" + # -- Neuron API port + port: 7001 # -- Specify the nodePort(s) value for the LoadBalancer and NodePort service types. # ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport @@ -186,7 +185,7 @@ containerPorts: # -- only for kubeedge deployment hostPorts: - enabled: true + enabled: false web: 30370 api: 30371 From cb328b6478ada877edde55cfa73fe4d859ebc1c2 Mon Sep 17 00:00:00 2001 From: bin Date: Fri, 15 Jul 2022 13:01:44 +0800 Subject: [PATCH 4/4] ci: add ci for helm Signed-off-by: bin --- .github/workflows/check-helm.yaml | 28 +++++++++++++++ .github/workflows/release.yaml | 42 ++++++++++++++++++++++ .github/workflows/test-helm.yaml | 59 +++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+) create mode 100644 .github/workflows/check-helm.yaml create mode 100644 .github/workflows/release.yaml create mode 100644 .github/workflows/test-helm.yaml diff --git a/.github/workflows/check-helm.yaml b/.github/workflows/check-helm.yaml new file mode 100644 index 00000000..83f4505d --- /dev/null +++ b/.github/workflows/check-helm.yaml @@ -0,0 +1,28 @@ +name: Check helm version + +on: + push: + paths: + - deploy/charts/neuron/templates/** + pull_request: + paths: + - deploy/charts/neuron/templates/** + +jobs: + check-helm-version: + runs-on: ubuntu-latest + steps: + - run: minikube start + - uses: actions/checkout@v2 + - name: Update helm + run: | + helm repo add emqx https://repos.emqx.io/charts + helm repo update + - name: Check helm version + run: | + old=$(helm show chart emqx/neuron |egrep "^version" | sed -r 's|^version:[[:space:]]([0-9]+.[0-9]+.[0-9]+)$|\1|g') + now=$(egrep "^version" deploy/charts/neuron/Chart.yaml | sed -r 's|^version:[[:space:]]([0-9]+.[0-9]+.[0-9]+)$|\1|g') + if [ "$old" = "$now" ];then + echo "Need update version for Chart.yaml" + exit 1 + fi diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..151ad6f1 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,42 @@ +name: Release neuron + +on: + push: + tags: + - "*" + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Check appVersion for helm + run: | + appVersion=$(egrep "^appVersion" deploy/charts/neuron/Chart.yaml | sed -r 's|^appVersion:[[:space:]]([0-9]+.[0-9]+.[0-9]+)$|\1|g') + if [ "$appVersion" != "${GITHUB_REF##*/}" ]; then + echo "Need update appVersion for Chart.yaml" + exit 1 + fi + + helm: + runs-on: self-hosted + if: github.repository_owner == 'emqx' + needs: + - release + steps: + - uses: actions/checkout@v2 + - name: Check appVersion for helm + working-directory: deploy/charts/neuron + run: | + appVersion=$(egrep "^appVersion" Chart.yaml | sed -r 's|^appVersion:[[:space:]]([0-9]+.[0-9]+.[0-9]+)$|\1|g') + if [ "$appVersion" != "${GITHUB_REF##*/}" ]; then + echo "Need update appVersion for Chart.yaml" + exit 1 + fi + - name: Create helm package + working-directory: deploy/charts/neuron + run: helm package . + - name: Update helm repo + run: | + sudo mv $(find deploy/charts/neuron -name "*.tgz") /repos/charts + sudo helm repo index /repos/charts \ No newline at end of file diff --git a/.github/workflows/test-helm.yaml b/.github/workflows/test-helm.yaml new file mode 100644 index 00000000..d5260e6e --- /dev/null +++ b/.github/workflows/test-helm.yaml @@ -0,0 +1,59 @@ +name: Test helm +inputs: + repository: + description: "neuron image repository" + required: true + default: "emqx/neuron" + tag: + description: "neuron image tag" + required: true + default: "2.0.1" + +on: + push: + tags: + - "*" + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - run: minikube start --kubernetes-version="v1.23.0" + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: '1.18.3' + - name: install kubebuilder + run: | + OS=$(uname -s | tr '[:upper:]' '[:lower:]') + ARCH=$(uname -m | sed 's/x86_64/amd64/') + curl -fsL "https://storage.googleapis.com/kubebuilder-tools/kubebuilder-tools-1.16.4-${OS}-${ARCH}.tar.gz" -o kubebuilder-tools + tar -zxvf kubebuilder-tools + sudo mv kubebuilder/ /usr/local/kubebuilder + - run: make test + + deployment: + runs-on: ubuntu-latest + steps: + - run: minikube start --kubernetes-version="v1.23.0" + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: '1.18.3' + - name: Deploy neuron by helm + shell: bash + run: | + helm install neuron deploy/charts/neuron\ + --set image.repository=${{ inputs.repository }} \ + --set image.tag=${{ inputs.tag }} + - name: Check deployment + run: | + while [ "$(kubectl get Deployment -l app.kubernetes.io/name=neuron -o jsonpath='{.items[0].status.replicas}')" \ + != "$(kubectl get Deployment -l app.kubernetes.io/name=neuron -o jsonpath='{.items[0].status.readyReplicas}')" ]; do + echo "==============================" + kubectl get pods + echo "==============================" + echo "waiting neuron started" + sleep 10 + done