Kubernetes部署Confluence
环境配置
Confluence版本:7.4.11
MySQL版本:5.7.31
Kubernetes版本:1.20.0
部署服务
部署mysql
[root@k8s01 mysql]# cat mysql.yaml
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-data
namespace: tools-env
labels:
app: mysql
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi
storageClassName: managed-nfs-storage
---
apiVersion: v1
kind: ConfigMap
metadata:
name: mysql-config
namespace: tools-env
labels:
app: mysql
data:
my.cnf: |-
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
default-storage-engine=INNODB
character-set-server=utf8mb4
collation-server=utf8mb4_bin
innodb_default_row_format=DYNAMIC
innodb_large_prefix=ON
innodb_file_format=Barracuda
symbolic-links=0
max_allowed_packet=50M
innodb_log_file_size=2048M
max_allowed_packet=2048M
transaction-isolation=READ-COMMITTED
sql_mode=''
---
apiVersion: v1
kind: Service
metadata:
name: mysql
namespace: tools-env
spec:
ports:
- port: 3306
nodePort: 31296
selector:
app: mysql
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
namespace: tools-env
labels:
app: mysql
spec:
replicas: 1
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- name: mysql
image: mysql:5.7.31
ports:
- containerPort: 3306
env:
- name: MYSQL_ROOT_PASSWORD
value: "test-pwd"
resources:
limits:
cpu: 2000m
memory: 512Mi
requests:
cpu: 2000m
memory: 512Mi
livenessProbe:
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
exec:
command: ["mysqladmin", "-uroot", "-p${MYSQL_ROOT_PASSWORD}", "ping"]
readinessProbe:
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
exec:
command: ["mysqladmin", "-uroot", "-p${MYSQL_ROOT_PASSWORD}", "ping"]
volumeMounts:
- name: data
mountPath: /var/lib/mysql
- name: config
mountPath: /etc/mysql/conf.d/my.cnf
subPath: my.cnf
- name: localtime
readOnly: true
mountPath: /etc/localtime
volumes:
- name: data
persistentVolumeClaim:
claimName: mysql-data
- name: config
configMap:
name: mysql-config
- name: localtime
hostPath:
type: File
path: /etc/localtime
[root@k8s01 confluence]# kubectl apply -f mysql.yaml
persistentvolumeclaim/mysql-data created
configmap/mysql-config created
service/mysql created
deployment.apps/mysql created
[root@k8s01 confluence]# kubectl get -n tools-env po
NAME READY STATUS RESTARTS AGE
mysql-6db9f6cc49-tnbhr 1/1 Running 0 51s
[root@k8s01 confluence]# kubectl exec -it -n tools-env mysql-6db9f6cc49-tnbhr bash
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
root@mysql-6db9f6cc49-tnbhr:/# mysql -ptest-pwd
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.31 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'test-pwd' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)
#创建confluence数据库库
mysql> create database confluence default character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.02 sec)
部署confluence
由于使用MySQL,需要下载mysql的驱动程序(Database JDBC Drivers | Confluence Data Center and Server 8.5 | Atlassian Documentation)以及破解包,链接如下:
构建镜像
为了方便,将上述文件放入镜像,Dockerfile如下
[root@k8s01 confluence]# cat Dockerfile
FROM atlassian/confluence-server:7.4.11-jdk11
USER root
#将代理破解包加入容器
COPY "atlassian-agent.jar" /opt/atlassian/confluence/
COPY "mysql-connector-java-5.1.48-bin.jar" /opt/atlassian/confluence/confluence/WEB-INF/lib/
#设置启动加载代理包
RUN echo '\nexport CATALINA_OPTS="-javaagent:/opt/atlassian/confluence/atlassian-agent.jar ${CATALINA_OPTS}"' >> /opt/atlassian/confluence/bin/setenv.sh
[root@k8s01 confluence]# docker build -t harbor.xxx.cn/tools/confluence:7.19.4 .
部署yaml文件
[root@k8s01 confluence]# cat confluence.yaml
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: confluence-data
namespace: tools-env
labels:
app: confluence
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 50Gi
storageClassName: managed-nfs-storage
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: confluence
namespace: tools-env
spec:
replicas: 1
selector:
matchLabels:
app: confluence
template:
metadata:
labels:
app: confluence
spec:
imagePullSecrets:
- name: harborsecret
containers:
- name: confluence
image: harbor.xxx.cn/tools/confluence:7.4.11
env:
- name: JVM_MINIMUM_MEMORY
value: "2048m"
- name: JVM_MAXIMUM_MEMORY
value: "2048m"
- name: JVM_RESERVED_CODE_CACHE_SIZE
value: "512m"
- name: ATL_PROXY_NAME
value: "confluence.xxx.cn"
- name: ATL_PROXY_PORT
value: "443"
- name: ATL_TOMCAT_PORT
value: "8090"
- name: ATL_TOMCAT_SCHEME
value: "https"
- name: ATL_TOMCAT_SECURE
value: "false"
volumeMounts:
- name: date
mountPath: /etc/localtime
- name: confluence-data
mountPath: /var/atlassian/application-data/confluence
volumes:
- name: date
hostPath:
path: /etc/localtime
- name: confluence-data
persistentVolumeClaim:
claimName: confluence-data
---
apiVersion: v1
kind: Service
metadata:
name: confluence
namespace: tools-env
labels:
app: confluence
spec:
sessionAffinity: "ClientIP"
ports:
- name: http
port: 8090
protocol: TCP
targetPort: 8090
nodePort: 38090
type: NodePort
selector:
app: confluence
[root@k8s01 confluence]# kubectl apply -f confluence.yaml
persistentvolumeclaim/confluence-data created
deployment.apps/confluence created
service/confluence created
[root@k8s01 confluence]# kubectl get -n tools-env po
NAME READY STATUS RESTARTS AGE
confluence-7cf4896c67-7qm45 1/1 Running 0 18s
网页配置
服务启动后就可以访问了,http://IP:38090
有了上面的Server ID,就可以生成license key了
[root@k8s01 confluence]# kubectl exec -it -n tools-env confluence-7cf4896c67-7qm45 bash
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
root@confluence-7cf4896c67-7qm45:/var/atlassian/application-data/confluence# cd /opt/atlassian/confluence/
root@confluence-7cf4896c67-7qm45:/opt/atlassian/confluence# ls
atlassian-agent.jar BUILDING.txt confluence lib licenses NOTICE README.md RELEASE-NOTES synchrony-proxy webapps
bin conf CONTRIBUTING.md LICENSE logs README.html README.txt RUNNING.txt temp work
root@confluence-7cf4896c67-7qm45:/opt/atlassian/confluence# java -jar atlassian-agent.jar -d -m test@test.com -n BAT -p conf -o http://localhost:8090 -s BH5V-N1QJ-RLQ1-JBP5
#注意,填写的license key不能有换行符
配置mysql连接信息
后面按照提示走就可以了
本项目只做个人学习研究之用,不得用于商业用途! 商业使用请向Atlassian购买正版,谢谢合作!
版权声明:
本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自
爱吃可爱多!
喜欢就支持一下吧
打赏
微信
支付宝