Revert "Introduce APIs to support multiple ClusterCIDRs (#108290)"
This reverts commit b9792a9daef4d978c5c30b6d10cbcdfa77a9b6ac. Kubernetes-commit: 7d57d5c70d04f652b431d2b86b8af40e119cd66a
This commit is contained in:
parent
f0ce177e80
commit
03614470e1
|
|
@ -46,7 +46,6 @@ import (
|
|||
discoveryv1beta1 "k8s.io/api/discovery/v1beta1"
|
||||
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
|
||||
networkingv1 "k8s.io/api/networking/v1"
|
||||
networkingv1alpha1 "k8s.io/api/networking/v1alpha1"
|
||||
networkingv1beta1 "k8s.io/api/networking/v1beta1"
|
||||
policyv1 "k8s.io/api/policy/v1"
|
||||
policyv1beta1 "k8s.io/api/policy/v1beta1"
|
||||
|
|
@ -214,7 +213,6 @@ func describerMap(clientConfig *rest.Config) (map[schema.GroupKind]ResourceDescr
|
|||
{Group: networkingv1beta1.GroupName, Kind: "IngressClass"}: &IngressClassDescriber{c},
|
||||
{Group: networkingv1.GroupName, Kind: "Ingress"}: &IngressDescriber{c},
|
||||
{Group: networkingv1.GroupName, Kind: "IngressClass"}: &IngressClassDescriber{c},
|
||||
{Group: networkingv1alpha1.GroupName, Kind: "CusterCIDRConfig"}: &ClusterCIDRConfigDescriber{c},
|
||||
{Group: batchv1.GroupName, Kind: "Job"}: &JobDescriber{c},
|
||||
{Group: batchv1.GroupName, Kind: "CronJob"}: &CronJobDescriber{c},
|
||||
{Group: batchv1beta1.GroupName, Kind: "CronJob"}: &CronJobDescriber{c},
|
||||
|
|
@ -2821,63 +2819,6 @@ func (i *IngressClassDescriber) describeIngressClassV1(ic *networkingv1.IngressC
|
|||
})
|
||||
}
|
||||
|
||||
// ClusterCIDRConfigDescriber generates information about a ClusterCIDRConfig.
|
||||
type ClusterCIDRConfigDescriber struct {
|
||||
client clientset.Interface
|
||||
}
|
||||
|
||||
func (c *ClusterCIDRConfigDescriber) Describe(namespace, name string, describerSettings DescriberSettings) (string, error) {
|
||||
var events *corev1.EventList
|
||||
|
||||
cccV1alpha1, err := c.client.NetworkingV1alpha1().ClusterCIDRConfigs().Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err == nil {
|
||||
if describerSettings.ShowEvents {
|
||||
events, _ = searchEvents(c.client.CoreV1(), cccV1alpha1, describerSettings.ChunkSize)
|
||||
}
|
||||
return c.describeClusterCIDRConfigV1alpha1(cccV1alpha1, events)
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
|
||||
func (c *ClusterCIDRConfigDescriber) describeClusterCIDRConfigV1alpha1(ccc *networkingv1alpha1.ClusterCIDRConfig, events *corev1.EventList) (string, error) {
|
||||
return tabbedString(func(out io.Writer) error {
|
||||
w := NewPrefixWriter(out)
|
||||
w.Write(LEVEL_0, "Name:\t%v\n", ccc.Name)
|
||||
printLabelsMultiline(w, "Labels", ccc.Labels)
|
||||
printAnnotationsMultiline(w, "Annotations", ccc.Annotations)
|
||||
|
||||
w.Write(LEVEL_0, "NodeSelector:\n")
|
||||
if ccc.Spec.NodeSelector != nil {
|
||||
w.Write(LEVEL_1, "NodeSelector Terms:")
|
||||
if len(ccc.Spec.NodeSelector.NodeSelectorTerms) == 0 {
|
||||
w.WriteLine("<none>")
|
||||
} else {
|
||||
w.WriteLine("")
|
||||
for i, term := range ccc.Spec.NodeSelector.NodeSelectorTerms {
|
||||
printNodeSelectorTermsMultilineWithIndent(w, LEVEL_2, fmt.Sprintf("Term %v", i), "\t", term.MatchExpressions)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ccc.Spec.PerNodeHostBits != 0 {
|
||||
w.Write(LEVEL_0, "PerNodeHostBits:\t%s\n", fmt.Sprint(ccc.Spec.PerNodeHostBits))
|
||||
}
|
||||
|
||||
if ccc.Spec.IPv4CIDR != "" {
|
||||
w.Write(LEVEL_0, "IPv4CIDR:\t%s\n", ccc.Spec.IPv4CIDR)
|
||||
}
|
||||
|
||||
if ccc.Spec.IPv6CIDR != "" {
|
||||
w.Write(LEVEL_0, "IPv6CIDR:\t%s\n", ccc.Spec.IPv6CIDR)
|
||||
}
|
||||
|
||||
if events != nil {
|
||||
DescribeEvents(events, w)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// ServiceDescriber generates information about a service.
|
||||
type ServiceDescriber struct {
|
||||
clientset.Interface
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
autoscalingv1 "k8s.io/api/autoscaling/v1"
|
||||
autoscalingv2beta2 "k8s.io/api/autoscaling/v2beta2"
|
||||
|
|
@ -35,7 +34,6 @@ import (
|
|||
discoveryv1 "k8s.io/api/discovery/v1"
|
||||
discoveryv1beta1 "k8s.io/api/discovery/v1beta1"
|
||||
networkingv1 "k8s.io/api/networking/v1"
|
||||
networkingv1alpha1 "k8s.io/api/networking/v1alpha1"
|
||||
networkingv1beta1 "k8s.io/api/networking/v1beta1"
|
||||
policyv1 "k8s.io/api/policy/v1"
|
||||
policyv1beta1 "k8s.io/api/policy/v1beta1"
|
||||
|
|
@ -5235,64 +5233,6 @@ Events: <none>` + "\n",
|
|||
}
|
||||
}
|
||||
|
||||
func TestDescribeClusterCIDRConfig(t *testing.T) {
|
||||
|
||||
testcases := map[string]struct {
|
||||
input *fake.Clientset
|
||||
output string
|
||||
}{
|
||||
"ClusterCIDRConfig v1alpha1": {
|
||||
input: fake.NewSimpleClientset(&networkingv1alpha1.ClusterCIDRConfig{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "foo.123",
|
||||
},
|
||||
Spec: networkingv1alpha1.ClusterCIDRConfigSpec{
|
||||
PerNodeHostBits: int32(8),
|
||||
IPv4CIDR: "10.1.0.0/16",
|
||||
IPv6CIDR: "fd00:1:1::/64",
|
||||
NodeSelector: &corev1.NodeSelector{
|
||||
NodeSelectorTerms: []corev1.NodeSelectorTerm{
|
||||
{
|
||||
MatchExpressions: []corev1.NodeSelectorRequirement{
|
||||
{
|
||||
Key: "foo",
|
||||
Operator: "In",
|
||||
Values: []string{"bar"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
|
||||
output: `Name: foo.123
|
||||
Labels: <none>
|
||||
Annotations: <none>
|
||||
NodeSelector:
|
||||
NodeSelector Terms:
|
||||
Term 0: foo in [bar]
|
||||
PerNodeHostBits: 8
|
||||
IPv4CIDR: 10.1.0.0/16
|
||||
IPv6CIDR: fd00:1:1::/64
|
||||
Events: <none>` + "\n",
|
||||
},
|
||||
}
|
||||
|
||||
for name, tc := range testcases {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
c := &describeClient{T: t, Namespace: "foo", Interface: tc.input}
|
||||
d := ClusterCIDRConfigDescriber{c}
|
||||
out, err := d.Describe("bar", "foo.123", DescriberSettings{ShowEvents: true})
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
if out != tc.output {
|
||||
t.Errorf("expected :\n%s\nbut got output:\n%s diff:\n%s", tc.output, out, cmp.Diff(tc.output, out))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestControllerRef(t *testing.T) {
|
||||
var replicas int32 = 1
|
||||
f := fake.NewSimpleClientset(
|
||||
|
|
|
|||
Loading…
Reference in New Issue