使用k8s回调函数,部署rabbitmq自动初始化一些操作
apiVersion: v1 kind: Pod metadata: name: lifecycle-demo spec: containers: - name: lifecycle-demo-container image: nginx lifecycle: # 回调 postStart: # 容器启动后 exec:
# Kubernetes容器管理逻辑会一直阻塞等待 postStart 处理函数执行完毕,延长等待10s,让容器启动完。 command: ["/bin/sh", "-c", "sleep 10;rabbitmqctl add_user username password;set_user_tags username management;rabbitmqctl add_vhost /vhost1;"] #preStop: 容器停止后 # exec: # command: ["/bin/sh","-c","nginx -s quit; while killall -0 nginx; do sleep 1; done"]
标签:容器,k8s,demo,nginx,回调,lifecycle From: https://www.cnblogs.com/colin88/p/16643661.html