Kubernetes部署Bitbucket
环境配置
Bitbucket版本:7.21.10
PostgreSQL版本:14.0
Kubernetes版本:1.20.0
部署服务
部署PostgreSQL
部署Bitbucket
构建镜像
为了方便,将上述文件放入镜像,Dockerfile如下
[root@k8s01 bitbucket]# cat Dockerfile
FROM atlassian/bitbucket-server:7.21.10-jdk11
USER root
COPY jdk-8u381-linux-x64.tar.gz /opt/
RUN mkdir /usr/lib/jvm
RUN tar -xzvf /opt/jdk-8u381-linux-x64.tar.gz -C /usr/lib/jvm
RUN rm -rf /opt/jdk-8u381-linux-x64.tar.gz
#将代理破解包加入容器
COPY "atlassian-agent.jar" /opt/atlassian/bitbucket/bin
#设置启动加载代理包
ENV JAVA_OPTS="-javaagent:/opt/atlassian/bitbucket/bin/atlassian-agent.jar ${JAVA_OPTS}"
ENV JAVA_HOME /usr/lib/jvm/jdk1.8.0_381
ENV JRE_HOME ${JAVA_HOME}/jre
ENV CLASSPATH .:${JAVA_HOME}/lib:${JRE_HOME}/lib
ENV PATH ${JAVA_HOME}/bin:$PATH
[root@nginx bitbucket]# docker build -t harbor.xxx.cn/tools/bitbucket:7.21.10 .
部署yaml文件
[root@k8s01 bitbucket]# cat bitbucket.yaml
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: bitbucket-data
namespace: tools-env
labels:
app: bitbucket
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 50Gi
storageClassName: managed-nfs-storage
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: bitbucket
namespace: tools-env
spec:
replicas: 1
selector:
matchLabels:
app: bitbucket
template:
metadata:
labels:
app: bitbucket
spec:
imagePullSecrets:
- name: harborsecret
containers:
- name: bitbucket
image: harbor.xxx.cn/tools/bitbucket:7.21.10
volumeMounts:
- name: date
mountPath: /etc/localtime
- name: bitbucket-data
mountPath: /var/atlassian/application-data/bitbucket
volumes:
- name: date
hostPath:
path: /etc/localtime
- name: bitbucket-data
persistentVolumeClaim:
claimName: bitbucket-data
---
apiVersion: v1
kind: Service
metadata:
name: bitbucket
namespace: tools-env
labels:
app: bitbucket
spec:
sessionAffinity: "ClientIP"
ports:
- name: http
port: 7990
protocol: TCP
targetPort: 7990
nodePort: 37990
type: NodePort
selector:
app: bitbucket
[root@k8s01 bitbucket]# kubectl apply -f bitbucket.yaml
persistentvolumeclaim/bitbucket-data created
deployment.apps/bitbucket created
service/bitbucket created
网页配置
服务启动后就可以访问了,http://IP:37990
有了上面的Server ID,就可以生成license key了
[root@k8s01 bitbucket]# kubectl exec -it -n tools-env bitbucket-6b968b5db8-hzs8k bash
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
root@bitbucket-6b968b5db8-hzs8k:/var/atlassian/application-data/bitbucket# cd /opt/atlassian/bitbucket/bin/
root@bitbucket-6b968b5db8-hzs8k:/opt/atlassian/bitbucket/bin# ls
atlassian-agent.jar exec-bitbucket-node.sh set-bitbucket-home.bat set-jmx-opts.sh start-bitbucket.sh _start-webapp.sh
bserv64.exe _exec-webapp.sh set-bitbucket-home.sh set-jre-home.bat _start-search.bat stop-bitbucket.sh
bserv.exe install_linux_service.sh set-bitbucket-user.sh set-jre-home.sh _start-search.sh _stop-search.sh
bservmgr.exe service.bat set-jmx-opts.bat start-bitbucket.bat _start-webapp.bat _stop-webapp.sh
root@bitbucket-6b968b5db8-hzs8k:/opt/atlassian/bitbucket/bin# java -jar atlassian-agent.jar -p bitbucket -m test@aa.com -n bitbucket -o http://localhost:7990 -s BB1J-AMPM-7LX2-2F3S
后面按照提示走就可以了
本项目只做个人学习研究之用,不得用于商业用途! 商业使用请向Atlassian购买正版,谢谢合作!
版权声明:
本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自
爱吃可爱多!
喜欢就支持一下吧
打赏
微信
支付宝