0
0

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 1 year has passed since last update.

CKAD) Init Container

Posted at

  • アプリ(本番)コンテナの実行前にすでに動作するコンテナ
  • アプリ(本番)コンテナが実行する前に事前作業が必要の場合、利用する
  • Init Containerがすべて実行された後、アプリ(本番)コンテナを実行
    • Init Containerはいつも完了を目標として実行される
    • 各Init Containerは次のInit Containerが実行する前に完了されるべき
    • PodのInit Containerが失敗したら、Init Containerga成功するまでリランする
k8sホームページのInit-Container例.yaml
apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
  labels:
    app.kubernetes.io/name: MyApp
spec:
  containers: # Init container が実行完了になったら実行される
  - name: myapp-container
    image: busybox:1.28
    command: ['sh', '-c', 'echo The app is running! && sleep 3600']
  initContainers: # 記載された順番に実行する 
  - name: init-myservice
    image: busybox:1.28
    command: ['sh', '-c', "until nslookup myservice.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local; do echo waiting for myservice; sleep 2; done"]
  - name: init-mydb
    image: busybox:1.28
    command: ['sh', '-c', "until nslookup mydb.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local; do echo waiting for mydb; sleep 2; done"]
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?