安装Postgres

  1. docker run -d --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=123456 postgres

创建数据库:

  1. docker exec -it postgres psql -Upostgres -w -c "CREATE DATABASE jira WITH OWNER postgres;"

如果是重装,则需要重建数据库:

  1. REVOKE CONNECT ON DATABASE jira FROM public;
  2. SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname='jira' AND pid<>pg_backend_pid();
  3. drop database jira;

Docker安装

直接使用官方镜像安装:

  1. docker run -d --name jira \
  2. -p 8080:8080 \
  3. -v /data/docker/jira:/var/atlassian/application-data/jira \
  4. -e TZ=Asia/Shanghai \
  5. atlassian/jira-software:8.7.0

https://gitee.com/pengzhile/atlassian-agent 下载破解文件,然后将破解文件拷贝到容器:

  1. docker cp atlassian-agent.jar jira:/opt/atlassian/jira/
  2. docker exec -it jira bash
  3. echo 'export CATALINA_OPTS="-javaagent:/opt/atlassian/jira/atlassian-agent.jar ${CATALINA_OPTS}"' \
  4. >> /opt/atlassian/jira/bin/setenv.sh
  5. docker restart jira

或者直接编译到镜像:

  1. # https://gitee.com/pengzhile/atlassian-agent
  2. FROM atlassian/jira-software:8.7.0
  3. #ADD http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.30.tar.gz /opt/atlassian/jira/lib/
  4. #COPY mysql-connector-java-5.1.30-bin.jar /opt/atlassian/jira/lib/
  5. # 将代理破解包加入容器
  6. COPY atlassian-agent.jar /opt/atlassian/jira/
  7. # 设置启动加载代理包
  8. RUN echo 'export CATALINA_OPTS="-javaagent:/opt/atlassian/jira/atlassian-agent.jar ${CATALINA_OPTS}"' >> /opt/atlassian/jira/bin/setenv.sh

构建镜像:

  1. docker build -t javachen/jira-software:8.7.0 .
  2. docker push javachen/jira-software:8.7.0

获取license:

  1. java -jar atlassian-agent.jar -p jira -m chenzj@javachen.com -n wesine \
  2. -o http://www.javachen.com -s BABY-MGVE-GCQ1-OAZD

K8s安装

创建命名空间和证书:

  1. kubectl create namespace jira
  2. cat << EOF | kubectl create -f -
  3. apiVersion: cert-manager.io/v1alpha2
  4. kind: Certificate
  5. metadata:
  6. name: jira-test-wesine-com-cn-cert
  7. namespace: jira
  8. spec:
  9. secretName: jira-test-wesine-com-cn-cert
  10. renewBefore: 720h
  11. dnsNames:
  12. - "*.javachen.xyz"
  13. issuerRef:
  14. name: cert-manager-webhook-dnspod-cluster-issuer
  15. kind: ClusterIssuer
  16. EOF

cert-manager-webhook-dnspod-cluster-issuer是提前创建好的cluster-issuer。
下载chart文件:

  1. git clone https://github.com/junetalk/charts
  2. cd charts

创建 jira-values.yaml 文件:

  1. cat <<EOF > jira-values.yaml
  2. image:
  3. repository: javachen/jira-software:8.7.0
  4. ingress:
  5. enabled: true
  6. annotations:
  7. kubernetes.io/ingress.class: nginx
  8. nginx.ingress.kubernetes.io/ssl-redirect: "true"
  9. nginx.ingress.kubernetes.io/proxy-body-size: 100m
  10. hosts:
  11. - jira.javachen.xyz
  12. - jira.test.javachen.xyz
  13. tls:
  14. - secretName: jira-test-wesine-com-cn-cert
  15. hosts:
  16. - jira.javachen.xyz
  17. env:
  18. - name: TZ
  19. value: Asia/Shanghai
  20. - name: JVM_MINIMUM_MEMORY
  21. value: "3072m"
  22. - name: JVM_MAXIMUM_MEMORY
  23. value: "4096m"
  24. - name: ATL_PROXY_NAME
  25. value: jira.javachen.com
  26. - name: ATL_PROXY_PORT
  27. value: "443"
  28. - name: ATL_TOMCAT_SCHEME
  29. value: "https"
  30. persistence:
  31. enabled: true
  32. storageClass: "ceph-rbd"
  33. accessMode: ReadWriteOnce
  34. size: 20Gi
  35. EOF

