1、搞定基础镜像
docker pull openjdk:8-jre-alpine
docker tag openjdk:8-jre-alpine 10.204.82.15/kubernetes/openjdk:8-jre-alpine
docker push 10.204.82.15/kubernetes/openjdk:8-jre-alpine
2、springboot-web应用服务打包
3、编写Dockerfile构建镜像
FROM 10.204.82.15/kubernetes/openjdk:8-jre-alpineCOPY target/springboot-web-demo-1.0-SNAPSHOT.jar /springboot-web.jarENTRYPOINT ["java", "-jar", "/springboot-web.jar"]
docker build -t springboot-web:v1 .docker tag springboot-web:v1 10.204.82.15/kubernetes/springboot-web:v1
4、编写springboot-web.yaml
#deploy
apiVersion: apps/v1
kind: Deployment
metadata:name: springboot-web-demo
spec:selector:matchLabels:app: springboot-web-demoreplicas: 1template:metadata:labels:app: springboot-web-demospec:nodeSelector:app: ingresscontainers:- name: springboot-web-demoimage: 10.204.82.15/kubernetes/springboot-web:v1ports:- containerPort: 8080
---
#service
apiVersion: v1
kind: Service
metadata:name: springboot-web-demo
spec:ports:- port: 80protocol: TCPtargetPort: 8080selector:app: springboot-web-demotype: ClusterIP---
#ingress
apiVersion: extensions/v1beta1
kind: Ingress
metadata:name: springboot-web-demo
spec:rules:- host: springboot.mooc.comhttp:paths:- path: /backend:serviceName: springboot-web-demoservicePort: 80
5、启动容器
kubectl apply -f springboot-web.yamlkubectl get pods -o wide