美文网首页Openshift:可靠的Kubernetes发行版
Jira容器化 + Openshift Jira模板创建

Jira容器化 + Openshift Jira模板创建

作者: 潘晓华Michael | 来源:发表于2018-07-23 10:37 被阅读86次

    因为应用容器化部署已经是标准化的流程,无需再详篇介绍具体的部署流程。所以本文只提供相关的配置文档。如果对部署过程不了解的同学,请先自学容器基础。
    镜像已经创建好了,如下

    docker.io/xhuaustc/jira-software:7.11.0
    docker.io/xhuaustc/atlassian-mysql:5.7
    

    镜像构建配置

    Jira容器构建

    git clone https://github.com/cptactionhank/docker-atlassian-jira-software
    

    将setenv.sh与atlassian-extras-3.2.jar拷贝到docker-atlassian-jira-software

    # setenv.sh
    #
    # One way to set the JIRA HOME path is here via this variable.  Simply uncomment it and set a valid path like /jira/home.  You can of course set it outside in the command terminal.  That will also work.
    #
    #JIRA_HOME=""
    
    #
    #  Occasionally Atlassian Support may recommend that you set some specific JVM arguments.  You can use this variable below to do that.
    #
    JVM_SUPPORT_RECOMMENDED_ARGS=""
    
    #
    # The following 2 settings control the minimum and maximum given to the JIRA Java virtual machine.  In larger JIRA instances, the maximum amount will need to be increased.
    #
    JVM_MINIMUM_MEMORY=${JVM_XMS:-384m}
    JVM_MAXIMUM_MEMORY=${JVM_XMX:-768m}
    
    #
    # The following are the required arguments for JIRA.
    #
    JVM_REQUIRED_ARGS='-Djava.awt.headless=true -Datlassian.standalone=JIRA -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dmail.mime.decodeparameters=true -Dorg.dom4j.factory=com.atlassian.core.xml.InterningDocumentFactory'
    
    # Uncomment this setting if you want to import data without notifications
    #
    #DISABLE_NOTIFICATIONS=" -Datlassian.mail.senddisabled=true -Datlassian.mail.fetchdisabled=true -Datlassian.mail.popdisabled=true"
    
    
    #-----------------------------------------------------------------------------------
    #
    # In general don't make changes below here
    #
    #-----------------------------------------------------------------------------------
    
    #-----------------------------------------------------------------------------------
    # Prevents the JVM from suppressing stack traces if a given type of exception
    # occurs frequently, which could make it harder for support to diagnose a problem.
    #-----------------------------------------------------------------------------------
    JVM_EXTRA_ARGS="-XX:-OmitStackTraceInFastThrow"
    
    PRGDIR=`dirname "$0"`
    cat "${PRGDIR}"/jirabanner.txt
    
    JIRA_HOME_MINUSD=""
    if [ "$JIRA_HOME" != "" ]; then
        echo $JIRA_HOME | grep -q " "
        if [ $? -eq 0 ]; then
            echo ""
            echo "--------------------------------------------------------------------------------------------------------------------"
            echo "   WARNING : You cannot have a JIRA_HOME environment variable set with spaces in it.  This variable is being ignored"
            echo "--------------------------------------------------------------------------------------------------------------------"
        else
            JIRA_HOME_MINUSD=-Djira.home=$JIRA_HOME
        fi
    fi
    
    JAVA_OPTS="-Xms${JVM_MINIMUM_MEMORY} -Xmx${JVM_MAXIMUM_MEMORY} ${JAVA_OPTS} ${JVM_REQUIRED_ARGS} ${DISABLE_NOTIFICATIONS} ${JVM_SUPPORT_RECOMMENDED_ARGS} ${JVM_EXTRA_ARGS} ${JIRA_HOME_MINUSD} ${START_JIRA_JAVA_OPTS}"
    
    export JAVA_OPTS
    
    # DO NOT remove the following line
    # !INSTALLER SET JAVA_HOME
    
    echo ""
    echo "If you encounter issues starting or stopping JIRA, please see the Troubleshooting guide at http://confluence.atlassian.com/display/JIRA/Installation+Troubleshooting+Guide"
    echo ""
    if [ "$JIRA_HOME_MINUSD" != "" ]; then
        echo "Using JIRA_HOME:       $JIRA_HOME"
    fi
    
    # set the location of the pid file
    if [ -z "$CATALINA_PID" ] ; then
        if [ -n "$CATALINA_BASE" ] ; then
            CATALINA_PID="$CATALINA_BASE"/work/catalina.pid
        elif [ -n "$CATALINA_HOME" ] ; then
            CATALINA_PID="$CATALINA_HOME"/work/catalina.pid
        fi
    fi
    export CATALINA_PID
    
    if [ -z "$CATALINA_BASE" ]; then
      if [ -z "$CATALINA_HOME" ]; then
        LOGBASE=$PRGDIR
        LOGTAIL=..
      else
        LOGBASE=$CATALINA_HOME
        LOGTAIL=.
      fi
    else
      LOGBASE=$CATALINA_BASE
      LOGTAIL=.
    fi
    
    PUSHED_DIR=`pwd`
    cd $LOGBASE
    cd $LOGTAIL
    LOGBASEABS=`pwd`
    cd $PUSHED_DIR
    
    echo ""
    echo "Server startup logs are located in $LOGBASEABS/logs/catalina.out"
    
    # Set the JVM arguments used to start JIRA. For a description of the options, see
    # http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
    
    #-----------------------------------------------------------------------------------
    # This allows us to actually debug GC related issues by correlating timestamps
    # with other parts of the application logs.
    #-----------------------------------------------------------------------------------
    GC_JVM_PARAMETERS=""
    GC_JVM_PARAMETERS="-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintGCCause ${GC_JVM_PARAMETERS}"
    GC_JVM_PARAMETERS="-Xloggc:$LOGBASEABS/logs/atlassian-jira-gc-%t.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=20M ${GC_JVM_PARAMETERS}"
    
    CATALINA_OPTS="${GC_JVM_PARAMETERS} ${CATALINA_OPTS}"
    export CATALINA_OPTS
    

    构建Dockerfile

    #Dockerfile
    FROM openjdk:8-alpine
    
    # Configuration variables.
    ENV JIRA_HOME     /var/atlassian/jira
    ENV JIRA_INSTALL  /opt/atlassian/jira
    ENV JIRA_VERSION  7.11.0
    
    # Install Atlassian JIRA and helper tools and setup initial home
    # directory structure.
    RUN set -x \
        && apk add --no-cache curl xmlstarlet bash ttf-dejavu libc6-compat \
        && mkdir -p                "${JIRA_HOME}" \
        && mkdir -p                "${JIRA_HOME}/caches/indexes" \
        && chmod -R 777            "${JIRA_HOME}" \
        && mkdir -p                "${JIRA_INSTALL}/conf/Catalina" \
        && curl -Ls                "https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-7.11.0.tar.gz" | tar -xz --directory "${JIRA_INSTALL}" --strip-components=1 --no-same-owner \
        && curl -Ls                "https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.38.tar.gz" | tar -xz --directory "${JIRA_INSTALL}/lib" --strip-components=1 --no-same-owner "mysql-connector-java-5.1.38/mysql-connector-java-5.1.38-bin.jar" \
        && rm -f                   "${JIRA_INSTALL}/lib/postgresql-9.1-903.jdbc4-atlassian-hosted.jar" \
        && curl -Ls                "https://jdbc.postgresql.org/download/postgresql-42.2.1.jar" -o "${JIRA_INSTALL}/lib/postgresql-42.2.1.jar" \
        && chmod -R 777            "${JIRA_INSTALL}/conf" \
        && chmod -R 777            "${JIRA_INSTALL}/logs" \
        && chmod -R 777            "${JIRA_INSTALL}/temp" \
        && chmod -R 777            "${JIRA_INSTALL}/work" \
        && sed --in-place          "s/java version/openjdk version/g" "${JIRA_INSTALL}/bin/check-java.sh" \
        && echo -e                 "\njira.home=$JIRA_HOME" >> "${JIRA_INSTALL}/atlassian-jira/WEB-INF/classes/jira-application.properties" \
        && touch -d "@0"           "${JIRA_INSTALL}/conf/server.xml"
    
    # Use the default unprivileged account. This could be considered bad practice
    # on systems where multiple processes end up being executed by 'daemon' but
    # here we only ever run one process anyway.
    
    # Expose default HTTP connector port.
    EXPOSE 8080
    
    # Set volume mount points for installation and home directory. Changes to the
    # home directory needs to be persisted as well as parts of the installation
    # directory due to eg. logs.
    VOLUME ["/var/atlassian/jira", "/opt/atlassian/jira/logs"]
    
    # Set the default working directory as the installation directory.
    WORKDIR /var/atlassian/jira
    
    COPY "docker-entrypoint.sh" "/"
    COPY atlassian-extras-3.2.jar ${JIRA_INSTALL}/atlassian-jira/WEB-INF/lib/atlassian-extras-3.2.jar
    COPY setenv.sh ${JIRA_INSTALL}/bin/setenv.sh
    ENTRYPOINT ["/docker-entrypoint.sh"]
    
    # Run Atlassian JIRA as a foreground process by default.
    CMD ["/opt/atlassian/jira/bin/start-jira.sh", "-fg"]
    

    构建对应的Mysql镜像

    # my.cnf
    [mysqld]
    pid-file        = /var/run/mysqld/mysqld.pid
    socket          = /var/run/mysqld/mysqld.sock
    datadir         = /var/lib/mysql
    secure-file-priv= NULL
    # Disabling symbolic-links is recommended to prevent assorted security risks
    symbolic-links=0
    character_set_server=utf8
    init_connect='SET NAMES utf8'
    collation_server=utf8_bin
    transaction_isolation='read-committed'
    
    # Custom config should go here
    !includedir /etc/mysql/conf.d/
    

    Dockerfile文件

    FROM mysql:5.7
    COPY my.cnf /etc/mysql/my.cnf
    

    部署镜像

    构建docker-compose.yml

    jira:
      image: xhuaustc/jira-software:7.11.0
      restart: always
      environment:
        - JVM_XMX=2048m
        - JVM_XMS=1024m
      ports:
        - '8080:8080'
      links:
        - db
      volumes:
        - ./data/jira:/var/atlassian/jira
        - ./data/logs:/opt/atlassian/jira/logs
    
    db:
      image: xhuaustc/atlassian-mysql:5.7
      restart: always
      environment:
        - MYSQL_USER=jira
        - MYSQL_PASSWORD=jira
        - MYSQL_DATABASE=jira
        - MYSQL_ROOT_PASSWORD=jira
      volumes:
        - ./data/mysql:/var/lib/mysql
    

    Openshift Jira模板

    apiVersion: template.openshift.io/v1
    kind: Template
    metadata:
      name: jira
    objects:
    - apiVersion: v1
      kind: DeploymentConfig
      metadata:
        labels:
          run: jira
        name: jira
      spec:
        replicas: 1
        selector:
          run: jira
        strategy:
          type: Recreate
        template:
          metadata:
            labels:
              run: jira
          spec:
            containers:
            - env:
              - name: JVM_XMX
                value: 2048m
              - name: JVM_XMS
                value: 1024m
              image: docker.io/xhuaustc/jira-software:7.11.0
              imagePullPolicy: IfNotPresent
              name: jira
              volumeMounts:
              - mountPath: /var/atlassian/jira
                name: volume-7iy6x
              - mountPath: /opt/atlassian/jira/logs
                name: volume-zsyly
            volumes:
            - name: volume-7iy6x
              persistentVolumeClaim:
                claimName: jira
            - name: volume-zsyly
              persistentVolumeClaim:
                claimName: jira-log
        triggers:
        - type: ConfigChange
    - apiVersion: v1
      kind: DeploymentConfig
      metadata:
        labels:
          run: mysql-jira
        name: mysql-jira
      spec:
        replicas: 1
        selector:
          run: mysql-jira
        strategy:
          type: Recreate
        template:
          metadata:
            labels:
              run: mysql-jira
          spec:
            containers:
            - env:
              - name: MYSQL_USER
                value: jira
              - name: MYSQL_PASSWORD
                value: jira
              - name: MYSQL_DATABASE
                value: jira
              - name: MYSQL_ROOT_PASSWORD
                value: jira
              image: docker.io/xhuaustc/atlassian-mysql:5.7
              imagePullPolicy: IfNotPresent
              name: mysql-jira
              volumeMounts:
              - mountPath: /var/lib/mysql/data
                name: volume-uiwfa
            volumes:
            - name: volume-uiwfa
              persistentVolumeClaim:
                claimName: mysql-jira-data
        triggers:
        - type: ConfigChange
    - apiVersion: v1
      kind: Service
      metadata:
        labels:
          run: jira
        name: jira
      spec:
        ports:
        - port: 8080
          protocol: TCP
          targetPort: 8080
        selector:
          run: jira
        type: ClusterIP
    - apiVersion: v1
      kind: Service
      metadata:
        labels:
          run: mysql-jira
        name: mysql-jira
      spec:
        ports:
        - port: 3306
          protocol: TCP
          targetPort: 3306
        selector:
          run: mysql-jira
        type: ClusterIP
    - apiVersion: v1
      kind: Route
      metadata:
        annotations:
          haproxy.router.openshift.io/timeout: 3000s
        labels:
          run: jira
        name: jira
      spec:
        port:
          targetPort: 8080
        to:
          kind: Service
          name: jira
          weight: 100
        wildcardPolicy: None
    - apiVersion: v1
      kind: PersistentVolumeClaim
      metadata:
        annotations:
          volume.beta.kubernetes.io/storage-class: ceph-rbd-sc
          volume.beta.kubernetes.io/storage-provisioner: kubernetes.io/rbd
        name: jira
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 20Gi
    - apiVersion: v1
      kind: PersistentVolumeClaim
      metadata:
        annotations:
          volume.beta.kubernetes.io/storage-class: ceph-rbd-sc
          volume.beta.kubernetes.io/storage-provisioner: kubernetes.io/rbd
        name: jira-log
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 10Gi
    - apiVersion: v1
      kind: PersistentVolumeClaim
      metadata:
        annotations:
          volume.beta.kubernetes.io/storage-class: ceph-rbd-sc
          volume.beta.kubernetes.io/storage-provisioner: kubernetes.io/rbd
        name: mysql-jira-data
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 10Gi
    

    相关文章

      网友评论

      • 纯白小:升级过程出错~~能加微信或者QQ请教下吗

      本文标题:Jira容器化 + Openshift Jira模板创建

      本文链接:https://www.haomeiwen.com/subject/olllmftx.html