1.去helm仓库拉取nacos包
https://artifacthub.io/packages/helm/kubegemsapp/nacos?modal=install
helm repo add kubegemsapp https://charts.kubegems.io/kubegemsapp
helm pull kubegemsapp/nacos
tar -zxvf nacos-0.1.5.tgz
mkdir -p nacos/ci/test
2.修改chart配置文件
注释nacos/values.yaml 与nacos/ci/values.yaml里面的数据库,
3.将nacos/values.yaml这个文件内容拷贝到nacos/ci/values.yaml,新增的文件里面将单点改为了集群模式,部署三个实例,
cp values.yaml ci/
改动1单点改为集群模式
改动2由一个实例启动改为三个实例启动
改动3,pvc磁盘改为false(关闭pvc挂载),不关闭就无法启动
这个nacos/ci/values.yaml文件启动的时候加了-f在后面,会默认覆盖前面的配置,只有这个文件里面没有的才会读取前一级的values.yaml
#这个是自己加的参数固定到一台机器上面运行pod,不想在一台机器上启动可以去掉
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: nacos.comm
operator: In
values:
- "true"
# Default values for nacos.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
global:
#mode: standalone
mode: cluster
nameOverride: nacos
fullnameOverride: nacos
############################nacos###########################
nacos:
image:
repository: registry.cn-beijing.aliyuncs.com/kubegemsapp/nacos-server
tag: 2.0.2
pullPolicy: IfNotPresent
plugin:
enable: true
image:
repository: registry.cn-beijing.aliyuncs.com/kubegemsapp/nacos-peer-finder-plugin
tag: 1.1
replicaCount: 3
domainName: cluster.local
preferhostmode: hostname
serverPort: 8848
health:
enabled: true
# storage:
# type: mysql
# db:
# host: localhost
# name: nacos
# port: 3306
# username: usernmae
# password: password
# param: characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false
persistence:
enabled: false
data:
accessModes:
- ReadWriteOnce
storageClassName: local-path
resources:
requests:
storage: Gi
service:
#type: ClusterIP
type: ClusterIP
port: 8848
#nodePort: 30000
ingress:
enabled: false
annotations: { }
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: nacos.example.com
paths: [ ]
tls: [ ]
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
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: "1"
memory: 2.5Gi
requests:
cpu: 500m
memory: 2Gi
annotations: { }
nodeSelector: { }
tolerations: [ ]
affinity: { }
3.增加数据库配置,nacos/ci/test/values.yaml 改成自己的数据库配置,name为数据库名称
values.yaml
nacos:
storage:
type: mysql
db:
host: percona80-master.devops
name: nacos
port: "3306"
username: nacos
password: password
param: characterEncoding=utf8&connectTimeout=60000&socketTimeout=180000&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true
启动命令
helm upgrade nacos ./nacos/ -f ./nacos/ci/values.yaml -f ./nacos/ci/test/values.yaml -i -n default
helm list -n default
helm uninstall nacos -n default
查看运行成功