root@k8s-node1 test]# cat nginx_tomcat.yaml 
apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: tomcat-nginx-pod
spec:
  replicas: 1
  selector:
    matchLabels:
      app: test
  template:
    metadata:
      labels:
        app: test
    spec:
      containers:
      - name: nginx
        image: daocloud.io/library/nginx:1.13.0-alpine
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 80
      - name: tomcat
        image: daocloud.io/library/tomcat:8.5.21-jre8-alpine
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
  name: tomcat-nginx-svc
spec:
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
      name: nginx
    - port: 8080
      targetPort: 8080
      protocol: TCP
      name: tomcat
  selector:
    app: test
  type: NodePort
Logo

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

更多推荐