1. nacos部署
服务镜像:nacos/nacos-server:1.4.0
插件镜像:nacos/nacos-peer-finder-plugin:1.0
在conf/Cluster.conf 中整合了所有实例的地址。peer-finder会轮询(1秒)指定的k8s service ,如果service下面的pod地址列表发生变化,则重新写入Cluster.conf文件。大致调用关系如图:
1.1 单机模式:
docker run \--name nacos1.4.0 \--privileged=true \-p 8848:8848 \-e PREFER_HOST_MODE=ip \-e MODE=standalone \-e NACOS_SERVER_PORT=8848 \-v /xxx/nacos/data:/home/nacos/data \-v /xxx/nacos/logs:/home/nacos/logs \-d nacos/nacos-server:1.4.0
Nacos 控制台:http://ip:8848/nacos/
用户名和密码:nacos/nacos
1.2 集群模式:
1.2.1 导入yml文件,创建nfs存储类
需先替换文件中的nfs服务器地址以及nfs目录
#创建serviceaccount及授权---kind: ServiceAccountapiVersion: v1metadata: name: nfs-client-provisioner---kind: ClusterRoleapiVersion: rbac.authorization.k8s.io/v1metadata: name: nfs-client-provisioner-runnerrules: - apiGroups: [""] resources: ["persistentvolumes"] verbs: ["get", "list", "watch", "create", "delete"] - apiGroups: [""] resources: ["persistentvolumeclaims"] verbs: ["get", "list", "watch", "update"] - apiGroups: ["storage.k8s.io"] resources: ["storageclasses"] verbs: ["get", "list", "watch"] - apiGroups: [""] resources: ["events"] verbs: ["list", "watch", "create", "update", "patch"] - apiGroups: [""] resources: ["endpoints"] verbs: ["get", "list", "watch", "create", "update", "patch"]---kind: ClusterRoleBindingapiVersion: rbac.authorization.k8s.io/v1metadata: name: run-nfs-client-provisionersubjects: - kind: ServiceAccount name: nfs-client-provisioner namespace: defaultroleRef: kind: ClusterRole name: nfs-client-provisioner-runner apiGroup: rbac.authorization.k8s.io#部署nfs-client-provisioner---kind: DeploymentapiVersion: extensions/v1beta1metadata: name: nfs-client-provisionerspec: replicas: 1 strategy: type: Recreate template: metadata: labels: app: nfs-client-provisioner spec: serviceAccountName: nfs-client-provisioner containers: - name: nfs-cli