diff --git a/helm/CHANGELOG.md b/helm/CHANGELOG.md new file mode 100644 index 0000000..9a06297 --- /dev/null +++ b/helm/CHANGELOG.md @@ -0,0 +1,17 @@ +**Note:** This file is automatically generated. Please see the [developer +documentation](doc/development/changelog.md) for instructions on adding your own +entry. + +## 0.1.0 (2020-02-31) + +### Other (1 change) + +- Update helm deploy nacos + + +## 0.1.1 (2020-04-26) + +### Other (1 change) + +- Update nacos mysql + diff --git a/helm/Chart.yaml b/helm/Chart.yaml index cc01793..9b9b913 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -1,7 +1,12 @@ apiVersion: v1 appVersion: "1.0" -description: A Helm chart for Kubernetes -name: nacos -version: 0.1.0 +description: use helm to deloy nacos cluster. +home: https://nacos.io/en-us/ +icon: https://nacos.io/img/nacos.png maintainers: -- name: arrowfeng +- email: huangmnlove@163.com + name: arrowfeng +name: nacos +sources: +- https://github.com/nacos-group/nacos-k8s +version: 0.1.1 diff --git a/helm/README.md b/helm/README.md index 27ec509..19c8a09 100644 --- a/helm/README.md +++ b/helm/README.md @@ -9,19 +9,44 @@ This project is based on the Helm Chart packaged by [nacos-k8s](https://github.c ## Prerequisites - Kubernetes 1.10+ - - Helm v3 + - Helm v2+ - PV provisioner support in the underlying infrastructure ## Installing the Chart +To install nfs-client-provisioner,Must have NFS server first: + +```shell +$ helm repo add stable https://kubernetes-charts.storage.googleapis.com +$ helm repo update +$ helm install --namespace kube-system \ +--set nfs.server=192.168.1.2 --set nfs.path=/k8s-data --set storageClass.reclaimPolicy=Retain \ +--set storageClass.defaultClass=true,storageClass.name=nfs \ +--name nfs-client-provisioner stable/nfs-client-provisioner --version=1.2.8 +``` + + + To install the chart with `release name`: ```shell -$ helm install `release name` ./nacos +$ helm repo update +$ helm dependency update +$ helm install --namespace `name` --set global.mode=cluster --name `release name` ./nacos ``` The command deploys Nacos on the Kubernetes cluster in the default configuration. It will run without a mysql chart and persistent volume. The [configuration](#configuration) section lists the parameters that can be configured during installation. +Update nacos to the latest version + +```shell +$ helm upgrade `release name` \ +--set mysql.image=nacos/nacos-mysq,mysql.imageTag=latest \ +--set image.repository=nacos/nacos-server,image.tag=latest \ +--set plugins.repository=nacos/nacos-peer-finder-plugin,plugins.tag=latest \ +./nacos +``` + ### Service & Configuration Management #### Service registration @@ -145,5 +170,5 @@ $ kubectl scale sts `release name`-nacos --replicas=3 ![img](../images/cluster2.png) * Use kubectl exec to get the cluster config of the Pods in the nacos StatefulSet after scale StatefulSets - + ![img](../images/cluster3.png) diff --git a/helm/charts/mysql-1.6.3.tgz b/helm/charts/mysql-1.6.3.tgz new file mode 100644 index 0000000..935f71b Binary files /dev/null and b/helm/charts/mysql-1.6.3.tgz differ diff --git a/helm/charts/mysql/.helmignore b/helm/charts/mysql/.helmignore deleted file mode 100644 index 50af031..0000000 --- a/helm/charts/mysql/.helmignore +++ /dev/null @@ -1,22 +0,0 @@ -# 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 -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/helm/charts/mysql/Chart.yaml b/helm/charts/mysql/Chart.yaml deleted file mode 100644 index d4970f8..0000000 --- a/helm/charts/mysql/Chart.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: v1 -appVersion: "1.0" -description: A Helm chart for Kubernetes -name: mysql -version: 0.1.0 diff --git a/helm/charts/mysql/templates/mysql-deployment.yaml b/helm/charts/mysql/templates/mysql-deployment.yaml deleted file mode 100644 index 5003973..0000000 --- a/helm/charts/mysql/templates/mysql-deployment.yaml +++ /dev/null @@ -1,71 +0,0 @@ -{{- if ne .Values.global.mode "quickstart" }} -apiVersion: v1 -kind: ReplicationController -metadata: - name: mysql - labels: - name: mysql - {{- if .Values.mysql.annotations }} - annotations: -{{ toYaml .Values.mysql.annotations | indent 4 }} - {{- end }} -spec: - replicas: 1 - selector: - name: mysql - template: - metadata: - labels: - name: mysql - spec: - containers: - - name: mysql - image: "{{ .Values.mysql.image.repository }}:{{ .Values.mysql.image.tag }}" - imagePullPolicy: {{ .Values.mysql.image.pullPolicy }} - ports: - - name: mysql - containerPort: 3306 - protocol: TCP - volumeMounts: - - name: mysql-data - mountPath: /var/lib/mysql - env: - - name: MYSQL_ROOT_PASSWORD - value: {{ .Values.mysql.rootPassword | quote }} - - name: MYSQL_DATABASE - value: {{ .Values.mysql.database | quote }} - - name: MYSQL_USER - value: {{ .Values.mysql.user | quote }} - - name: MYSQL_PASSWORD - value: {{ .Values.mysql.password | quote }} - resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- if not .Values.mysql.persistence.enabled }} - volumes: - - name: mysql-data - emptyDir: {} - {{- else if .Values.mysql.persistence.existingClaim }} - volumes: - - name: mysql-data - persistentVolumeClaim: - claimName: {{ .Values.mysql.persistence.existingClaim }} - {{- end }} - {{- if and .Values.mysql.persistence.enabled (not .Values.mysql.persistence.existingClaim) }} - volumes: - - name: mysql-data - persistentVolumeClaim: - claimName: {{ .Values.mysql.persistence.claim}} - {{- end}} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} -{{- end }} diff --git a/helm/charts/mysql/templates/mysql-pvc.yaml b/helm/charts/mysql/templates/mysql-pvc.yaml deleted file mode 100644 index 5de9b2a..0000000 --- a/helm/charts/mysql/templates/mysql-pvc.yaml +++ /dev/null @@ -1,10 +0,0 @@ -{{- if ne .Values.global.mode "quickstart" }} -{{- if and .Values.mysql.persistence.enabled (not .Values.mysql.persistence.existingClaim) -}} -kind: PersistentVolumeClaim -apiVersion: v1 -metadata: - name: {{ .Values.mysql.persistence.claim.name }} -spec: - {{ toYaml .Values.mysql.persistence.claim.spec | indent 2 }} -{{- end }} -{{- end }} diff --git a/helm/charts/mysql/templates/mysql-service.yaml b/helm/charts/mysql/templates/mysql-service.yaml deleted file mode 100644 index 8d5c880..0000000 --- a/helm/charts/mysql/templates/mysql-service.yaml +++ /dev/null @@ -1,16 +0,0 @@ -{{- if ne .Values.global.mode "quickstart" }} -apiVersion: v1 -kind: Service -metadata: - name: mysql - labels: - name: mysql -spec: - ports: - - port: {{ .Values.mysql.service.port }} - targetPort: mysql - protocol: TCP - name: mysql - selector: - name: mysql -{{- end }} diff --git a/helm/charts/mysql/templates/storageclass.yaml b/helm/charts/mysql/templates/storageclass.yaml deleted file mode 100644 index 0172513..0000000 --- a/helm/charts/mysql/templates/storageclass.yaml +++ /dev/null @@ -1,11 +0,0 @@ -{{- if and .Values.mysql.persistence.enabled (not .Values.mysql.persistence.existingClaim) -}} -apiVersion: storage.k8s.io/v1 -kind: StorageClass -metadata: - name: {{ .Values.mysql.persistence.claim.spec.storageClassName }} -provisioner: -{{ toYaml .Values.global.storageClass.provisioner | indent 2 }} -parameters: -{{ toYaml .Values.mysql.classParameters | indent 2 }} -{{- end }} - diff --git a/helm/charts/mysql/values.yaml b/helm/charts/mysql/values.yaml deleted file mode 100644 index 98a0b39..0000000 --- a/helm/charts/mysql/values.yaml +++ /dev/null @@ -1,47 +0,0 @@ -## Default values for nacos. -## This is a YAML-formatted file. -## Declare variables to be passed into your templates. -# -#global: -# mode: quickstart -# #mode: standalone -# #mode: cluster -# storageClass: -# provisioner: -# #nfs -# # provisioner: fuseim.pri/ifs -# ###ceph -# # provisioner: ceph.com/rbd -# -#############################mysql########################### -############################mysql########################### -mysql: - annotations: {} - resources: {} - nodeSelector: {} - affinity: {} - tolerations: {} - service: - port: 3306 - rootPassword: root - database: nacos_devtest - user: nacos - password: nacos - image: - pullPolicy: IfNotPresent - repository: nacos/nacos-mysql - tag: 5.7 - classParameters: {} - persistence: - enabled: false - existingClaim: mysql-data - #existingClaim: - claim: - name: mysql-data - spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 5G - storageClassName: sc-mysql diff --git a/helm/requirements.lock b/helm/requirements.lock new file mode 100644 index 0000000..8ded535 --- /dev/null +++ b/helm/requirements.lock @@ -0,0 +1,6 @@ +dependencies: +- name: mysql + repository: https://kubernetes-charts.storage.googleapis.com + version: 1.6.3 +digest: sha256:15c35804b0f493351f12c6fe039a3837e9e02d2ac9cf62a0b6fa85e26044b96e +generated: "2020-04-25T21:45:10.90741954+08:00" diff --git a/helm/requirements.yaml b/helm/requirements.yaml new file mode 100644 index 0000000..d1f502b --- /dev/null +++ b/helm/requirements.yaml @@ -0,0 +1,6 @@ +dependencies: +- name: mysql + version: 1.6.3 + repository: https://kubernetes-charts.storage.googleapis.com + condition: mysql.install + alias: mysql diff --git a/helm/templates/NOTES.txt b/helm/templates/NOTES.txt index 8fa1474..3ef406e 100644 --- a/helm/templates/NOTES.txt +++ b/helm/templates/NOTES.txt @@ -23,4 +23,4 @@ 2. MODE: quickstart: you need to modify replicaCount in the values.yaml, .Values.replicaCount=1 standalone: you need to modify replicaCount in the values.yaml, .Values.replicaCount=1 - cluster: kubectl scale sts {{ .Release.Namespace }}-nacos --replicas=3 + cluster: kubectl -n {{ .Release.Namespace }} scale sts {{ include "nacos.fullname" . }} --replicas=3 diff --git a/helm/templates/deployment.yaml b/helm/templates/StatefulSet.yaml similarity index 96% rename from helm/templates/deployment.yaml rename to helm/templates/StatefulSet.yaml index f780061..b4dc827 100644 --- a/helm/templates/deployment.yaml +++ b/helm/templates/StatefulSet.yaml @@ -24,8 +24,8 @@ spec: {{- if eq .Values.global.mode "cluster" }} initContainers: - name: peer-finder-plugin-install - image: nacos/nacos-peer-finder-plugin:1.0 - imagePullPolicy: Always + image: "{{ .Values.plugins.repository }}:{{ .Values.plugins.tag}}" + imagePullPolicy: {{ .Values.image.pullPolicy }} volumeMounts: - mountPath: /home/nacos/plugins/peer-finder name: plugindir @@ -91,7 +91,7 @@ spec: - name: SERVICE_NAME value: "nacos-hs" - name: DOMAIN_NAME - value: {{ .Values.env.domainNmae | quote }} + value: {{ .Values.env.domainName | quote }} - name: POD_NAMESPACE valueFrom: fieldRef: diff --git a/helm/templates/configmap.yaml b/helm/templates/configmap.yaml index cd903e8..0f5215f 100644 --- a/helm/templates/configmap.yaml +++ b/helm/templates/configmap.yaml @@ -5,9 +5,9 @@ metadata: name: nacos-cm data: {{- with .Values.mysql }} - mysql.db.name: {{ .database }} + mysql.db.name: {{ .mysqlDatabase }} mysql.port: "3306" - mysql.user: {{ .user }} - mysql.password: {{ .password }} + mysql.user: {{ .mysqlUser }} + mysql.password: {{ .mysqlPassword }} {{- end }} {{- end }} diff --git a/helm/templates/ingress.yaml b/helm/templates/ingress.yaml index 377d29d..64858d7 100644 --- a/helm/templates/ingress.yaml +++ b/helm/templates/ingress.yaml @@ -1,6 +1,11 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "nacos.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} apiVersion: extensions/v1beta1 +{{- end }} kind: Ingress metadata: name: {{ $fullName }} @@ -30,7 +35,7 @@ spec: - path: {{ . }} backend: serviceName: nacos-cs - servicePort: http + servicePort: {{ $svcPort }} {{- end }} {{- end }} {{- end }} diff --git a/helm/templates/storageclass.yaml b/helm/templates/storageclass.yaml deleted file mode 100644 index c41b53a..0000000 --- a/helm/templates/storageclass.yaml +++ /dev/null @@ -1,10 +0,0 @@ -{{- if and .Values.persistence.enabled .Values.persistence.storageClass -}} -apiVersion: storage.k8s.io/v1 -kind: StorageClass -metadata: - name: {{ .Values.persistence.storageClassName }} -provisioner: -{{ toYaml .Values.global.storageClass.provisioner | indent 2 }} -parameters: -{{ toYaml .Values.persistence.classParameters | indent 2 }} -{{- end }} diff --git a/helm/values.yaml b/helm/values.yaml index 1dd6fd3..e7809cd 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -3,79 +3,80 @@ # Declare variables to be passed into your templates. global: - mode: quickstart + #mode: quickstart #mode: standalone - #mode: cluster - storageClass: - provisioner: - #nfs - # provisioner: fuseim.pri/ifs - ###ceph - # provisioner: ceph.com/rbd + mode: cluster ############################mysql########################### mysql: - annotations: {} - resources: {} - nodeSelector: {} - affinity: {} - tolerations: {} - service: - port: 3306 - rootPassword: root - database: nacos_devtest - user: nacos - password: nacos - image: - pullPolicy: IfNotPresent - repository: nacos/nacos-mysql - tag: 5.7 - classParameters: {} + image: "nacos/nacos-mysq" + imageTag: "5.7" + + strategy: + type: Recreate + + busybox: + image: "busybox" + tag: "1.29.3" + + ## Specify password for root user + ## + ## Default: random 10 character string + mysqlRootPassword: root + + ## Create a database user + ## + mysqlUser: nacos + ## Default: random 10 character string + mysqlPassword: nacos + + ## Allow unauthenticated access, uncomment to enable + ## + # mysqlAllowEmptyPassword: true + + ## Create a database + mysqlDatabase: nacos_devtest + + # Optionally specify an array of imagePullSecrets. + # Secrets must be manually created in the namespace. + # ref: https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod + # imagePullSecrets: + # - name: myRegistryKeySecretName + + ## Persist data to a persistent volume persistence: + enabled: true + ## database data Persistent Volume Storage Class + ## If defined, storageClassName: + ## If set to "-", storageClassName: "", which disables dynamic provisioning + ## If undefined (the default) or set to null, no storageClassName spec is + ## set, choosing the default provisioner. (gp2 on AWS, standard on + ## GKE, AWS & OpenStack) + ## + # storageClass: "-" + storageClass: "nfs" + accessMode: ReadWriteOnce + size: 8Gi + annotations: {} + + metrics: enabled: false - existingClaim: mysql-data - #existingClaim: - claim: - name: mysql-data - spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 5G - storageClassName: sc-mysql - - - - -######nfs -# archiveOnDelete: "false" - -######ceph -# monitors: 10.144.131.48:6789 -# adminId: admin -# adminSecretName: ceph-secret-admin -# adminSecretNamespace: nacos -# pool: nacos-mysql-data -# userId: mysql -# userSecretName: ceph-secret-mysql -# userSecretNamespace: nacos -# fsType: ext4 -# imageFormat: "2" -# imageFeatures: "layering" - - - - - -############################mysql########################### - + image: prom/mysqld-exporter + imageTag: v0.10.0 + imagePullPolicy: IfNotPresent + resources: {} ############################nacos########################### + replicaCount: 1 image: repository: nacos/nacos-server - tag: latest + tag: 1.2.1 + pullPolicy: IfNotPresent + +plugins: + repository: nacos/nacos-peer-finder-plugin + tag: "1.0" pullPolicy: IfNotPresent health: @@ -85,30 +86,29 @@ env: domainName: cluster.local preferhostmode: hostname serverPort: 8848 -# dbHost: 127.0.0.1 + dbHost: nacos-mysql persistence: - enabled: false - storageClassName: sc-nacos + enabled: true classParameters: {} data: accessModes: - ReadWriteOnce - storageClassName: manual + storageClassName: nfs resources: requests: storage: 5Gi plugin: accessModes: - ReadWriteOnce - storageClassName: manual + storageClassName: nfs resources: requests: storage: 5Gi log: accessModes: - ReadWriteOnce - storageClassName: manual + storageClassName: nfs resources: requests: storage: 5Gi @@ -119,22 +119,22 @@ service: port: 8848 nodePort: 30000 - ingress: - enabled: false + enabled: true annotations: {} # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" hosts: - - host: nacos.example.com - paths: [] + - host: chart-example.local + paths: + - /nacos tls: [] # - secretName: chart-example-tls # hosts: # - chart-example.local -resources: +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 @@ -142,16 +142,12 @@ resources: # limits: # cpu: 100m # memory: 128Mi - requests: - cpu: 500m - memory: 2Gi -annotations: {} + # requests: + # cpu: 100m + # memory: 128Mi nodeSelector: {} tolerations: [] affinity: {} - - -