apiVersion: v1
kind: ReplicationController
metadata:
  namespace: dev
  name: uas
spec:
  replicas: 1
  selector:
    app: uas
  template:
    metadata:
      labels:
        app: uas
    spec:
      volumes:
      - name: uas-webapp
        hostPath:
          path: /app/meap/UAS/webapps
      - name: uas-logs
        hostPath:
          path: /app/meap/UAS/logs
      containers:
      - name: uas
        image: google_containers/centos6-tomcat:v7.0
        ports:
        - containerPort: 8080
        volumeMounts:
        - name: uas-webapp
          mountPath: /usr/local/tomcat7/webapps
        - name: uas-logs
          mountPath: /usr/local/tomcat7/logs
      nodeName: xxx.xxx.241.xxx
---
apiVersion: v1
kind: Service
metadata:
  namespace: dev
  name: uas
spec:
  selector:
    app: uas
  type: NodePort
  ports:
  - port: 8082
    targetPort: 8080
    nodePort: 8082

说明:
1、文件夹挂载:
volumes:指定宿主机挂载目录
volumeMounts:docker容器目录
#注#当需要映射配置文件时,同样适用,写全文件名路径

2、端口映射:
containerPort/targetPort:tomcat默认使用8080端口
port/nodePort:宿主机的端口,从其他服务器访问的端口




启动命令:k create -f uas.yaml
删除命令:k delete -f uas.yaml



Logo

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

更多推荐