【云原生之kubernetes实战】在k8s环境下部署go-file文件分享工具
# 文件名: go-file-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: go-file
spec:
replicas: 1
selector:
matchLabels:
app: go-file
template:
metadata:
labels:
app: go-file
spec:
containers:
- name: go-file
image: xuxinhua/go-file:latest
ports:
- containerPort: 8080
env:
- name: DB_URL
value: "your_database_url"
- name: DB_NAME
value: "your_database_name"
- name: DB_USER
value: "your_database_user"
- name: DB_PASS
valueFrom:
secretKeyRef:
name: db-password-secret
key: password
- name: REDIS_HOST
value: "your_redis_host"
- name: REDIS_PORT
value: "6379"
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: redis-password-secret
key: password
- name: DOMAIN
value: "your_domain"
- name: PORT
value: "8080"
- name: MODE
value: "prod"
- name: FORCE_HTTPS_DOWNLOAD
value: "true"
- name: FORCE_HTTPS_SHARE
value: "true"
- name: FORCE_HTTPS_PANEL
value: "true"
- name: LOG_LEVEL
value: "info"
- name: UPLOAD_MODE
value: "local"
- name: UPLOAD_DIR
value: "/data/upload"
- name: AVATAR_DIR
value: "/data/avatar"
- name: BACKUP_DIR
value: "/data/backup"
volumeMounts:
- name: upload-volume
mountPath: /data
volumes:
- name: upload-volume
persistentVolumeClaim:
claimName: upload-pvc
在这个示例中,我们定义了一个Deployment资源,用于在Kubernetes环境中部署名为go-file的文件共享服务。我们指定了单个副本、容器的名称、镜像、端口号以及环境变量。我们还定义了一个持久卷声明(PVC),用于挂载上传目录。注意,你需要替换环境变量中的数据库URL、域名以及存储相关的配置信息。
评论已关闭