k8s部署onlyoffice
时间: 2023-12-09 10:37:03 浏览: 302
windows+onlyoffice部署.zip
5星 · 资源好评率100%
以下是部署OnlyOffice的Kubernetes示例:
1. 创建命名空间
```shell
kubectl create namespace onlyoffice
```
2. 部署OnlyOffice Document Server
创建一个名为`onlyoffice-documentserver.yaml`的文件,并将以下内容复制到该文件中:
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: onlyoffice-documentserver
namespace: onlyoffice
labels:
app: onlyoffice-documentserver
spec:
replicas: 1
selector:
matchLabels:
app: onlyoffice-documentserver
template:
metadata:
labels:
app: onlyoffice-documentserver
spec:
containers:
- name: onlyoffice-documentserver
image: onlyoffice/documentserver:latest
ports:
- containerPort: 8000
volumeMounts:
- name: documentserver-fonts
mountPath: /usr/share/fonts/truetype/custom
- name: documentserver-etc
mountPath: /etc/onlyoffice/documentserver/
volumes:
- name: documentserver-fonts
configMap:
name: documentserver-fonts
- name: documentserver-etc
configMap:
name: documentserver-etc
```
然后运行以下命令:
```shell
kubectl apply -f onlyoffice-documentserver.yaml
```
3. 创建OnlyOffice Document Server服务
创建一个名为`onlyoffice-documentserver-service.yaml`的文件,并将以下内容复制到该文件中:
```yaml
apiVersion: v1
kind: Service
metadata:
labels:
app: onlyoffice-documentserver
name: onlyoffice-documentserver
name: onlyoffice-documentserver
namespace: onlyoffice
spec:
ports:
- name: http
port: 8000
protocol: TCP
targetPort: 8000
selector:
app: onlyoffice-documentserver
type: NodePort
```
然后运行以下命令:
```shell
kubectl apply -f onlyoffice-documentserver-service.yaml
```
4. 部署OnlyOffice文档服务器
创建一个名为`onlyoffice.yaml`的文件,并将以下内容复制到该文件中:
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: onlyoffice
namespace: onlyoffice
labels:
app: onlyoffice
spec:
replicas: 1
selector:
matchLabels:
app: onlyoffice
template:
metadata:
labels:
app: onlyoffice
spec:
containers:
- name: onlyoffice
image: onlyoffice/documentserver:latest
ports:
- containerPort: 80
env:
- name: DOCUMENT_SERVER_PORT
value: "8000"
- name: DOCUMENT_SERVER_SECURE_CONNECTION
value: "false"
- name: JWT_ENABLED
value: "true"
- name: JWT_SECRET
value: "mysecret"
- name: JWT_HEADER
value: "Authorization"
- name: JWT_COOKIE
value: "token"
- name: JWT_EXPIRATION_TIME
value: "3600"
- name: JWT_REFRESH_TIME
value: "1800"
- name: JWT_ALGORITHM
value: "HS256"
- name: JWT_AUDIENCE
value: "onlyoffice"
- name: JWT_ISSUER
value: "onlyoffice"
- name: JWT_SUBJECT
value: "onlyoffice"
- name: JWT_ID
valueFrom:
fieldRef:
fieldPath: metadata.name
volumeMounts:
- name: onlyoffice-etc
mountPath: /etc/onlyoffice/
volumes:
- name: onlyoffice-etc
configMap:
name: onlyoffice-etc
```
然后运行以下命令:
```shell
kubectl apply -f onlyoffice.yaml
```
5. 创建OnlyOffice服务
创建一个名为`onlyoffice-service.yaml`的文件,并将以下内容复制到该文件中:
```yaml
apiVersion: v1
kind: Service
metadata:
labels:
app: onlyoffice
name: onlyoffice
name: onlyoffice
namespace: onlyoffice
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: 80
selector:
app: onlyoffice
type: NodePort
```
然后运行以下命令:
```shell
kubectl apply -f onlyoffice-service.yaml
```
6. 创建Ingress
创建一个名为`onlyoffice-ingress.yaml`的文件,并将以下内容复制到该文件中:
```yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: onlyoffice
namespace: onlyoffice
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: onlyoffice.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: onlyoffice
port:
name: http
```
然后运行以下命令:
```shell
kubectl apply -f onlyoffice-ingress.yaml
```
阅读全文