apiVersion: apps/v1 kind: Deployment metadata: name: nacos-sync namespace: tools spec: replicas: 1 selector: matchLabels: app: nacos-sync template: metadata: labels: app: nacos-sync spec: initContainers: - name: init-mysql-schema image: registry.cn-hangzhou.aliyuncs.com/zhengyu1992/mysql:8.0.43 command: ['sh', '-c'] args: - | echo "Waiting for MySQL..."; until mysqladmin ping -h"$MYSQL_HOST" -P"$MYSQL_PORT" -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" --silent; do sleep 5; done; echo "MySQL is up. Applying schema..."; mysql -h"$MYSQL_HOST" -P"$MYSQL_PORT" -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" < /init/init.sql; echo "Schema applied."; envFrom: - configMapRef: name: nacos-sync-config volumeMounts: - name: init-sql mountPath: /init resources: requests: memory: "64Mi" cpu: "50m" limits: memory: "128Mi" cpu: "100m" containers: - name: nacos-sync image: harbor.haidaifu.net/base/nacos-sync:v0.4.8 ports: - containerPort: 8083 envFrom: - configMapRef: name: nacos-sync-config livenessProbe: httpGet: path: /actuator/health port: 8083 initialDelaySeconds: 60 readinessProbe: httpGet: path: /actuator/health port: 8083 initialDelaySeconds: 10 volumes: - name: init-sql configMap: name: nacos-sync-init-sql --- apiVersion: v1 kind: Service metadata: name: nacos-sync namespace: tools labels: app: nacos-sync spec: publishNotReadyAddresses: true ports: - port: 8083 name: http targetPort: 8083 selector: app: nacos-sync