环境配置

  • Confluence版本:8.5.1

  • 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 jira;
Query OK, 1 row affected (0.02 sec) 

部署Jira

由于使用MySQL,需要下载mysql的驱动程序(Database JDBC Drivers | Confluence Data Center and Server 8.5 | Atlassian Documentation)以及破解包,链接如下:

mysql驱动 破解jar包

构建镜像

为了方便,将上述文件放入镜像,Dockerfile如下

[root@k8s01 jira]# cat Dockerfile 
FROM atlassian/jira-software:8.5.1-jdk11
USER root
#将代理破解包加入容器
COPY "atlassian-agent.jar" /opt/atlassian/jira/
#jira需要安装比较旧的驱动
COPY "mysql-connector-java-5.1.25-bin.jar" /opt/atlassian/jira/atlassian-jira/WEB-INF/lib
#设置启动加载代理包
RUN echo '\nexport CATALINA_OPTS="-javaagent:/opt/atlassian/jira/atlassian-agent.jar ${CATALINA_OPTS}"' >> /opt/atlassian/jira/bin/setenv.sh
[root@k8s01 confluence]# docker build -t harbor.xxx.cn/tools/jira:8.5.1 .  

部署yaml文件

[root@k8s01 jira]# cat jira.yaml 
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: jira-data
  namespace: tools-env
  labels:
    app: jira
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 50Gi
  storageClassName: managed-nfs-storage
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: jira
  namespace: tools-env
spec:
  replicas: 1
  selector:
    matchLabels:
      app: jira
  template:
    metadata:
      labels:
        app: jira
    spec:
      imagePullSecrets:
        - name: harborsecret
      containers:
      - name: jira
        image: harbor.ndgratus.cn/tools/jira:8.5.1
        imagePullPolicy: Always
        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: "jira.ndgratus.cn"
        - name: ATL_PROXY_PORT
          value: "443"
        - name: ATL_TOMCAT_PORT
          value: "8080"
        - name: ATL_TOMCAT_SCHEME
          value: "https"
        - name: ATL_TOMCAT_SECURE
          value: "false"
        volumeMounts:
        - name: date
          mountPath: /etc/localtime
        - name: jira-data
          mountPath: /var/atlassian/application-data/jira           
      volumes:
      - name: date
        hostPath:
          path: /etc/localtime
      - name: jira-data
        persistentVolumeClaim:
          claimName: jira-data
---
apiVersion: v1
kind: Service
metadata:
  name: jira
  namespace: tools-env
  labels:
    app: jira
spec:
  sessionAffinity: "ClientIP"
  ports:
    - name: http
      port: 8080
      protocol: TCP
      targetPort: 8080
      nodePort: 38080
  type: NodePort
  selector:
    app: jira
[root@k8s01 jira]# kubectl apply -f jira.yaml 
persistentvolumeclaim/jira-data created
deployment.apps/jira created
service/jira created    
[root@k8s01 jira]# kubectl get -n tools-env po
NAME                             READY   STATUS    RESTARTS   AGE

jira-fbb48bf4c-8vv2v             1/1     Running   0          42s

网页配置

服务启动后就可以访问了,http://IP:38080

image-kvrt.pngimage-jrwl.png有了上面的Server ID,就可以生成license key了

[root@k8s01 confluence]# kubectl exec -it -n tools-env jira-fbb48bf4c-q8k6v bash
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
root@jira-fbb48bf4c-q8k6v:/var/atlassian/application-data/jira# cd /opt/atlassian/jira/
root@jira-fbb48bf4c-q8k6v:/opt/atlassian/jira# ls
atlassian-agent.jar  bin           conf             external-source  licenses  NOTICE       README.md   temp         webapps
atlassian-jira       BUILDING.txt  CONTRIBUTING.md  lib              logs      README.html  README.txt  tomcat-docs  work
root@jira-fbb48bf4c-q8k6v:/opt/atlassian/jira# java -jar atlassian-agent.jar -d -m test@test.com -n BAT -p 'com.valiantys.spreadsheets' -o http://localhost:8090 -s B0VH-CDG8-1ITX-V7P7

后面按照提示走就可以了

image-hbqd.png本项目只做个人学习研究之用,不得用于商业用途! 商业使用请向Atlassian购买正版,谢谢合作!

文章作者: 鲜花的主人
版权声明: 本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 爱吃可爱多
Atlassian Atlassian
喜欢就支持一下吧
打赏
微信 微信
支付宝 支付宝