Kubernetes pod 定义文件问题

Kubernetes pod definition file issue

我可以使用以下命令 运行 wso2 ei 的 Docker 容器。

docker run -it -p 8280:8280 -p 8243:8243 -p 9443:9443 -v wso2ei:/home/wso2carbon --name integrator wso2/wso2ei-integrator

我正在尝试为其创建 pod 定义文件。我不知道如何在 pod 定义文件中进行端口映射和卷映射。以下是我到目前为止创建的文件。我怎样才能完成剩下的?

apiVersion: v1
kind: Pod
metadata:
    name: ei-pod
    labels:
        type: ei
        version: 6.6.0
spec:
    containers:
        - name: integrator
          image: wso2/wso2ei-integrator

以下是可能有效的 YAML 内容:

apiVersion: v1
kind: Pod
metadata:
  name: ei-pod
  labels:
    type: ei
    version: 6.6.0
spec:
  containers:
  - name: integrator
    image: wso2/wso2ei-integrator
    ports:
    - containerPort: 8280
    volumeMounts:
    - mountPath: /wso2carbon
      name: wso2ei
  volumes:
  - name: wso2ei
    hostPath:
      # directory location on host
      path: /home/wso2carbon

虽然以上 YAML 内容只是一个基本示例,但不建议将其用于生产,原因有二:

  1. 直接使用 deployment 或 statefulset 或 daemonset 而不是 pods。

  2. hostPath 卷不可在节点之间共享。因此,使用 NFS 或 Block 等外部卷并将其挂载到 pod 中。另请查看使用存储 class.

    的动态卷配置