6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

kubernetes(GKE)でgcePersistentDisk使う上で注意すること

Posted at

二点ほどはまった

  1. pod起動後にContainerCreatingから進まない
  2. Root以外のユーザーが利用する場合 permissionがない

他にはGKE cluster作るときにdisk read/write scopeがないとダメかも?(自分は最初っからRWで作った)

pod起動後にContainerCreatingから進まない

これをコピペしてはまった
partition: 1を指定するとpod statusがContainerCreatingから進まない。
きっちりと調べずにおまじない的になってしまうのはあんまりよくないけど 動いたからよしとする。

deployment.yml

volumes:
- name: pd-test
  gcePersistentDisk:
    pdName: "pd-test"
    fsType: ext4
    # partition: 1 # サンプルには結構書かれてるけどこれがあると止まるから消す

Root以外のユーザーが利用する場合

基本rootになってるため、mountされたあとのdiskにpermissionがない。
これはpod.Spec.SecurityContextにlinux group idを書くことによって解決する。 
http://kubernetes.io/docs/user-guide/security-context/

kubernetes関連深い項目でもdocumentが結構わかりづらい位置にあったりする。
探し方が悪い

deployment.yml

# 対象のcontainerの中に入って `id`コマンドで実行userのgidを調べておく。
spec:
  securityContext:                                             
    fsGroup: 1000 # container user gid  
  containers: 
    # do_something...

最後にGKE上にjenkins clusterを作った時にgcePersistentDiskを使った例です。
https://github.com/Sho2010/k8s-jenkins/blob/master/k8s/jenkins-deploy.yml

GKE上で全てのjenkinsをContainer化するの極めて快適だからこの話もいつかしたい

6
6
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
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?