Docker学习(六)-Kubernetes - Spring Boot 应用

接上一篇

https://www.cnblogs.com/woxpp/p/11872155.html

新建

k8s-demo.yaml

apiVersion: apps/v1beta2  
kind: Deployment  
metadata:  
  name: k8s-springboot-demo  
  labels:  
    app: k8s-springboot-demo  
spec:  
  replicas: 1
  revisionHistoryLimit: 10
  selector:  
    matchLabels:  
      app: k8s-springboot-demo 
  template:  
    metadata:  
      labels:  
        app: k8s-springboot-demo  
    spec:  
      containers:  
      - name: k8s-springboot-demo
        image: service-test:latest
        ports:  
        - containerPort: 8080
          protocol: TCP  
        livenessProbe:  
          httpGet:  
            path: /  
            port: 8080  
          initialDelaySeconds: 30  
          timeoutSeconds: 30  
        imagePullPolicy: IfNotPresent  
      tolerations:  
      - key: node-role.kubernetes.io/master  
        effect: NoSchedule  
  
---  
apiVersion: v1  
kind: Service  
metadata:  
  name: k8s-springboot-demo
  namespace: default
  labels:  
    app: k8s-springboot-demo
spec:  
  ports:  
    - port: 8080
      targetPort: 8080
  selector:  
    app: k8s-springboot-demo 
  type: NodePort 

创建service

 kubectl create -f k8s-demo.yaml

查看实列运行情况

kubectl get po,svc,deploy -o wide

 

 

 测试访问

NodePort方式,可以到任意一个节点的30516端口查看

 

posted @ 2019-11-18 17:13  释迦苦僧  阅读(668)  评论(0编辑  收藏  举报