From f87baf004dda2693cd7c97a1021ca2fbb13932ab Mon Sep 17 00:00:00 2001 From: Sergei Lukianov Date: Thu, 5 Dec 2024 17:11:43 -0800 Subject: [PATCH] Get rid of the control node object leftovers --- PROJECT | 12 ---- .../wiring.githedgehog.com_controlnodes.yaml | 60 ------------------- config/crd/kustomization.yaml | 3 - .../cainjection_in_wiring_controlnodes.yaml | 7 --- .../webhook_in_wiring_controlnodes.yaml | 16 ----- config/rbac/kustomization.yaml | 4 +- .../rbac/wiring_controlnode_editor_role.yaml | 27 --------- .../rbac/wiring_controlnode_viewer_role.yaml | 23 ------- pkg/hhfctl/inspect/fabric.go | 38 +----------- 9 files changed, 3 insertions(+), 187 deletions(-) delete mode 100644 config/crd/bases/wiring.githedgehog.com_controlnodes.yaml delete mode 100644 config/crd/patches/cainjection_in_wiring_controlnodes.yaml delete mode 100644 config/crd/patches/webhook_in_wiring_controlnodes.yaml delete mode 100644 config/rbac/wiring_controlnode_editor_role.yaml delete mode 100644 config/rbac/wiring_controlnode_viewer_role.yaml diff --git a/PROJECT b/PROJECT index 2b31cded..3bb5e316 100644 --- a/PROJECT +++ b/PROJECT @@ -203,16 +203,4 @@ resources: kind: Catalog path: go.githedgehog.com/fabric/api/agent/v1beta1 version: v1beta1 -- api: - crdVersion: v1 - namespaced: true - domain: githedgehog.com - group: wiring - kind: ControlNode - path: go.githedgehog.com/fabric/api/wiring/v1beta1 - version: v1beta1 - webhooks: - defaulting: true - validation: true - webhookVersion: v1 version: "3" diff --git a/config/crd/bases/wiring.githedgehog.com_controlnodes.yaml b/config/crd/bases/wiring.githedgehog.com_controlnodes.yaml deleted file mode 100644 index fd2a06ef..00000000 --- a/config/crd/bases/wiring.githedgehog.com_controlnodes.yaml +++ /dev/null @@ -1,60 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.14.0 - name: controlnodes.wiring.githedgehog.com -spec: - group: wiring.githedgehog.com - names: - kind: ControlNode - listKind: ControlNodeList - plural: controlnodes - singular: controlnode - scope: Namespaced - versions: - - name: v1beta1 - schema: - openAPIV3Schema: - description: ControlNode is the Schema for the controlnodes API - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: ControlNodeSpec defines configuration for the ControlNode - properties: - extIP: - type: string - extIface: - type: string - mgmtIP: - type: string - mgmtIface: - type: string - targetDevice: - type: string - type: object - status: - description: ControlNodeStatus defines the observed state of ControlNode - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 5c9fb113..7d773fda 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -33,7 +33,6 @@ resources: - bases/vpc.githedgehog.com_externalpeerings.yaml - bases/dhcp.githedgehog.com_dhcpsubnets.yaml - bases/agent.githedgehog.com_catalogs.yaml - - bases/wiring.githedgehog.com_controlnodes.yaml #+kubebuilder:scaffold:crdkustomizeresource patches: @@ -56,7 +55,6 @@ patches: #- path: patches/webhook_in_dhcp_dhcpsubnets.yaml #- path: patches/webhook_in_agent_catalogs.yaml - path: patches/webhook_in_wiring_switchprofiles.yaml - - path: patches/webhook_in_wiring_controlnodes.yaml #+kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. @@ -78,7 +76,6 @@ patches: #- path: patches/cainjection_in_dhcp_dhcpsubnets.yaml #- path: patches/cainjection_in_agent_catalogs.yaml - path: patches/cainjection_in_wiring_switchprofiles.yaml - - path: patches/cainjection_in_wiring_controlnodes.yaml #+kubebuilder:scaffold:crdkustomizecainjectionpatch # the following config is for teaching kustomize how to do kustomization for CRDs. diff --git a/config/crd/patches/cainjection_in_wiring_controlnodes.yaml b/config/crd/patches/cainjection_in_wiring_controlnodes.yaml deleted file mode 100644 index 24cdff79..00000000 --- a/config/crd/patches/cainjection_in_wiring_controlnodes.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# The following patch adds a directive for certmanager to inject CA into the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME - name: controlnodes.wiring.githedgehog.com diff --git a/config/crd/patches/webhook_in_wiring_controlnodes.yaml b/config/crd/patches/webhook_in_wiring_controlnodes.yaml deleted file mode 100644 index ea4f4850..00000000 --- a/config/crd/patches/webhook_in_wiring_controlnodes.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# The following patch enables a conversion webhook for the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: controlnodes.wiring.githedgehog.com -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1 diff --git a/config/rbac/kustomization.yaml b/config/rbac/kustomization.yaml index 370fd31a..378f3644 100644 --- a/config/rbac/kustomization.yaml +++ b/config/rbac/kustomization.yaml @@ -34,6 +34,4 @@ resources: # For each CRD, "Editor" and "Viewer" roles are scaffolded by # default, aiding admins in cluster management. Those roles are # not used by the Project itself. You can comment the following lines -# if you do not want those helpers be installed with your Project. -# - wiring_controlnode_editor_role.yaml -# - wiring_controlnode_viewer_role.yaml \ No newline at end of file +# if you do not want those helpers be installed with your Project. \ No newline at end of file diff --git a/config/rbac/wiring_controlnode_editor_role.yaml b/config/rbac/wiring_controlnode_editor_role.yaml deleted file mode 100644 index 78b33398..00000000 --- a/config/rbac/wiring_controlnode_editor_role.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# permissions for end users to edit controlnodes. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: fabric - app.kubernetes.io/managed-by: kustomize - name: wiring-controlnode-editor-role -rules: -- apiGroups: - - wiring.githedgehog.com - resources: - - controlnodes - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - wiring.githedgehog.com - resources: - - controlnodes/status - verbs: - - get diff --git a/config/rbac/wiring_controlnode_viewer_role.yaml b/config/rbac/wiring_controlnode_viewer_role.yaml deleted file mode 100644 index 0e020f68..00000000 --- a/config/rbac/wiring_controlnode_viewer_role.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# permissions for end users to view controlnodes. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: fabric - app.kubernetes.io/managed-by: kustomize - name: wiring-controlnode-viewer-role -rules: -- apiGroups: - - wiring.githedgehog.com - resources: - - controlnodes - verbs: - - get - - list - - watch -- apiGroups: - - wiring.githedgehog.com - resources: - - controlnodes/status - verbs: - - get diff --git a/pkg/hhfctl/inspect/fabric.go b/pkg/hhfctl/inspect/fabric.go index 37947b92..3bd641a4 100644 --- a/pkg/hhfctl/inspect/fabric.go +++ b/pkg/hhfctl/inspect/fabric.go @@ -35,14 +35,8 @@ type FabricIn struct { } type FabricOut struct { - Summary string `json:"summary,omitempty"` - ControlNodes []*FabricOutControl `json:"controlNodes,omitempty"` - Switches []*FabricOutSwitch `json:"switches,omitempty"` -} - -type FabricOutControl struct { - Name string `json:"name,omitempty"` - State *AgentState `json:"state,omitempty"` + Summary string `json:"summary,omitempty"` + Switches []*FabricOutSwitch `json:"switches,omitempty"` } type FabricOutSwitch struct { @@ -58,30 +52,6 @@ type FabricOutSwitch struct { func (out *FabricOut) MarshalText() (string, error) { str := &strings.Builder{} - // TODO return back after there is an agent running on the control node again - // str.WriteString("Control Nodes:\n") - - // ctrlData := [][]string{} - // for _, ctrl := range out.ControlNodes { - // applied := "" - - // if !ctrl.State.LastAppliedTime.IsZero() { - // applied = humanize.Time(ctrl.State.LastAppliedTime.Time) - // } - - // ctrlData = append(ctrlData, []string{ - // ctrl.Name, - // ctrl.State.Summary, - // fmt.Sprintf("%d/%d", ctrl.State.LastAppliedGen, ctrl.State.DesiredGen), - // applied, - // humanize.Time(ctrl.State.LastHeartbeat.Time), - // }) - // } - // str.WriteString(RenderTable( - // []string{"Name", "State", "Gen", "Applied", "Heartbeat"}, - // ctrlData, - // )) - str.WriteString("Switches:\n") swData := [][]string{} @@ -174,10 +144,6 @@ func Fabric(ctx context.Context, kube client.Reader, _ FabricIn) (*FabricOut, er return strings.Compare(a.Name, b.Name) }) - slices.SortFunc(out.ControlNodes, func(a, b *FabricOutControl) int { - return strings.Compare(a.Name, b.Name) - }) - out.Summary = fmt.Sprintf("Ready: %d/%d switches", readySwitches, totalSwitches) return out, nil