1、ReplicationController文件

vi iae-rc.yaml 输入

apiVersion: v1
kind: ReplicationController
metadata:
  name: web-controller
spec:
  replicas: 2
  selector:
    name: web
  template:
    metadata:
     labels:
       name: web
    spec:
     containers:
     - name: web
       image: 192.168.7.221:5000/tomcat9:v1
       imagePullPolicy: IfNotPresent
       tty: true
       ports:
       - containerPort: 8080
       volumeMounts:
       - name: web-project-path
         mountPath: /usr/local/apache-tomcat-9.0.8/webapps
       - name: web-log-path
         mountPath: /usr/local/apache-tomcat-9.0.8/logs
     volumes:
     - name: web-project-path
       hostPath: 
         path: /usr/local/k8s/web/myapps
     - name: web-log-path
       hostPath: 
         path: /usr/local/k8s/web/logs

部署

kubectl create -f iae-rc.yaml 

替换

kubectl replace -f iae-rc.yaml

查看

kubectl get rc,namespace

2、Kubernates Service文件

vi iae-svc.yaml 输入

apiVersion: v1
kind: Service
metadata:
  name: web-service-nodeport
spec:
  type: NodePort
  ports:
    - port: 8000
      targetPort: 8080
      nodePort: 30098
      protocol: TCP
  selector:
    name: web

部署

kubectl create -f iae-svc.yaml

查看

kubectl get pods,svc

删除

kubectl delete -f iae-svc.yaml

查看指定pod跑在哪个node上

kubectl get po iae-jkntk -o wide

服务网络查询service network

kubectl get services

flannel network查询

kubectl get pod -o wide

flanneld的程序

3、浏览器查询

http://192.168.7.216:30098/portal-web/swagger-ui.html

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