Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.8k views
in Technique[技术] by (71.8m points)

kubernetes - Helm install in certain order

I am trying to create a Helm Chart with the following resources:

  1. Secret
  2. ConfigMap
  3. Service
  4. Job
  5. Deployment

These are also in the order that I would like them to be deployed. I have put a hook in the Deployment so that it is post-install, but then Helm does not see it as a resource and I have to manually manage it.

The Job needs the information in the Secret and ConfigMap, otherwise I would make that a pre-install hook. But I can't make everything a hook or nothing will be managed in my release.

Does anyone have a solution or idea to be able to manage all of the resources within the Helm release AND make sure the Job finishes before the Deployment begins?

My only thought right now is two make two Charts: One with 1-4 and the second with 5 which would depend on the first.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Helm collects all of the resources in a given Chart and it's dependencies, groups them by resource type, and then installs them in the following order (see here - Helm 2.10):

  1. Namespace
  2. ResourceQuota
  3. LimitRange
  4. PodSecurityPolicy
  5. Secret
  6. ConfigMap
  7. StorageClass
  8. PersistentVolume
  9. PersistentVolumeClaim
  10. ServiceAccount
  11. CustomResourceDefinition
  12. ClusterRole
  13. ClusterRoleBinding
  14. Role
  15. RoleBinding
  16. Service
  17. DaemonSet
  18. Pod
  19. ReplicationController
  20. ReplicaSet
  21. Deployment
  22. StatefulSet
  23. Job
  24. CronJob
  25. Ingress
  26. APIService

During uninstallation of a release, the order is reversed (see here).

Following this logic, in your case when your Job resource is created, both the Secret and the ConfigMap will already be applied, but Helm won't wait for the Job to complete before applying the Deployment. If you split your Chart to two parts (1-4, 5) and install them sequentially you would still have the problem of the Deployment being possibly applied before the Job is completed. What I would suggest is splitting your Chart to two parts (1-3, 4-5), in which the the Job has a pre-install hook, which would make sure it completes before your Deployment is applied.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...