오늘은 k8s를 사용해 JupyterNotebook을 설치해보겠다.
deployment
jupyter-deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: jupyter-deployment
namespace: jupyter-notebook
spec:
replicas: 1
selector:
matchLabels:
app: jupyter-deploy
template:
spec:
nodeSelector:
nodeType: worker-node1
metadata:
labels:
app: jupyter-deploy
spec:
containers:
- name: jupyter-container
image: jupyter/tensorflow-notebook:tensorflow-2.12.0
securityContext:
runAsUser: 0
ports:
- containerPort: 8888
volumeMounts:
- name: config-volume
mountPath: /home/jovyan/.jupyter
- name: data-volume
mountPath: /home/jovyan/.local/share/jupyter
- name: work-volume
mountPath: /home/jovyan/work
volumes:
- name: config-volume
hostPath:
path: /data/jupyter-notebook/config
- name: data-volume
hostPath:
path: /data/jupyter-notebook/data
- name: work-volume
hostPath:
path: /data/jupyter-notebook/work
volumes를 설정하기 위해 주피터 노트북내 파드에 접근하여 공통 디렉토리 및 파일 위치를 확인해야한다
jupyter --config-dir
jupyter --data-dir
위 명령어로 디렉토리를 확인후 volumeMounts 필드에 mountPath에 작성해주면 된다
work같은 경우에는 주피터 노트북에서 파이썬 파일을 저장할 때 work 디렉토리로 저장되기 때문에 work 경로를 추가 해줬다.
volumes 필드에 hostPath에 path 경로를 설정하기 위해 worker-node1에 접속한 후
config,data,work 디렉토리를 만들어준다.
Service
jupyter-service.yaml
apiVersion: v1
kind: Service
metadata:
name: jupyter-service
spec:
type: NodePort
selector:
app: jupyter-deploy
ports:
- protocol: TCP
port: 8888
targetPort: 8888
nodePort: 31000
'인프라 > kubernetes' 카테고리의 다른 글
[Kubernetes] Helm (1) - Helm이란? (0) | 2023.07.14 |
---|---|
[Kubernetes] 오브젝트 이름 규칙 (0) | 2023.07.06 |
[kubernetes] 쿠버네티스란? (0) | 2022.08.01 |