【问题标题】:How to deploy nginx with ftp? [closed]如何使用 ftp 部署 nginx? [关闭]
【发布时间】:2019-10-17 03:40:11
【问题描述】:

最近我开始研究 Kubernetes。现在我知道如何使用默认选项在 pod 中部署 nginx,并且我知道如何使用自定义 nginx.conf 和 configmap 部署 nginx。现在我有一个问题,如果我想将 nginx 与 ftp 一起使用。 Ftp 需要访问 nginx.conf 所在的目录。有可能的 ? 也许有人知道简单的例子?

【问题讨论】:

    标签: linux docker kubernetes ftp


    【解决方案1】:

    您可以将您的 ftp 容器作为 nginx 主容器的 sidecar,并在容器之间共享卷:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nginx
      labels:
        app: nginx
    spec:
      selector:
        matchLabels:
          app: nginx
      replicas: 1
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: <your nginx image>
            ports:
            - name: http
              containerPort: 80
            volumeMounts:
            - name: config
              mountPath: /etc/nginx/nginx.conf
              subPath: nginx.conf
          - name: ftp
            image: <your ftp image>
            ports:
            - name: ftp
              containerPort: 21
            volumeMounts:
            - name: config
              readOnly: true
              mountPath: /etc/nginx/nginx.conf
              subPath: nginx.conf
          volumes:
          - name: config
            configMap:
              name: nginx-config
    

    服务公开两个端口

    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: nginx-ftp
    spec:
      selector:
        app: nginx
      ports:
      - name: http
        port: 80
        targetPort: 80
      - name: ftp
        port: 21
        targetPort: 21
    

    【讨论】:

    • 感谢您的提问。但是如何部署服务呢?
    • 服务暴露两个端口,ftp端口和nginx端口
    • 抱歉,但是如何在该配置 configMap 上进行部署?那么认证呢?使用环境?
    猜你喜欢
    • 2016-11-25
    • 2013-01-31
    • 2021-01-30
    • 2011-07-17
    • 1970-01-01
    • 2019-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多