如何正确使用Kubernetes客户端到服务器端应用功能?

k5ifujac  于 2022-12-11  发布在  Kubernetes
关注(0)|答案(1)|浏览(353)

When I run the below code using client-go library I get an inscrutable error? What am I doing wrong?

ctx := context.TODO()

    ns := applycorev1.NamespaceApplyConfiguration{
        ObjectMetaApplyConfiguration: &applymetav1.ObjectMetaApplyConfiguration{
            Name: to.StringPtr("foobar"),
        },
    }

    if _, err := kubeClient.CoreV1().Namespaces().Apply(ctx, &ns, v1.ApplyOptions{}); err != nil {
        panic(err)
    }

Yields the very unhelpful error:
panic: PatchOptions.meta.k8s.io "" is invalid: fieldManager: Required value: is required for apply patch
What is the correct way to send an Apply operation to the API server in Kube using client-go?

相关问题