使用helm3安装:

  1. helm install jira -n jira -f jira-values.yaml ./jira

卸载:

  1. helm del jira -n jira

集成OpenLDAP

参考:

首先,设置memberof:

  1. dn: cn=module,cn=config
  2. cn: module
  3. objectClass: olcModuleList
  4. olcModuleLoad: memberof.la
  5. olcModulePath: /usr/lib64/openldap
  6. dn: olcOverlay=memberof,olcDatabase={1}hdb,cn=config
  7. objectClass: olcConfig
  8. objectClass: olcMemberOf
  9. objectClass: olcOverlayConfig
  10. objectClass: top
  11. olcOverlay: memberof
  12. olcMemberOfDangling: ignore
  13. olcMemberOfRefInt: TRUE
  14. olcMemberOfGroupOC: groupOfUniqueNames
  15. olcMemberOfMemberAD: uniqueMember
  16. olcMemberOfMemberOfAD: memberOf

接着使用 ldapadd 命令将其导入:

  1. ldapadd -Y EXTERNAL -H ldapi:/// -f memberof.ldif

创建组:

  1. cat > basedomain.ldif <<EOF
  2. dn: dc=javachen,dc=com
  3. objectClass: top
  4. objectClass: dcObject
  5. objectclass: organization
  6. o: Javachen
  7. dc: javachen
  8. dn: cn=admin,dc=javachen,dc=com
  9. objectClass: organizationalRole
  10. cn: admin
  11. description: Directory Manager
  12. dn: ou=People,dc=javachen,dc=com
  13. objectClass: organizationalUnit
  14. ou: People
  15. dn: ou=Group,dc=javachen,dc=com
  16. objectClass: organizationalUnit
  17. ou: Group
  18. EOF
  19. ldapadd -x -D cn=admin,dc=javachen,dc=com -W -f basedomain.ldif

创建添加用户脚本add_user.sh:

  1. #!/bin/bash
  2. # const
  3. LDAP_SERVER_IP="localhost"
  4. LDAP_SERVER_PORT="389"
  5. LDAP_ADMIN_USER="cn=admin,dc=javachen,dc=com"
  6. LDAP_ADMIN_PASS="admin"
  7. if [ x"$#" != x"3" ];then
  8. echo "Usage: $0 <username> <realname>"
  9. exit -1
  10. fi
  11. # param
  12. USER_ID="$1"
  13. SN="$2"
  14. NAME="$3"
  15. PASSWORD="123456"
  16. ENCRYPT_PASSWORD=$(slappasswd -h {ssha} -s "$PASSWORD")
  17. # add count & group
  18. cat <<EOF | ldapmodify -c -h $LDAP_SERVER_IP -p $LDAP_SERVER_PORT \
  19. -w $LDAP_ADMIN_PASS -D $LDAP_ADMIN_USER
  20. dn: cn=$USER_ID,ou=People,javachen,dc=com
  21. changetype: add
  22. objectClass: top
  23. objectClass: person
  24. objectClass: organizationalPerson
  25. objectClass: inetOrgPerson
  26. cn: $USER_ID
  27. sn: $SN
  28. givenName: $NAME
  29. displayName: $SN$NAME
  30. mail: $USER_ID@javachen.com
  31. userPassword: $ENCRYPT_PASSWORD
  32. dn: cn=jira,ou=Group,dc=javachen,dc=com
  33. changetype: modify
  34. add: uniqueMember
  35. uniqueMember: cn=$USER_ID,ou=People,javachen,dc=com
  36. EOF

添加用户:

  1. add_user.sh zhangsan

在jiar中添加openldap目录:
img
设置用户模式:
img
设置组成员模式:
img
输入用户和秘密进行测试:
img