-
Dockerfile文件编写
#基础镜像,如果本地仓库没有,会从远程仓库拉取 openjdk:8 FROM openjdk:8 #暴露端口 EXPOSE 9301 #容器中创建目录 RUN mkdir -p /usr/local/java #编译后的jar包copy到容器中创建到目录内 ../../realize-gateway COPY realize-auth.jar /usr/local/java/realize-auth.jar #指定容器时区 RUN rm -f /etc/localtime \ && ln -sv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && echo "Asia/Shanghai" > /etc/timezone #指定容器启动时要执行的命令 ENTRYPOINT ["java","-jar","-Dspring.profiles.active=server","/usr/local/java/realize-auth.jar"] -
kubectl 定义资源文件
apiVersion: v1 kind: Service metadata: name: $IMG_NAME namespace: rz labels: app: $IMG_NAME spec: type: ClusterIP ports: - name: tcp-9301-9301 port: 9301 protocol: TCP targetPort: 9301 selector: app: $IMG_NAME --- apiVersion: apps/v1 kind: Deployment #对象类型 metadata: name: $IMG_NAME #名称 namespace: rz labels: app: $IMG_NAME #标注 spec: replicas: 1 #运行容器的副本数,修改这里可以快速修改分布式节点数量 selector: matchLabels: app: $IMG_NAME template: metadata: labels: app: $IMG_NAME spec: containers: #docker容器的配置 - name: $IMG_NAME # env: # - name: aliyun_logs_catalina # value: stdout image: rz-image-server-registry-vpc.cn-shanghai.cr.aliyuncs.com/rz-real/$IMG_NAME:$IMG_TAG # pull镜像的地址 ip:prot/dir/images:tag imagePullPolicy: Always #pull镜像时机, ports: - containerPort: 9301 #容器对外开放端口,需与springboot配置文件一致 volumeMounts: - name: time-config mountPath: /etc/localtime readOnly: true - name: volume-logs mountPath: /logs subPath: logs resources: limits: cpu: 500m memory: 1Gi requests: cpu: 10m memory: 50Mi #从私有仓库拉取镜像凭证 imagePullSecrets: - name: miyue-vpc volumes: - name: time-config hostPath: path: /usr/share/zoneinfo/Asia/Shanghai - name: volume-logs persistentVolumeClaim: claimName: nas-volume-claim-real -
一键shell脚本部署pod
echo "开始制作镜像..." image_name=realize-auth image_tag=`date +%Y-%m-%d-%H-%M-%S` #_%H%M echo "当前时间版本号:$image_tag" docker build -t ${image_name}:${image_tag} . echo "制作镜像成功!" echo "登录" sudo docker login --username=aliyun03 rz-dt-image-server-registry-vpc.cn-shanghai.cr.aliyuncs.com --password=1234 echo "镜像最新版本提交" docker tag ${image_name}:${image_tag} rz-dt-image-server-registry-vpc.cn-shanghai.cr.aliyuncs.com/rz-dt-real/${image_name}:${image_tag} docker push rz-dt-image-server-registry-vpc.cn-shanghai.cr.aliyuncs.com/rz-dt-real/${image_name}:${image_tag} echo "k8s一键部署" export IMG_TAG=${image_tag} export IMG_NAME=${image_name} envsubst < ${image_name}'-real'.yaml | kubectl --kubeconfig ~/.kube-rz-real/config apply -f -
kubectl 运行脚本 kubernetes 部署springcloud微服务 yaml + Dockerfile+shell 脚本
xiaogg36782025-03-06 5:06
相关推荐
ruleslol11 小时前
Spring Cloud: Sentinel入门讲解小毅&Nora11 小时前
【AI微服务】【Spring AI Alibaba】② Agent 深度实战:构建可记忆、可拦截、可流式的智能体系统kong790692811 小时前
微服务项目开发环境Connie145112 小时前
记一次K8s故障告警排查(Grafna告警排查)丸子哥哥16 小时前
同一个域名,如何添加多个网站?摇滚侠19 小时前
2025最新 SpringCloud 教程,教程简介,笔记01豆奶特浓620 小时前
Java面试生死局:谢飞机遭遇在线教育场景,从JVM、Spring Security到AI Agent,他能飞吗?谷隐凡二20 小时前
Kubernetes主从架构简单解析:基于Python的模拟实现陈陈CHENCHEN20 小时前
SuperMap iManager for K8s 离线环境镜像仓库 Containerd 部署vx_vxbs6621 小时前
【SSM电动车智能充电服务平台】(免费领源码+演示录像)|可做计算机毕设Java、Python、PHP、小程序APP、C#、爬虫大数据、单片机、文案