0
0

More than 1 year has passed since last update.

CKA試験、Volume EmptyDir(命令語のみ)

Posted at

Volume

EmptyDir

次の条件に合わせて、nginxwebサーバが生成したログファイルをもらい、STDOUTで出力するbusyboxコンテナーを運営しなさい

  • pod名: weblog1
  • Web Container
    • image: nginx:1.17
    • Volume mount: /var/log/nginx
    • readwrite権限
  • Log Container
    • image: busybox
    • Command: /bin/sh, -c, "tail -n+1 -f /data/access.log"
    • Volume mount: /data
    • readonly
  • emptyDirを利用した、データ共有
kubectl run weblog --image=nginx:1.17 --dry-run=client -o yaml > weblog1.yaml
修正前weblog1.yaml
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: weblog1
  name: weblog1
spec:
  containers:
  - image: nginx:1.17
    name: weblog1
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}
修正後weblog1.yaml
apiVersion: v1
kind: Pod
metadata:
  labels:
    run: weblog1
  name: weblog1
spec:
  containers:
  - image: nginx:1.17
    name: weblog1
    volumeMounts:
    - mountPath: /var/log/nginx # path を記載する
      name: cache-volume # volumesと合わせる

  - image: busybox
    name: busybox2
    args: [/bin/sh, -c, 'tail -n+1 -F /data/access.log'] 
    volumeMounts:
    - mountPath: /data # path を記載する
      name: cache-volume # volumesと合わせる
      readOnly: true # readOnly: true

  volumes:
  - name: cache-volume
    emptyDir: {}

kubectl apply -f weblog1.yaml
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0