func deleteServices(kubeClient client.Interface, ns string) error {
	items, err := kubeClient.Services(ns).List(labels.Everything())
	if err != nil {
		return err
	}
	for i := range items.Items {
		err := kubeClient.Services(ns).Delete(items.Items[i].Name)
		if err != nil {
			return err
		}
	}
	return nil
}
Exemple #2
0
func loadServices(g osgraph.Graph, graphLock sync.Mutex, namespace string, kclient kclient.Interface, client client.Interface) error {
	svcs, err := kclient.Services(namespace).List(labels.Everything())
	if err != nil {
		return err
	}

	graphLock.Lock()
	defer graphLock.Unlock()
	for i := range svcs.Items {
		kubegraph.EnsureServiceNode(g, &svcs.Items[i])
	}

	return nil
}
Exemple #3
0
func createService(ctx api.Context, name string, port int, client client.Interface) (*api.Service, error) {
	// TODO remove context in favor of just namespace string
	svc := &api.Service{
		ObjectMeta: api.ObjectMeta{
			Name: name,
			Labels: map[string]string{
				"name": name,
			},
		},
		Spec: api.ServiceSpec{
			Port: port,
			Selector: map[string]string{
				"name": name,
			},
		},
	}
	svc, err := client.Services(api.Namespace(ctx)).Create(svc)
	return svc, err
}