背景介绍:
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-ubglm
namespace: sit
generation: 4
labels:
app: mysql5-ubglm
name: mysql5
version: v5.7
spec:
replicas: 1
selector:
matchLabels:
app: mysql5-ubglm
name: mysql5
template:
metadata:
labels:
app: mysql5-ubglm
name: mysql5
version: v5.7
spec:
volumes:
- name: confluence-mysql5-pvc
persistentVolumeClaim:
claimName: confluence-mysql5-pvc
- name: confluence-mysql-juflz
configMap:
name: confluence-mysql
defaultMode: 420
containers:
- name: mysql5
image: 'dockerhub.jiang.com/jxstjh-public/mysql:5.7'
ports:
- containerPort: 3306
protocol: TCP
env:
- name: MYSQL_ROOT_PASSWORD
value: confluence
resources:
limits:
cpu: '1'
memory: 4Gi
requests:
cpu: 400m
memory: 1Gi
volumeMounts:
- name: confluence-mysql5-pvc
mountPath: /var/lib/mysql
- name: confluence-mysql-juflz
mountPath: /etc/my.cnf
subPath: my.cnf
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: IfNotPresent
securityContext:
privileged: false
restartPolicy: Always
terminationGracePeriodSeconds: 30
dnsPolicy: ClusterFirst
serviceAccountName: default
serviceAccount: default
securityContext: {}
imagePullSecrets:
- name: user-1-registrysecret
schedulerName: default-scheduler
strategy:
type: Recreate
minReadySeconds: 10
revisionHistoryLimit: 10
progressDeadlineSeconds: 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-mysql
namespace: sit
data:
my.cnf: |-
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
secure-file-priv= NULL
symbolic-links = 0
max_allowed_packet = 256M
max_connections = 1000
innodb_log_file_size = 2GB
transaction-isolation = READ-COMMITTED
binlog_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-pvc
namespace: sit
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 30Gi
storageClassName: hpe-san
volumeMode: Filesystem
service组件的配置:
# vim confluence-mysql-svc.yaml
kind: Service
metadata:
name: mysql5
namespace: sit
labels:
name: mysql5
system/appName: confluence
spec:
ports:
- name: tcp-port-0
protocol: TCP
port: 3306
targetPort: 3306
selector:
name: mysql5
type: ClusterIP
sessionAffinity: 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-eoqzd
namespace: sit
labels:
app: confluence-server-eoqzd
name: confluence-server
version: v7.2.0
spec:
replicas: 1
selector:
matchLabels:
app: confluence-server-eoqzd
name: confluence-server
template:
metadata:
labels:
app: confluence-server-eoqzd
name: confluence-server
version: v7.2.0
spec:
volumes:
- name: confluence-server-pvc
persistentVolumeClaim:
claimName: confluence-server-pvc
containers:
- name: confluence-server
image: 'dockerhub.jiang.com/jxstjh-public/confluence:7.2.0'
ports:
- containerPort: 8090
protocol: TCP
resources:
limits:
cpu: '1'
memory: 4Gi
requests:
cpu: 400m
memory: 1Gi
volumeMounts:
- name: confluence-server-pvc
mountPath: /var/atlassian/application-data/confluence/
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: IfNotPresent
securityContext:
privileged: false
restartPolicy: Always
terminationGracePeriodSeconds: 30
dnsPolicy: ClusterFirst
serviceAccountName: default
serviceAccount: default
securityContext: {}
imagePullSecrets:
- name: user-1-registrysecret
schedulerName: default-scheduler
strategy:
type: Recreate
minReadySeconds: 10
revisionHistoryLimit: 10
progressDeadlineSeconds: 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-pvc
namespace: sit
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: hpe-san
volumeMode: Filesystem
生效pvc组件配置:
# kubectl apply -f confluence-pvc.yaml
service组件配置:
# vim confluence-svc.yaml
kind: Service
metadata:
name: confluence-server
namespace: sit
labels:
name: confluence-server
system/appName: confluence
spec:
ports:
- name: tcp-port-0
protocol: TCP
port: 8090
targetPort: 8090
selector:
name: confluence-server
type: ClusterIP
sessionAffinity: 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密码:
点击开始之后,就会进入到这个界面了。