k8s 创建deployment 挂载宿主机


 

 

 

kind: Deployment
apiVersion: apps/v1
metadata:
  labels:
    app: test-yfs
    version: v0.1
  name: test-yfs
  namespace: kube-ops
spec:
  replicas: 1
  selector:
    matchLabels:
      app: test-yfs
  template:
    metadata:
      labels:
        app: test-yfs
    spec:
      containers:
      - name: test-yfs
        image: harbor.test.com/test/tomcat8.5:v2
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 8080
          protocol: TCP
        volumeMounts: 
        - name: test-yfs
          mountPath: /usr/local/tomcat/webapps
      volumes: 
      - name: test-yfs
        hostPath:
          path: /opt/test
          type: Directory
      nodeSelector:
        test.com/projet: test

 

 

 

 

kind: Service
apiVersion: v1
metadata:
  labels:
    app: test-svc
  name: test-svc
  namespace: kube-ops
spec:
  type: NodePort
  ports:
  - port: 8080
    name: http
    targetPort: 8080
    nodePort: 30807
  selector:
    app: test-yfs
  sessionAffinity: ClientIP

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM