2020年11月2日星期一

kubernetes 环境安装Nacos集群

kubernetes 环境安装Nacos集群

1.nfs服务器配置

#所有k8s节点执行yum install -y nfs-utilsmkdir -p /usr/local/nacos/nfs-sharemkdir -p /usr/local/nacos/mysql-slavemkdir -p /usr/local/nacos/mysql-masterchmod a+rw /usr/local/nacos#添加nacos、mysql-master 、mysql-slave 持久化文件夹vi /etc/exports/usr/local/nacos/mysql-master *(insecure,rw,async,no_root_squash)/usr/local/nacos/mysql-slave *(insecure,rw,async,no_root_squash)/usr/local/nacos/nfs-share *(insecure,rw,async,no_root_squash)systemctl restart rpcbind.servicesystemctl restart nfs-server.serviceshowmount -e kipnode1

2.部署nfs

下载nacos k8s部署代码

git clone https://github.com/nacos-group/nacos-k8s.git

创建nacos 命名空间

kubectl create namespace nacos

创建角色

cd nacos-k8sNS=$(kubectl config get-contexts|grep -e "^\*" |awk '{print $5}')NAMESPACE=${NS:-nacos}sed -i'' "s/namespace:.*/namespace: $NAMESPACE/g" ./deploy/nfs/rbac.yamlkubectl create -f deploy/nfs/rbac.yaml

创建 ServiceAccount 和部署 NFS-Client Provisioner

修改deployment.yaml

apiVersion: v1kind: ServiceAccountmetadata: name: nfs-client-provisioner---kind: DeploymentapiVersion: extensions/v1beta1metadata: name: nfs-client-provisionerspec: replicas: 1 strategy: type: Recreate template: metadata:  labels:  app: nfs-client-provisioner spec:  serviceAccount: nfs-client-provisioner  containers:  - name: nfs-client-provisioner  image: quay.io/external_storage/nfs-client-provisioner:latest  volumeMounts:  - name: nfs-client-root   mountPath: /persistentvolumes  env:  - name: PROVISIONER_NAME   value: fuseim.pri/ifs  - name: NFS_SERVER   value: kipnode1  - name: NFS_PATH   value: /usr/local/nacos/nfs-share  volumes:  - name: nfs-client-root  nfs:   server: kipnode1   path: /usr/local/nacos/nfs-share
kubectl create -f deploy/nfs/deployment.yaml -n nacos

创建 NFS StorageClass

kubectl create -f deploy/nfs/class.yaml -n nacos

验证NFS部署成功

kubectl get pod -l app=nfs-client-provisioner -n nacos

3.部署数据库

部署主库

修改 mysql-master-nfs.yaml nfs位置

apiVersion: v1kind: ReplicationControllermetadata: name: mysql-master labels: name: mysql-masterspec: replicas: 1 selector: name: mysql-master template: metadata:  labels:  name: mysql-master spec:  containers:  - name: master  image: nacos/nacos-mysql-master:latest  ports:  - containerPort: 3306  volumeMounts:  - name: mysql-master-data   mountPath: /var/lib/mysql  env:  - name: MYSQL_ROOT_PASSWORD   value: "root"  - name: MYSQL_DATABASE   value: "nacos_devtest"  - name: MYSQL_USER   value: "nacos"  - name: MYSQL_PASSWORD   value: "nacos"  - name: MYSQL_REPLICATION_USER   value: 'nacos_ru'  - name: MYSQL_REPLICATION_PASSWORD   value: 'nacos_ru'  volumes:  - name: mysql-master-data  nfs:   server: kipnode1   path: /usr/local/nacos/mysql-master---apiVersion: v1kind: Servicemetadata: name: mysql-master labels: name: mysql-masterspec: ports: - port: 3306 targetPort: 3306 selector: name: mysql-master
kubectl create -f deploy/mysql/mysql-master-nfs.yaml -n nacos

部署从库

修改 mysql-slave-nfs.yaml nfs位置

apiVersion: v1kind: ReplicationControllermetadata: name: mysql-slave labels: name: mysql-slavespec: replicas: 1 selector: name: mysql-slave template: metadata:  labels:  name: mysql-slave spec:  containers:  - name: slave  image: nacos/nacos-mysql-slave:latest  ports:  - containerPort: 3306  volumeMounts:  - name: mysql-slave-data   mountPath: /var/lib/mysql  env:  - name: MYSQL_ROOT_PASSWORD   value: "root"  - name: MYSQL_REPLICATION_USER   value: 'nacos_ru'  - name: MYSQL_REPLICATION_PASSWORD   value: 'nacos_ru'  volumes:  - name: mysql-slave-data  nfs:   server: kipnode1   path: /usr/local/nacos/mysql-slave---apiVersion: v1kind: Servicemetadata: name: mysql-slave labels: name: mysql-slavespec: ports: - port: 3306 targetPort: 3306 selector: name: mysql-slave
kubectl create -f deploy/mysql/mysql-slave-nfs.yaml -n nacos

4.部署Nacos

修改deploy/nacos/nacos-pvc-nfs.yaml 和数据库配置文件保持一致即可

data: mysql.master.db.name: "主库名称" mysql.master.port: "主库端口" mysql.slave.port: "从库端口" mysql.master.user: "主库用户名" mysql.master.password: "主库密码"
kubectl create -f deploy/nacos/nacos-pvc-nfs.yaml -n nacos

使用kubectl scale 对Nacos动态扩容

kubectl scale sts nacos --replicas=3 -n nacos

5.创建ingress

vi ingress/nacos-ingress.yaml

---# 创建Ingress,定义访问规则 apiVersion: extensions/v1beta1 kind: Ingressmetadata: name: nacos-headlessspec: rules: - host: demo.nacos.com http:  paths:  - path: /  backend:   serviceName: nacos-headless   servicePort: 8848 
kubectl create -f nacos-ingress.yaml -n nacos

nacos后台管理访问地址:

原文转载:http://www.shaoqun.com/a/485959.html

走秀网:https://www.ikjzd.com/w/2427

欧麦:https://www.ikjzd.com/w/2085

拍拍网服装:https://www.ikjzd.com/w/2205


kubernetes环境安装Nacos集群1.nfs服务器配置#所有k8s节点执行yuminstall-ynfs-utilsmkdir-p/usr/local/nacos/nfs-sharemkdir-p/usr/local/nacos/mysql-slavemkdir-p/usr/local/nacos/mysql-masterchmoda+rw/usr/local/nacos#添加nacos、
upc:https://www.ikjzd.com/w/111
promotion:https://www.ikjzd.com/w/127
High翻深圳的了景点有哪些?:http://tour.shaoqun.com/a/169.html
欧盟授权代表:https://www.ikjzd.com/w/2057
卯山仙人谷温泉预订?丽水松阳温泉门票怎么预订?:http://tour.shaoqun.com/a/47316.html

没有评论:

发表评论