k8s部署Jupyter应用

目录

示例模板是一个Jupyter应用,包括一个deployment和service

# Define the tensorflow deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: tf-notebook
  labels:
    app: tf-notebook
spec:
  replicas: 1
  selector: # define how the deployment finds the pods it mangages
    matchLabels:
      app: tf-notebook
  template: # define the pods specifications
    metadata:
      labels:
        app: tf-notebook
    spec:
      containers:
      - name: tf-notebook
        image: tensorflow/tensorflow:1.4.1-gpu-py3
        resources:
          limits:
            nvidia.com/gpu: 1                      #指定调用nvidia gpu的数量
        ports:
        - containerPort: 8888
          hostPort: 8888
        env:
          - name: PASSWORD                         # 指定访问Jupyter服务的密码,您可以按照您的需要修改
            value: mypassw0rd

# Define the tensorflow service
---
apiVersion: v1
kind: Service
metadata:
  name: tf-notebook
spec:
  ports:
  - port: 80
    targetPort: 8888
    name: jupyter
  selector:
    app: tf-notebook
  type: LoadBalancer  

旧的GPU部署方案,您必须要定义如下的nvidia驱动所在的数据卷。

volumes:
    - hostPath:
        path: /usr/lib/nvidia-375/bin
        name: bin
    - hostPath:
        path: /usr/lib/nvidia-375
        name: lib

这需要您在编写部署文件时,强依赖于所在的集群,导致缺乏可移植性。但是在Kubernetes 1.9.3及之后的版本中,最终用户无需指定这些hostPath,nvidia的插件会自发现驱动所需的库链接和执行文件

随机文章