From a146e85bfe75c431a35ba4cd882462e084301be5 Mon Sep 17 00:00:00 2001 From: Miku <28099773+CaoYunzhou@users.noreply.github.com> Date: Fri, 31 Mar 2023 11:52:10 +0800 Subject: [PATCH] feat: add kubernetes deploy (#1001) --- kubernetes/README.md | 9 ++++++ kubernetes/deploy.yaml | 66 +++++++++++++++++++++++++++++++++++++++++ kubernetes/ingress.yaml | 21 +++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 kubernetes/README.md create mode 100644 kubernetes/deploy.yaml create mode 100644 kubernetes/ingress.yaml diff --git a/kubernetes/README.md b/kubernetes/README.md new file mode 100644 index 0000000000..0fbae50218 --- /dev/null +++ b/kubernetes/README.md @@ -0,0 +1,9 @@ +## 增加一个Kubernetes的部署方式 +``` +kubectl apply -f deploy.yaml +``` + +### 如果需要Ingress域名接入 +``` +kubectl apply -f ingress.yaml +``` diff --git a/kubernetes/deploy.yaml b/kubernetes/deploy.yaml new file mode 100644 index 0000000000..25273b5d53 --- /dev/null +++ b/kubernetes/deploy.yaml @@ -0,0 +1,66 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: chatgpt-web + labels: + app: chatgpt-web +spec: + replicas: 1 + selector: + matchLabels: + app: chatgpt-web + strategy: + type: RollingUpdate + template: + metadata: + labels: + app: chatgpt-web + spec: + containers: + - image: chenzhaoyu94/chatgpt-web + name: chatgpt-web + imagePullPolicy: Always + ports: + - containerPort: 3002 + env: + - name: OPENAI_API_KEY + value: sk-xxx + - name: OPENAI_API_BASE_URL + value: "https://api.openai.com" + - name: OPENAI_API_MODEL + value: gpt-3.5-turbo + - name: API_REVERSE_PROXY + value: https://bypass.duti.tech/api/conversation + - name: AUTH_SECRET_KEY + value: '123456' + - name: TIMEOUT_MS + value: '60000' + - name: SOCKS_PROXY_HOST + value: '' + - name: SOCKS_PROXY_PORT + value: '' + - name: HTTPS_PROXY + value: '' + resources: + limits: + cpu: 500m + memory: 500Mi + requests: + cpu: 300m + memory: 300Mi +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app: chatgpt-web + name: chatgpt-web +spec: + ports: + - name: chatgpt-web + port: 3002 + protocol: TCP + targetPort: 3002 + selector: + app: chatgpt-web + type: ClusterIP diff --git a/kubernetes/ingress.yaml b/kubernetes/ingress.yaml new file mode 100644 index 0000000000..d5355c049b --- /dev/null +++ b/kubernetes/ingress.yaml @@ -0,0 +1,21 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + annotations: + kubernetes.io/ingress.class: nginx + nginx.ingress.kubernetes.io/proxy-connect-timeout: "5" + name: chatgpt-web +spec: + rules: + - host: chatgpt.example.com + http: + paths: + - backend: + service: + name: chatgpt-web + port: + number: 3002 + path: / + pathType: ImplementationSpecific + tls: + - secretName: chatgpt-web-tls