1、k8s部署tomcat的yaml文件

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mytomcat
spec:
  replicas: 5
  selector:
    matchLabels:
      app: mytomcat
  minReadySeconds: 1
  progressDeadlineSeconds: 60
  revisionHistoryLimit: 5
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
  template:
    metadata:
      name: mytomcat
      labels:
        app: mytomcat
    spec:
      containers:
      - name: mytomcat
        image: tomcat:8
        ports:
        - containerPort: 8080
        volumeMounts:
        - name: tz-config
          mountPath: /etc/localtime
      volumes:
      - name: tz-config
        hostPath:
          path: /usr/share/zoneinfo/Asia/Shanghai

2、k8s部署tomcat的svc文件

apiVersion: v1
kind: Service
metadata:
  name: mytomcat
spec:
  type: NodePort
  ports:
   - port: 8080
     nodePort: 30012
  selector:
    app: mytomcat
Logo

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

更多推荐