一、Nacos
二、MySQL配置
1、nacos-mysql.sql
2、application.properties 配置
三、k8s部署
1、k8s容器文件路径
k8s容器文件路径.png2、挂载配置路径 挂载配置路径.png
3、注意
- 由于容器
/home/nacos/conf
中有多个文件,所以如果直接挂载/home/nacos/conf目录就会覆盖容器中的所有文件。为了实现按需配置
就必须要执行子路径
四、配置依赖的MySQL容器
由于Nacos使用了MySQL配置,所以在启动Nacos容器的时候必须要保证MySQL容器已经启动完成
1、配置init容器
image.png image.png使用init容器来检验MySQL容器是否启动成功
- 命令
sh,-c,until nslookup mysql-svc; do echo waiting for mydb; sleep 2; done
- yaml
kind: StatefulSet
apiVersion: apps/v1
metadata:
name: nacos-svc-v1
namespace: yygh
labels:
app: nacos-svc
version: v1
annotations:
kubesphere.io/creator: raven-work-wang
spec:
replicas: 1
selector:
matchLabels:
app: nacos-svc
version: v1
template:
metadata:
creationTimestamp: null
labels:
app: nacos-svc
version: v1
annotations:
cni.projectcalico.org/ipv4pools: '["default-ipv4-ippool"]'
kubesphere.io/restartedAt: '2022-04-02T06:03:02.185Z'
logging.kubesphere.io/logsidecar-config: '{}'
spec:
volumes:
- name: host-time
hostPath:
path: /etc/localtime
type: ''
- name: volume-1w0qgd
configMap:
name: nacos-config
defaultMode: 420
initContainers:
- name: container-mo0skl
image: 'busybox:latest'
command:
- sh
- '-c'
- until nslookup mysql-svc; do echo waiting for mydb; sleep 2; done
ports:
- name: http-8081
containerPort: 8081
protocol: TCP
resources: {}
volumeMounts:
- name: host-time
readOnly: true
mountPath: /etc/localtime
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: IfNotPresent
containers:
- name: container-0up3y8
image: 'nacos/nacos-server:v2.0.4'
ports:
- name: http-8848
containerPort: 8848
protocol: TCP
resources:
limits:
cpu: 500m
memory: 1000Mi
volumeMounts:
- name: host-time
readOnly: true
mountPath: /etc/localtime
- name: volume-1w0qgd
readOnly: true
mountPath: /home/nacos/conf/application.properties
subPath: application.properties
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: IfNotPresent
restartPolicy: Always
terminationGracePeriodSeconds: 30
dnsPolicy: ClusterFirst
serviceAccountName: default
serviceAccount: default
securityContext: {}
affinity: {}
schedulerName: default-scheduler
serviceName: nacos-svc
podManagementPolicy: OrderedReady
updateStrategy:
type: RollingUpdate
rollingUpdate:
partition: 0
revisionHistoryLimit: 10
image.png
网友评论