k8s的常用命令
kubectl get ingress -n prod kubectl get deployment -n prod kubectl get pod -n prod kubectl get service -n prod kubectl logs -f -n prod prodName-6cc4c54645-765g9 看日志 kubectl apply -f ~/Downloads/paas/007.yaml 更新配置文件
007.yaml 示例
apiVersion: apps/v1 kind: Deployment metadata: namespace: prod name: tomcat-deployment labels: app: tomcat spec: replicas: 2 selector: matchLabels: app: tomcat template: metadata: labels: app: tomcat spec: containers: - name: tomcat image: tomcat:9.0.71-jre8-temurin-focal ports: - containerPort: 8080 --- apiVersion: v1 kind: Service metadata: namespace: prod name: tomcat spec: selector: app: tomcat ports: - name: tomcat protocol: TCP port: 8080 targetPort: 8080 --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: namespace: prod name: ingress-tomcat spec: rules: - host: "k8s.agatha.pro" http: paths: - pathType: Prefix path: "/" backend: service: name: tomcat port: number: 8080
使用dockerFile部署jar包
(1)打jar包
(2)创建DockerFile文件
(3)构建镜像 docker build -t my/spring-boot .
(4)运行 docker run -d --restart=always --name demo -p 8080:8080 my/spring-boot
--restart=always 这个表示docker容器在停止或服务器开机后会自动重新启动
dockerFile文件 示例
## 基础镜像java FROM java:8 ## 作者是drgaon MAINTAINER dragon ## 就是你上传的jar包的名称。给jar包起个别名 ADD project-spring_boot-1.0-SNAPSHOT.jar spring_boot.jar ## 就是在容器中以多少端口号运行 EXPOSE 8080 ## 容器启动之后执行的命令,java -jar spring_boot.jar 即启动jar ENTRYPOINT ["java","-jar","spring_boot.jar"]
标签:prod,Java,name,tomcat,部署,boot,jar,8080,k8s From: https://www.cnblogs.com/pzyin/p/17092900.html