Cloud/Kubernetes

R Studio YAML (Deployment, Template)

퐁스 2021. 2. 15. 11:14

 노션에만 정리해두었는데, 블로그 관리 안한지 너무 오래되서 같이 기재한다.

1. Deployment

kind: Deployment
apiVersion: apps/v1
metadata:
  name: rstudio-deploy
  labels:
    app: rstudio
spec:
  replicas: 1
  selector:
    matchLabels:
      app: rstudio
  template:
    metadata:
      labels:
        app: rstudio
    spec:
      volumes:
        - name: rstudio
          persistentVolumeClaim:
            claimName: rstudio
      containers:
        - resources: {}
          name: rstudio
          env:
            - name: PASSWORD
              value: [password]
            - name: ROOT
              value: 'TRUE'
            - name: USER
              value: [user]
          ports:
            - name: http
              containerPort: 8787
              protocol: TCP
          volumeMounts:
            - name: rstudio
              mountPath: /home/rstudio
          terminationMessagePolicy: File
          image: 'rocker/rstudio:4.0.3'

2. Template

apiVersion: v1
kind: Template
metadata:
  name: RStudio-template
shortDescription: RStudio Deployment
longDescription: RStudio Deployment
urlDescription: 'https://hub.docker.com/r/rocker/rstudio'
imageUrl: 'https://blog.kakaocdn.net/dn/kHVJJ/btqyiAIwZzy/uJ4cXwNHqnjWGkXoYKkeM1/img.png'
tags:
- rstudio
parameters:
  - description: RStudio Deployment Name
    displayName: AppName
    name: APP_NAME
    required: true
  - description: RStudio Login User Name
    displayName: ID
    name: ID
    required: true
  - description: RStudio Login User Password
    displayName: PWD
    name: PWD
    required: true
  - description: Storage size
    displayName: Storage
    name: STORAGE
    required: true
  - description: StorageClass name
    displayName: StorageClass
    name: STORAGE_CLASS
    required: true
  - description: Service Type (ClsuterIP/NodePort/LoadBalancer)
    displayName: ServiceType
    name: SERVICE_TYPE
    required: true
objectKinds:
  - Service (ClusterIP)
  - PersistentVolumeClaim
  - Deployment
objects:
  - apiVersion: v1
    kind: Service
    metadata:
      labels:
        app: '${APP_NAME}'
      name: '${APP_NAME}-svc'
    spec:
      ports:
        - name: http
          port: 8787
          targetPort: 8787
      selector:
        app: '${APP_NAME}'
      type: '${SERVICE_TYPE}'
  - apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      labels:
        app: '${APP_NAME}'
      name: '${APP_NAME}-pvc'
    spec:
      accessModes:
        - ReadWriteMany
      resources:
        requests:
          storage: '${STORAGE}'
      storageClassName: '${STORAGE_CLASS}'
  - apiVersion: apps/v1
    kind: Deployment
    metadata:
      labels:
        app: '${APP_NAME}'
      name: '${APP_NAME}'
    spec:
      selector:
        matchLabels:
          app: '${APP_NAME}'
      template:
        metadata:
          labels:
            app: '${APP_NAME}'
        spec:
          containers:
            - name: '${APP_NAME}'
              image: 'rocker/rstudio:4.0.3'
              ports:
                - containerPort: 8787
                  name: http
              volumeMounts:
                - mountPath: '/home/${ID}'
                  name: '${APP_NAME}-pv'
              env:
                - name: USER
                  value: '${ID}'
                - name: PASSWORD
                  value: '${PWD}'
                - name: ROOT
                  value: 'TURE'
          volumes:
            - name: '${APP_NAME}-pv'
              persistentVolumeClaim:
                claimName: '${APP_NAME}-pvc'