二进制部署k8s集群v1.23.9版本-20-安装nacos-2.0.3
20.1、准备镜像
192.168.1.200操作
docker pull nacos/nacos-server
docker images |grep nacos
docker tag bdf60dc2ada3 harbor.qgutech.com/middleware/nacos:v2.0.3
docker push bdf60dc2ada3 harbor.qgutech.com/middleware/nacos:v2.0.3
20.2、准备资源配置清单
192.168.1.200操作
mkdir -p /data/k8s-yaml/nacos/
cd /data/k8s-yaml/nacos/
vim dp.yaml
apiVersion: v1
kind: Service
metadata:
name: nacos-headless
namespace: middleware
labels:
app: nacos
annotations:
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
spec:
ports:
- port: 8848
name: server
targetPort: 8848
- port: 7848
name: rpc
targetPort: 7848
clusterIP: None
selector:
app: nacos
---
apiVersion: v1
kind: ConfigMap
metadata:
name: nacos-cm
namespace: middleware
data:
mysql.db.name: "qixiao-nacos"
mysql.port: "3306"
mysql.user: "root"
mysql.password: "12345678"
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: nacos
namespace: middleware
spec:
serviceName: nacos-headless
replicas: 1
selector:
matchLabels:
app: nacos
template:
metadata:
labels:
app: nacos
annotations:
pod.alpha.kubernetes.io/initialized: "true"
spec:
containers:
- name: nacos
imagePullPolicy: IfNotPresent
image: harbor.qgutech.com/middleware/nacos:v2.0.3
resources:
requests:
memory: "2Gi"
cpu: "500m"
ports:
- containerPort: 8848
hostPort: 58849
name: client-port
- containerPort: 7848
hostPort: 58850
name: rpc
env:
- name: NACOS_REPLICAS
value: "1"
- 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: NACOS_SERVER_PORT
value: "8848"
- name: NACOS_APPLICATION_PORT
value: "8848"
- name: PREFER_HOST_MODE
value: "hostname"
- name: TZ
value: Asia/Shanghai
- name: MODE
value: standalone
volumeMounts:
- name: nacos-logs
mountPath: /home/nacos/logs
# - name: nacos-conf
# mountPath: /home/nacos/conf
- name: nacos-data
mountPath: /home/nacos/data
imagePullSecrets:
- name: harbor
volumes:
#- nfs:
# server: hfqg1-200
# path: /data/nfs-volume/nacos/conf
# name: nacos-conf
- nfs:
server: hfqg1-200
path: /data/nfs-volume/nacos/data
name: nacos-data
- nfs:
server: hfqg1-200
path: /data/nfs-volume/nacos/logs
name: nacos-logs
vim svc.yaml
apiVersion: v1
kind: Service
metadata:
name: nacos
namespace: middleware
labels:
app: nacos
spec:
ports:
- port: 8848
name: server
targetPort: 8848
- port: 7848
name: rpc
targetPort: 7848
selector:
app: nacos
vim ingress.yaml
kind: Ingress
apiVersion: networking.k8s.io/v1
metadata:
name: nacos
namespace: middleware
spec:
rules:
- host: nacos-test.qgutech.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: nacos
port:
number: 8848
20.3、创建挂载卷
192.168.1.200操作
mkdir -p /data/nfs-volume/nacos/data
mkdir -p /data/nfs-volume/nacos/logs
mkdir -p /data/nfs-volume/nacos/conf
20.4、内网域名解析
192.168.1.197操作
vim /var/named/qgutech.com.zone
增加一条解析记录,注意序列号前滚
nacos-test A 192.168.1.196
重启named服务
systemctl restart named
dig -t A nacos-test.qgutech.com @192.168.1.197 +short
20.5、应用资源配置清单
192.168.1.201操作
kubectl apply -f http://k8s-yaml.qgutech.com/nacos/dp.yaml
kubectl apply -f http://k8s-yaml.qgutech.com/nacos/svc.yaml
kubectl apply -f http://k8s-yaml.qgutech.com/nacos/ingress.yaml
界面访问
http://nacos-test.qgutech.com/nacos
用户名:nacos
密码:nacos
如下图所示:
至此,nacos安装完成,谢谢观看。
本文来自博客园,作者:霸都运维,转载请注明原文链接:https://www.cnblogs.com/wangjie20200529/p/16688586.html