背景介绍:
Confluence是一个专业的企业知识管理与协同软件。使用简单,但它强大的编辑和站点管理特征能够帮助团队成员之间共享信息、文档协作、集体讨论,信息推送。
这里介绍的使用的是Confluence 7.2.0版本的。
一、在kubernetes集群部署
1、部署mysql数据库:
confluence服务需要一个数据库做数据存储,一般使用mysql,这里准备的mysql数据库是mysql:5.7.*版本的。
mysql的deployment的配置如下:
# vim confluence-mysql.yaml
kind: Deployment
metadata:name: mysql5-ubglmnamespace: sitgeneration: 4labels:app: mysql5-ubglmname: mysql5version: v5.7
spec:replicas: 1selector:matchLabels:app: mysql5-ubglmname: mysql5template:metadata:labels:app: mysql5-ubglmname: mysql5version: v5.7spec:volumes:- name: confluence-mysql5-pvcpersistentVolumeClaim:claimName: confluence-mysql5-pvc- name: confluence-mysql-juflzconfigMap:name: confluence-mysqldefaultMode: 420containers:- name: mysql5image: 'dockerhub.jiang.com/jxstjh-public/mysql:5.7'ports:- containerPort: 3306protocol: TCPenv:- name: MYSQL_ROOT_PASSWORDvalue: confluenceresources:limits:cpu: '1'memory: 4Girequests:cpu: 400mmemory: 1GivolumeMounts:- name: confluence-mysql5-pvcmountPath: /var/lib/mysql- name: confluence-mysql-juflzmountPath: /etc/my.cnfsubPath: my.cnfterminationMessagePath: /dev/termination-logterminationMessagePolicy: FileimagePullPolicy: IfNotPresentsecurityContext:privileged: falserestartPolicy: AlwaysterminationGracePeriodSeconds: 30dnsPolicy: ClusterFirstserviceAccountName: defaultserviceAccount: defaultsecurityContext: {}imagePullSecrets:- name: user-1-registrysecretschedulerName: default-schedulerstrategy:type: RecreateminReadySeconds: 10revisionHistoryLimit: 10progressDeadlineSeconds: 600
生效deployment控制器:
# kubectl apply -f confluence-mysql.yaml
mysql服务部署过程中有使用到configmap组件、和pvc的配置。
configmap的配置:
# vim confluence-mysql.yaml
# k get cm confluence-mysql -o yaml
apiVersion: v1
kind: ConfigMap
metadata:annotations:configlabels: ""name: confluence-mysqlnamespace: sit
data:my.cnf: |-[mysqld]pid-file = /var/run/mysqld/mysqld.pidsocket = /var/run/mysqld/mysqld.sockdatadir = /var/lib/mysqlsecure-file-priv= NULLsymbolic-links = 0max_allowed_packet = 256Mmax_connections = 1000innodb_log_file_size = 2GBtransaction-isolation = READ-COMMITTEDbinlog_format = row[mysql]
# kubectl apply -f confluence-mysql-cm.yaml
pvc存储的配置:
# vim confluence-mysql-pvc.yaml
apiVersion: storage.k8s.io/v1
kind: PersistentVolumeClaim
metadata:name: confluence-mysql5-pvcnamespace: sit
spec:accessModes:- ReadWriteOnceresources:requests:storage: 30GistorageClassName: hpe-sanvolumeMode: Filesystem
service组件的配置:
# vim confluence-mysql-svc.yaml
kind: Service
metadata:name: mysql5namespace: sitlabels:name: mysql5system/appName: confluence
spec:ports:- name: tcp-port-0protocol: TCPport: 3306targetPort: 3306selector:name: mysql5type: ClusterIPsessionAffinity: None
2、初始化mysql数据库:
这里是创建数据库名称、设置用户密码。
mysql> CREATE DATABASE confluence CHARACTER SET utf8 COLLATE utf8_bin;
Query OK, 1 row affected (0.01 sec)mysql> create user 'confluenceuser'@'%' identified by 'confluencepassword';
Query OK, 0 rows affected (0.01 sec)
mysql> grant all privileges on confluence.* to 'confluenceuser'@'%' with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql> set global tx_isolation='READ-COMMITTED';
Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)mysql>
测试是否可以登入mysql数据库
3、部署confluence服务:
confluence的镜像地址可以通过如下地址下载:
registry.cn-hangzhou.aliyuncs.com/images-speed-up/confluence:7.2.0
# vim confluence.yaml
kind: Deployment
metadata:name: confluence-server-eoqzdnamespace: sitlabels:app: confluence-server-eoqzdname: confluence-serverversion: v7.2.0
spec:replicas: 1selector:matchLabels:app: confluence-server-eoqzdname: confluence-servertemplate:metadata:labels:app: confluence-server-eoqzdname: confluence-serverversion: v7.2.0spec:volumes:- name: confluence-server-pvcpersistentVolumeClaim:claimName: confluence-server-pvccontainers:- name: confluence-serverimage: 'dockerhub.jiang.com/jxstjh-public/confluence:7.2.0'ports:- containerPort: 8090protocol: TCPresources:limits:cpu: '1'memory: 4Girequests:cpu: 400mmemory: 1GivolumeMounts:- name: confluence-server-pvcmountPath: /var/atlassian/application-data/confluence/terminationMessagePath: /dev/termination-logterminationMessagePolicy: FileimagePullPolicy: IfNotPresentsecurityContext:privileged: falserestartPolicy: AlwaysterminationGracePeriodSeconds: 30dnsPolicy: ClusterFirstserviceAccountName: defaultserviceAccount: defaultsecurityContext: {}imagePullSecrets:- name: user-1-registrysecretschedulerName: default-schedulerstrategy:type: RecreateminReadySeconds: 10revisionHistoryLimit: 10progressDeadlineSeconds: 600
生效deployment配置:
# kubectl apply -f confluence.yaml
confluence服务部署过程中有使用到pvc组件和service组件的配置。
pvc存储配置:
# vim confluence-pvc.yaml
apiVersion: storage.k8s.io/v1
kind: PersistentVolumeClaim
metadata:name: confluence-server-pvcnamespace: sit
spec:accessModes:- ReadWriteOnceresources:requests:storage: 10GistorageClassName: hpe-sanvolumeMode: Filesystem
生效pvc组件配置:
# kubectl apply -f confluence-pvc.yaml
service组件配置:
# vim confluence-svc.yaml
kind: Service
metadata:name: confluence-servernamespace: sitlabels:name: confluence-serversystem/appName: confluence
spec:ports:- name: tcp-port-0protocol: TCPport: 8090targetPort: 8090selector:name: confluence-servertype: ClusterIPsessionAffinity: None
生效service配置:
# kubectl apply -f confluence-svc.yaml
二、初始化confluence配置:
通过service组件放出来的地址+端口进行访问。
http://localhost:8090/
修改语言,设置为中文。
选择产品类型:,这里选择产品安装的
选择应用,这里全部选择吧。
输入授权码:
授权获取如下:
可以进入到confluence容器中执行:
cd /opt/atlassian/confluence/java -jar atlassian-agent.jar -d -m 805492434@qq.com -n TEST -p conf -o http://10.15.0.137 -s BMOJ-K1Y0-7R56-6PFY
这里需要更换的内容,有邮箱地址,服务器ID
选择confluence模式
设置数据库:-测试链接成功-下一步
这里confluence会去数据创建信息,需要较长的时间~ 耐心等待后,大概需要5-10分钟。
设置admin密码:
点击开始之后,就会进入到这个界面了。