BS问题:k8s部署Nacos Could not resolve placeholder ‘NACOS_AUTH_IDENTITY_KEY‘ in value “${NACOS_AUTH_IDENT
Nacos镜像: nacos/nacos-server:latest。然后pods一直重启,查看pod日志。上面参数官方文档上有相关描述。启动pod的Yaml文件。我按照官方文档执行到。这个参数怎么会少呢?
官网文档2.X
Nacos镜像: nacos/nacos-server:latest
我按照官方文档执行到
- 验证Nacos节点启动成功
然后pods一直重启,查看pod日志
这个参数怎么会少呢?
启动pod的Yaml文件
---
apiVersion: v1
kind: Service
metadata:
name: nacos-headless
labels:
app: nacos
spec:
publishNotReadyAddresses: true
ports:
- port: 8848
name: server
targetPort: 8848
- port: 9848
name: client-rpc
targetPort: 9848
- port: 9849
name: raft-rpc
targetPort: 9849
## 兼容1.4.x版本的选举端口
- port: 7848
name: old-raft-rpc
targetPort: 7848
clusterIP: None
selector:
app: nacos
---
apiVersion: v1
kind: ConfigMap
metadata:
name: nacos-cm
data:
mysql.host: "10.110.240.135"
mysql.db.name: "nacos_devtest"
mysql.port: "3306"
mysql.user: "nacos"
mysql.password: "nacos"
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: nacos
spec:
podManagementPolicy: Parallel
serviceName: nacos-headless
replicas: 3
template:
metadata:
labels:
app: nacos
annotations:
pod.alpha.kubernetes.io/initialized: "true"
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "app"
operator: In
values:
- nacos
topologyKey: "kubernetes.io/hostname"
serviceAccountName: nfs-client-provisioner
initContainers:
- name: peer-finder-plugin-install
image: nacos/nacos-peer-finder-plugin:1.1
imagePullPolicy: Always
volumeMounts:
- mountPath: /home/nacos/plugins/peer-finder
name: data
subPath: peer-finder
containers:
- name: nacos
imagePullPolicy: Always
image: nacos/nacos-server:latest
resources:
requests:
memory: "200m"
cpu: "500m"
ports:
- containerPort: 8848
name: client-port
- containerPort: 9848
name: client-rpc
- containerPort: 9849
name: raft-rpc
- containerPort: 7848
name: old-raft-rpc
env:
- name: NACOS_REPLICAS
value: "3"
- name: SERVICE_NAME
value: "nacos-headless"
- name: DOMAIN_NAME
value: "cluster.local"
- name: POD_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: MYSQL_SERVICE_HOST
valueFrom:
configMapKeyRef:
name: nacos-cm
key: mysql.host
- name: MYSQL_SERVICE_DB_NAME
valueFrom:
configMapKeyRef:
name: nacos-cm
key: mysql.db.name
- name: MYSQL_SERVICE_PORT
valueFrom:
configMapKeyRef:
name: nacos-cm
key: mysql.port
- name: MYSQL_SERVICE_USER
valueFrom:
configMapKeyRef:
name: nacos-cm
key: mysql.user
- name: MYSQL_SERVICE_PASSWORD
valueFrom:
configMapKeyRef:
name: nacos-cm
key: mysql.password
- name: SPRING_DATASOURCE_PLATFORM
value: "mysql"
- name: NACOS_SERVER_PORT
value: "8848"
- name: NACOS_APPLICATION_PORT
value: "8848"
- name: PREFER_HOST_MODE
value: "hostname"
volumeMounts:
- name: data
mountPath: /home/nacos/plugins/peer-finder
subPath: peer-finder
- name: data
mountPath: /home/nacos/data
subPath: data
- name: data
mountPath: /home/nacos/logs
subPath: logs
volumeClaimTemplates:
- metadata:
name: data
annotations:
volume.beta.kubernetes.io/storage-class: "managed-nfs-storage"
spec:
accessModes: [ "ReadWriteMany" ]
resources:
requests:
storage: 20Gi
selector:
matchLabels:
app: nacos
尝试修改配置文件增加环境变量env:
-name: NACOS_AUTH_IDENTITY_KEY
value: serverIdentity
但是依然无效
上面参数官方文档上有相关描述
尝试切换nacos镜像版本:v2.2.0 docker pull nacos/nacos-server:v2.2.0
然后在启动就这样了
第一种情况(没有执行sql初始化语句)的解决办法:
https://github.com/nacos-group/nacos-k8s/issues/205
在GitHub上找到了答案,感谢这位大佬
在前面的流程中,看到了这个sql的初始化语言,由于当时打开链接404就没有管了
这个文件已经不再这个地方了
nacos-k8s/nacos-mysql.sql at master · nacos-group/nacos-k8s · GitHubzz
执行SQL完成后,启动终于成功了!
没有重启次数了
第二种(nacos-pvc-nfs.yaml配置的mysql service地址变更了)情况的解决办法:
原因:在nacos-pvc-nfs.yaml 文件中的mysql.host: "10.102.179.83" (msyql service地址)变更了,导致nacos启动时找不到数据库
修改mysql service 地址
更多推荐
所有评论(0)