在服务器根目录下,创建 datax-web.yaml 文件,文件内容为:

---
kind: ConfigMap
apiVersion: v1
metadata:
  name: datax-web-cm
  annotations:
    kubesphere.io/creator: admin
data:
  db.host: 10.16.8.2
  db.port: "4408"
  db.database: datax_web_db
  db.username: datax_web
  db.password: "123456"
---
apiVersion: v1
kind: Service
metadata:
  name: datax-web-svc
  namespace: dw-prod
  annotations:
    kubesphere.io/alias-name: DataX 3.0 Web
    kubesphere.io/description: DataX 3.0 Web
spec:
  ports:
    - name: tcp-9527
      port: 9527
      protocol: TCP
      targetPort: 9527
  selector:
    app: datax-web
  type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: datax-web-deploy
  namespace: dw-prod
  annotations:
    kubesphere.io/alias-name: DataX 3.0 Web
    kubesphere.io/description: DataX 3.0 Web
  labels:
    app: datax-web
spec:
  replicas: 1
  selector:
    matchLabels:
      app: datax-web
  template:
    metadata:
      labels:
        app: datax-web
    spec:
      containers:
        - name: datax-web
          image: linshellfeng/datax_web:3.0.1
          ports:
            - containerPort: 9527
          imagePullPolicy: Always
          env:
            - name: DB_HOST
              valueFrom:
                configMapKeyRef:
                  name: datax-web-cm
                  key: db.host
            - name: DB_PORT
              valueFrom:
                configMapKeyRef:
                  name: datax-web-cm
                  key: db.port
            - name: DB_DATABASE
              valueFrom:
                configMapKeyRef:
                  name: datax-web-cm
                  key: db.database
            - name: DB_USERNAME
              valueFrom:
                configMapKeyRef:
                  name: datax-web-cm
                  key: db.username
            - name: DB_PASSWORD
              valueFrom:
                configMapKeyRef:
                  name: datax-web-cm
                  key: db.password

使用 kubectl 执行如下命令部署 mindoc 服务 :

kubectl create -f mindoc.yaml --namespace=你的命名空间

kubectl create -f mindoc.yaml --namespace=dw-prod

作者:Jeebiz  创建时间:2022-06-15 12:22
最后编辑:Jeebiz  更新时间:2024-07-10 22:56