Example #1
0
func (this *PodHandler) Patch(args *types.Pod, reply *types.Event) error {
	c := NewkubeClient()
	pods := c.Pods(args.ParentId)

	// 转换配置文件
	conf := utils.PodToKubeStruct(args)

	reply.Id = conf.GetName()

	_, err := pods.Update(conf)
	if err != nil {
		return err
	}
	return nil
}
Example #2
0
func (this *PodHandler) Post(args *types.Pod, reply *types.Event) error {
	c := NewkubeClient()
	pods := c.Pods(args.ParentId)

	if len(args.Containers) == 0 {
		return errors.New("一个实例至少有一个容器")
	}

	// 转换配置文件
	conf := utils.PodToKubeStruct(args)

	_, err := pods.Create(conf)
	if err != nil {
		return err
	}
	return nil
}