如何通过ftp部署nginx?

问题描述 投票:0回答:1

最近我开始稳定Kubernetes。现在,我知道如何使用默认选项在Pod中部署Nginx,并且我知道如何使用configmap自定义nginx.conf来部署nginx。现在我有一个问题是否要在ftp中使用nginx。 ftp需要在nginx.conf目录中具有访问权限。有可能的 ?也许有人知道简单的例子?

linux docker kubernetes ftp
1个回答
0
投票

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

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
© www.soinside.com 2019 - 2024. All rights reserved.