一:使用流水线devops部署springboot项目的流程:
二、本次项目结构:
其中Dockerfile:
FROM openjdk:8-jdk LABEL maintainer=leifengyang #docker run -e PARAMS="--server.port 9090" ENV PARAMS="--server.port=8080" RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone COPY target/*.jar /app.jar EXPOSE 8080 # ENTRYPOINT ["/bin/sh","-c","java -Dfile.encoding=utf8 -Djava.security.egd=file:/dev/./urandom -jar app.jar ${PARAMS}"]
deploy.yaml:
apiVersion: apps/v1 kind: Deployment metadata: labels: app: demo-mybatis name: demo-mybatis namespace: terp #一定要写名称空间 spec: progressDeadlineSeconds: 600 replicas: 1 selector: matchLabels: app: demo-mybatis strategy: rollingUpdate: maxSurge: 50% maxUnavailable: 50% type: RollingUpdate template: metadata: labels: app: demo-mybatis spec: imagePullSecrets: - name: aliyuncs-docker-hub #提前在项目下配置访问阿里云的账号密码 containers: - image: $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:SNAPSHOT-$BUILD_NUMBER # readinessProbe: # httpGet: # path: /actuator/health # port: 8080 # timeoutSeconds: 10 # failureThreshold: 30 # periodSeconds: 5 imagePullPolicy: Always name: app ports: - containerPort: 8080 protocol: TCP resources: limits: cpu: 300m memory: 600Mi terminationMessagePath: /dev/termination-log terminationMessagePolicy: File dnsPolicy: ClusterFirst restartPolicy: Always terminationGracePeriodSeconds: 30 --- apiVersion: v1 kind: Service metadata: labels: app: demo-mybatis name: demo-mybatis namespace: terp spec: ports: - name: http port: 8080 protocol: TCP targetPort: 8080 nodePort: 32607 selector: app: demo-mybatis sessionAffinity: None type: NodePort
上面的部署文件中,我们的镜像需要从阿里云镜像仓库拉取,这里拉取的密钥是imagePullSecrets是aliyuncs-docker-hub,因此现在kubeSphere中配置好这个镜像仓库:
标签:8080,springboot,demo,app,jar,devops,mybatis,kubesphere,name From: https://www.cnblogs.com/yangxiaohui227/p/17528428.html