canal配置记录

Dockerfile:

root@nx-eks-ctl:/usr/local/src/zhdya/canal# cat Dockerfile
FROM canal/canal-server:v1.1.5

#COPY canal.properties /home/admin/canal-server/conf/
#COPY instance.properties /home/admin/canal-server/conf/example/
RUN rm -rf /home/admin/canal-server/conf/canal.properties \
&& rm -rf /home/admin/canal-server/conf/example/instance.properties

# 2222 sys , 8000 debug , 11111 canal , 11112 metrics
EXPOSE 2222 11111 8000 11112

WORKDIR /home/admin

ENTRYPOINT [ "/alidata/bin/main.sh" ]
CMD [ "/home/admin/app.sh" ]

先从文件创建configmap

# kubectl create configmap  canal-properties -ndevops-system --from-file=/home/canal/properties/canal.properties
# kubectl create configmap  canal-instance-properties -ndevops-system --from-file=/home/canal/properties/instance.properties

控制器及SVC:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: canal-server
  namespace: devops-system
spec:
  replicas: 1
  selector:
    matchLabels:
      app: canal-server
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      name: canal-server
      labels:
        app: canal-server
    spec:
      containers:
      - name: canal-server
        image: harbor.devops.xxxx.com/library/canal-server:v2
        imagePullPolicy: IfNotPresent
        volumeMounts:
          - name: canal-properties
            mountPath: /usr/local/src/
          - name: canal-instance-properties
            mountPath: /opt/
        lifecycle:
          postStart:
            exec:
              command: ["/bin/sh", "-c", "cp -f /usr/local/src/canal.properties /home/admin/canal-server/conf/ && chown admin.admin /home/admin/canal-server/conf/canal.properties && chmod 777 /home/admin/canal-server/conf/canal.properties && cp -f /opt/instance.properties /home/admin/canal-server/conf/example/ && chown admin.admin /home/admin/canal-server/conf/example/instance.properties && chmod 777 /home/admin/canal-server/conf/example/instance.properties"]
        livenessProbe:
          exec:
            command:
            - ls
          initialDelaySeconds: 5
          periodSeconds: 5
        readinessProbe:
          exec:
            command:
            - ls
          initialDelaySeconds: 5
          periodSeconds: 5
        ports:
        - name: svc-sys
          containerPort: 2222
        - name: svc-debug
          containerPort: 8000
        - name: svc-canal
          containerPort: 11111
        - name: svc-metrics
          containerPort: 11112
      volumes:
        - name: canal-properties
          configMap:
            name: canal-properties
        - name: canal-instance-properties
          configMap:
            name: canal-instance-properties
      dnsPolicy: ClusterFirst
      imagePullSecrets:
      - name: harborsecret
      restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  name: canal-server-svc
  labels:
    app: canal-server-svc
  namespace: devops-system
spec:
  selector:
    app: canal-server
  ports:
  - name: svc-sys
    port: 2222
  - name: svc-debug
    port: 8000
    targetPort: 8000
  - name: svc-canal
    port: 11111
    targetPort: 11111
  - name: svc-metrics
    port: 11112
    targetPort: 11112
  type: ClusterIP

本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!