Sau khi đã triển khai được hệ thống mail sử dụng Zimbra, Có một vấn đề đặt ra là nhu cầu chia sẻ các file nội bộ trong công ty, phòng ban. Chẳng hạn như file tài liệu, file báo cáo, từ đó dẫn đến việc cần thiết phải xây dựng hệ thống chia sẻ file nội bộ.
Kết hợp với hệ thống hiện có là mailserver zimbra, ban IT quyết định xây dựng giải pháp on-primise Cloud:
- Nhân viên có tài khoản email có thể dễ dàng truy cập vào Cloud nội bộ
- Dễ dàng chia sẻ file, phân quyền
- Tích hợp vào hệ thống mail đính kèm
Từ đó, ban IT quyết đinh sử dụng nền tảng NextCloud và tương thích với Zimbra.
Deploy NextCloud trên Kubernetes
namespace
Tạo namespace nextcloud
để dễ dàng quản lý resource liên quan
#namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
name: nextcloud
Deploy database
PersistentVolume
# database-pvc.yaml
kind: PersistentVolume
apiVersion: v1
metadata:
name: nextcloud-mysql-pv
labels:
type: local
app: nextcloud
namespace: nextcloud
spec:
storageClassName: manual
capacity:
storage: 2Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/home/admin/nextcloud-database"
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: nextcloud-mysql-pvc
labels:
type: local
app: nextcloud
namespace: nextcloud
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
volumeName: nextcloud-mysql-pv
Deploy DB
# deploy-db.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nextcloud-db
labels:
app: nextcloud
namespace: nextcloud
spec:
replicas: 1
selector:
matchLabels:
pod-label: nextcloud-db-pod
template:
metadata:
labels:
pod-label: nextcloud-db-pod
spec:
containers:
- name: mysql
image: mysql:5.7
env:
- name: MYSQL_DATABASE
value: nextcloud
envFrom:
- secretRef:
name: nextcloud-mysql-credentials
volumeMounts:
- name: db-storage
mountPath: /var/lib/mysql
subPath: mysql-data
volumes:
- name: db-storage
persistentVolumeClaim:
claimName: nextcloud-mysql-pvc
---
apiVersion: v1
kind: Service
metadata:
name: nextcloud-db
labels:
app: nextcloud
namespace: nextcloud
spec:
selector:
pod-label: nextcloud-db-pod
ports:
- protocol: TCP
port: 3306
secrets
Chứa thông tin kết nố với database
# secrets.yaml
apiVersion: v1
kind: Secret
metadata:
name: nextcloud-mysql-credentials
namespace: nextcloud
type: Opaque
data:
MYSQL_ROOT_PASSWORD: dkBudGh1MG45c0AxZzBu
MYSQL_USER: bmV4dGNsMHVk
MYSQL_PASSWORD: dnRzZzIwMjA=
Deploy NextCloud server
PersistentVolume
# storage-pvc.yaml
kind: PersistentVolume
apiVersion: v1
metadata:
name: nextcloud-pv
labels:
type: local
namespace: nextcloud
spec:
storageClassName: manual
capacity:
storage: 50Gi
accessModes:
- ReadWriteMany
hostPath:
path: "/home/admin/nextcloud-storage"
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: nextcloud-pvc
labels:
type: local
namespace: nextcloud
spec:
storageClassName: manual
accessModes:
- ReadWriteMany
resources:
requests:
storage: 50Gi
volumeName: nextcloud-pv
Deploy Server
# deploy-server.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nextcloud-server
labels:
app: nextcloud
namespace: nextcloud
spec:
replicas: 1
selector:
matchLabels:
pod-label: nextcloud-server-pod
template:
metadata:
labels:
pod-label: nextcloud-server-pod
spec:
containers:
- name: nextcloud
image: nextcloud:20-apache
volumeMounts:
- name: server-storage
mountPath: /var/www/html
subPath: server-data
volumes:
- name: server-storage
persistentVolumeClaim:
claimName: nextcloud-pvc
readOnly: false
---
apiVersion: v1
kind: Service
metadata:
name: nextcloud-server
labels:
app: nextcloud
namespace: nextcloud
spec:
selector:
pod-label: nextcloud-server-pod
ports:
- protocol: TCP
port: 80
Certificate SSL
# certificate.yaml
apiVersion: cert-manager.io/v1alpha2
kind: ClusterIssuer
metadata:
name: letsencrypt-nextcloud
labels:
app: nextcloud
namespace: nextcloud
spec:
acme:
# The ACME server URL
server: https://acme-v02.api.letsencrypt.org/directory
# Email address used for ACME registration
email: your@gmail.com
# Name of a secret used to store the ACME account private key
privateKeySecretRef:
name: letsencrypt-nextcloud
# Enable the HTTP-01 challenge provider
solvers:
- http01:
ingress:
class: nginx
Ingress Nginx
# ingress.yaml
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: cluster-ingress
namespace: nextcloud
annotations:
kubernetes.io/ingress.class: "nginx"
cert-manager.io/cluster-issuer: "letsencrypt-nextcloud"
spec:
tls:
- hosts:
- cloud.my-domain.com
secretName: letsencrypt-nextcloud
rules:
- host: cloud.my-domain.com
http:
paths:
- path: /
backend:
serviceName: nextcloud-server
servicePort: 80
Deploy Zimbra
Bạn cần phải chỉnh sửa 1 chút trong docker image install-zimbra.sh
như trong phần highlight
...
sudo -u zimbra /opt/zimbra/bin/zmprov mcf zimbraMtaSmtpdTlsExcludeCiphers 'aNULL,MD5,DES'
echo
echo "Config Open Driver"
sudo -u zimbra /opt/zimbra/bin/zmprov prov md my-domain.com zimbraDriveOwnCloudURL 'https://cloud.my-domain.com/index.php'
echo
echo "Configuring default COS to use selected persona in the Return-Path of the mail envelope (important for privacy)."
sudo -u zimbra /opt/zimbra/bin/zmprov mc default zimbraSmtpRestrictEnvelopeFrom FALSE
....
Nếu không muốn deploy lại Zimbra server thì có thể vào terminal của pod và chạy lênh
sudo -u zimbra /opt/zimbra/bin/zmprov prov md my-domain.com zimbraDriveOwnCloudURL 'https://cloud.my-domain.com/index.php'
sudo -u zimbra /opt/zimbra/bin/zmcontrol restart
Sau khi hoàn thành bước này, tiếp theo cần vào phần Admin của Nextcloud cài Zimbra Driver

Cài đặt các thông số để kết nối với Zimbra
- Enable Zimbra authentication backend: Sử dụng Zimbra LDAP
- Allow Zimbra users to login: Cho phép người dùng Zimbra đăng nhập
- Zimbra Server: Zimbra FQDN ở đây mà mail server
mail.domain.com
- Zimbra Port: Zimbra Port, usually is 443 if using SSL
- Use SSL: Check this mark if you are using HTTPS, you should be using HTTPS
- Enable certificate verification: Check this if you are using a self-signed SSL certificate
- Domain PreauthKey: This is optional, add it in case you want to login from ownCloud/nextCloud to a Zimbra server

Comments