gpt4 book ai didi

linux - 如何通过ftp部署nginx?

转载 作者:太空宇宙 更新时间:2023-11-04 04:42:10 25 4
gpt4 key购买 nike

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

最佳答案

您可以将 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

关于linux - 如何通过ftp部署nginx?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58424566/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com