首页 技术 正文
技术 2022年11月6日
0 收藏 662 点赞 562 浏览 2915 个字

阿里nacos k8s部署

[root@master1 nacos]# cat nacos-quick-start.yaml
---
apiVersion: v1
kind: Service
metadata:
namespace: testhip
name: nacos-headless
labels:
app: nacos-headless
spec:
ports:
- port:
name: server
targetPort:
selector:
app: nacos
---
apiVersion: v1
kind: ConfigMap
metadata:
namespace: testhip
name: nacos-cm
data:
mysql.master.db.name: "nacos_devtest"
mysql.master.port: ""
mysql.slave.port: ""
mysql.master.user: "nacos"
mysql.master.password: "nacos"
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
namespace: testhip
name: nacos
spec:
serviceName: nacos-headless
replicas:
template:
metadata:
labels:
app: nacos
annotations:
pod.alpha.kubernetes.io/initialized: "true"
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "app"
operator: In
values:
- nacos-headless
topologyKey: "kubernetes.io/hostname"
containers:
- name: k8snacos
imagePullPolicy: Always
image: 192.168.200.10/nacos/nacos-server:latest
resources:
requests:
memory: "2Gi"
cpu: "500m"
ports:
- containerPort:
name: client
env:
- name: NACOS_REPLICAS
value: ""
- name: MYSQL_MASTER_SERVICE_DB_NAME
valueFrom:
configMapKeyRef:
name: nacos-cm
key: mysql.master.db.name
- name: MYSQL_MASTER_SERVICE_PORT
valueFrom:
configMapKeyRef:
name: nacos-cm
key: mysql.master.port
- name: MYSQL_SLAVE_SERVICE_PORT
valueFrom:
configMapKeyRef:
name: nacos-cm
key: mysql.slave.port
- name: MYSQL_MASTER_SERVICE_USER
valueFrom:
configMapKeyRef:
name: nacos-cm
key: mysql.master.user
- name: MYSQL_MASTER_SERVICE_PASSWORD
valueFrom:
configMapKeyRef:
name: nacos-cm
key: mysql.master.password
- name: NACOS_SERVER_PORT
value: ""
- name: PREFER_HOST_MODE
value: "hostname"
- name: NACOS_SERVERS
value: "nacos-0.nacos-headless.testhip.svc.cluster.local.:8848 nacos-1.nacos-headless.testhip.svc.cluster.local.:8848 nacos-2.nacos-headless.testhip.svc.cluster.local.:8848"
volumeMounts:
- name: datadir
mountPath: /home/nacos/data
- name: logdir
mountPath: /home/nacos/logs
volumeClaimTemplates:
- metadata:
namespace: testhip
name: datadir
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: ceph-rbd-provisioner-testhip
resources:
requests:
storage: 30Gi
- metadata:
namespace: testhip
name: logdir
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: ceph-rbd-provisioner-testhip
resources:
requests:
storage: 30Gi
selector:
matchLabels:
app: nacos
kubectl label pod nacos- nacosInst= -n testhipkubectl expose pod nacos- --port= --target-port= --name=nacos- --selector=nacosInst= --type=NodePort -n testhip

最容易出问题的是 nacos的主机名,与 nacos的配置文件不相同

#注意  nacos-0.nacos.senyint.svc.cluster.local.  带一个点, yaml 中没有点,

[root@nacos- conf]# cat cluster.conf nacos-.nacos.testhip.svc.cluster.local.:
nacos-.nacos.testhip.svc.cluster.local.:
nacos-.nacos.testhip.svc.cluster.local.:

nacos-0 /etc/hosts 中不带点

[root@nacos- conf]# cat /etc/hosts
# Kubernetes-managed hosts file.
127.0.0.1 localhost
:: localhost ip6-localhost ip6-loopback
fe00:: ip6-localnet
fe00:: ip6-mcastprefix
fe00:: ip6-allnodes
fe00:: ip6-allrouters
10.20.3.90 nacos-.nacos.testhip.svc.cluster.local. nacos-

#错误日志

[root@nacos- logs]# cat naming-raft.log WARN [IS LEADER] no leader is available now!#没有选leader,所以需要部署集群
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,491
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,492
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,132
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,293