如果你还没有 Google Cloud 账户,首先需要前往 Google Cloud 官网 ( https://cloud.google.com ) 注册一个新账户。
如果你已经有账户,直接登录即可。
登录到 Google Cloud 控制台(Google Cloud Console)。
在控制台首页,点击左上角的项目选择器,然后点击“新建项目”。
输入项目名称并点击“创建”。
选择你刚创建的项目。
导航到左侧菜单中的“API 和服务” > “库”。
在 API 库中搜索你需要的 API(例如 “Google Maps API” 或 “Google Cloud Translation API”)。
点击相应的 API,然后点击“启用”。
启用 API 后,导航到左侧菜单中的“API 和服务” > “凭据”。
点击“创建凭据”按钮,然后选择“API 密钥”。
系统会生成一个新的 API 密钥。请妥善保存这个密钥。
生成 API 密钥后,你可以点击密钥名称进行配置,例如设置 IP 地址限制,以提高安全性。
安装 Kubernetes
编辑 Kubernetes Yaml 文件
vim geminiprochat.yaml
---
# 创建 Namespace
apiVersion: v1
kind: Namespace
metadata:
name: hty1024-app
---
# 创建 Service
apiVersion: v1
kind: Service
metadata:
name: hty1024-app-geminiprochat-service
namespace: hty1024-app
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: geminiprochat
app.k8s.hty1024.com/version: "20240709"
app.k8s.hty1024.com/resources: service
spec:
type: NodePort
ports:
- port: 3000
targetPort: 3000
nodePort: 30000
selector:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: geminiprochat
app.k8s.hty1024.com/version: "20240709"
app.k8s.hty1024.com/resources: pod
---
# 创建 Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: hty1024-app-geminiprochat-deployment
namespace: hty1024-app
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: geminiprochat
app.k8s.hty1024.com/version: "20240709"
app.k8s.hty1024.com/resources: deployment
spec:
replicas: 1
minReadySeconds: 30
selector:
matchLabels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: geminiprochat
app.k8s.hty1024.com/version: "20240709"
app.k8s.hty1024.com/resources: pod
template:
metadata:
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: geminiprochat
app.k8s.hty1024.com/version: "20240709"
app.k8s.hty1024.com/resources: pod
spec:
terminationGracePeriodSeconds: 60
volumes:
- name: localtime
hostPath:
path: /etc/localtime
- name: shanghai
hostPath:
path: /usr/share/zoneinfo/Asia/Shanghai
containers:
- name: geminiprochat
image: hub.hty1024.com/official/babaohuang/geminiprochat:20240709
ports:
- name: tcp
containerPort: 3000
volumeMounts:
- name: shanghai
mountPath: /etc/localtime
readOnly: true
env:
- name: GEMINI_API_KEY
value: "123456"
- name: SITE_PASSWORD
value: "123456"
nodeSelector:
node.k8s.hty1024.com/type: app
kubectl apply -f geminiprochat.yaml
安装 Docker
编辑 Docker Compose Yaml 文件
vim compose.yaml
version: "3.9"
services:
geminiprochat:
image: yidadaa/chatgpt-next-web:v2.14.0
container_name: geminiprochat
hostname: geminiprochat
restart: always
networks:
- app_network
ports:
- "3000:3000"
volumes:
- /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime:ro
environment:
- GEMINI_API_KEY=123456
- SITE_PASSWORD=123456
networks:
app_network:
name: app_network
external: true
# driver: bridge
# driver_opts:
# encrypted: 'true'
# ipam:
# driver: default
# config:
# - subnet: 10.21.22.1/24
docker-compose up -d