0、准备工作
kubernetes:1.20.4
kubersphere:3.1.1
nacos:1.4.2
开放云服务器的安全组 30000 ~ 32767 TCP端口
1、下载nacos1.4.2
链接:https://pan.baidu.com/s/1hyffniJTN2lmX_iiHDW4Tw
提取码:4buw
2、修改相关配置文件(这里的数据哭url是我自己的mysql服务的dns)
(1)application.properties
### If use MySQL as datasource: spring.datasource.platform=mysql ### Count of DB: db.num=1 ### Connect URL of DB: db.url.0=jdbc:mysql://edu-mysql.edu:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC db.user.0=root db.password.0=数据库密码
(2)数据库创建nacos数据库,相关sql在nacos的conf文件夹下
(3)修改cluster-conf文件(这里的是我的nacos服务的dns)
# # Copyright 1999-2018 Alibaba Group Holding Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR ConDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # #it is ip #example edu-nacos-v1-0.edu-nacos.edu.svc.cluster.local:8848 edu-nacos-v1-1.edu-nacos.edu.svc.cluster.local:8848 edu-nacos-v1-2.edu-nacos.edu.svc.cluster.local:8848
(4)在kubesphere中创建这两个配置文件(键就是文件的名字,值就是配置内容,复制所有相关配置内容)
3、创建一个nacos的有状态服务
(1)去dockerhub找到nacos1.4.2镜像
(2)相关配置模板
存活探针
挂载配置文件(点击子路径 填写配置文件名 这种形式不会替换整个文件夹,只会替换对应的这个文件):
4、创建完成,进入pod查看日志:
5、从服务那儿创建一个服务暴露端口即可访问



