in contrib/cmd/runkperf/commands/data/configmaps/configmap.go [204:231]
func prepareNamespace(kubeCfgPath string, namespace string) error {
if namespace == "" {
return fmt.Errorf("namespace cannot be empty")
}
if namespace == "default" {
return nil
}
clientset, err := newClientsetWithRateLimiter(kubeCfgPath, 30, 10)
if err != nil {
return err
}
_, err = clientset.CoreV1().Namespaces().Create(context.TODO(), &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: namespace,
},
}, metav1.CreateOptions{})
if err != nil {
// If the namespace already exists, ignore the error
if errors.IsAlreadyExists(err) {
return nil
}
return fmt.Errorf("failed to create namespace %s: %v", namespace, err)
}
return nil
}