k8s应用
作者:互联网
创建镜像
执行
kubectl create -f springboot-demo-template.yaml
apiVersion: apps/v1 #kubectl api-versions 可以通过这条指令去看版本信息 kind: Deployment # 指定资源类别 metadata: #资源的一些元数据 name: springboot-demo-deployment #deloyment的名称 labels: app: springboot-demo-deployment #标签 spec: replicas: 2 #创建pod的个数 selector: matchLabels: app: springboot-demo-deployment #满足标签为这个的时候相关的pod才能被调度到 template: metadata: labels: app: springboot-demo-deployment spec: containers: - name: springboot-boot-demo-v1 image: springboot-demo:1.0 imagePullPolicy: IfNotPresent ports: - containerPort: 8080
执行
kubectl expose deployment springboot-demo-deployment --type=NodePort
kubectl get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.43.0.1 <none> 443/TCP 2d11h
mongo ClusterIP 10.43.159.130 <none> 27017/TCP 2d8h
springboot-demo-deployment NodePort 10.43.15.205 <none> 8080:30799/TCP 37s
[root@localhost demo]# kubectl get pods
NAME READY STATUS RESTARTS AGE
mongo-75f59d57f4-mmp98 1/1 Running 2 (46h ago) 2d8h
springboot-demo-deployment-84c64f7f6b-qdnzs 1/1 Running 0 33s
springboot-demo-deployment-84c64f7f6b-xcsvl 1/1 Running 0 33s
在浏览器访问:
http://192.168.49.102:30799/doc.html
标签:kubectl,springboot,demo,TCP,10.43,应用,deployment,k8s 来源: https://www.cnblogs.com/beilong/p/15869398.html