Skip to content

Commit

Permalink
Introduce openshift markers support and generate CRDs
Browse files Browse the repository at this point in the history
  • Loading branch information
enxebre committed Oct 17, 2024
1 parent 2f2139e commit 3f0c674
Show file tree
Hide file tree
Showing 52 changed files with 110,105 additions and 11,403 deletions.
32 changes: 27 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ TOOLS_DIR=./hack/tools
BIN_DIR=bin
TOOLS_BIN_DIR := $(TOOLS_DIR)/$(BIN_DIR)
CONTROLLER_GEN := $(abspath $(TOOLS_BIN_DIR)/controller-gen)
CODE_GEN := $(abspath $(TOOLS_BIN_DIR)/codegen)
STATICCHECK := $(abspath $(TOOLS_BIN_DIR)/staticcheck)
GENAPIDOCS := $(abspath $(TOOLS_BIN_DIR)/gen-crd-api-reference-docs)

Expand Down Expand Up @@ -62,6 +63,10 @@ verify: update staticcheck fmt vet
$(CONTROLLER_GEN): $(TOOLS_DIR)/go.mod # Build controller-gen from tools folder.
cd $(TOOLS_DIR); GO111MODULE=on GOFLAGS=-mod=vendor GOWORK=off go build -tags=tools -o $(BIN_DIR)/controller-gen sigs.k8s.io/controller-tools/cmd/controller-gen

$(CODE_GEN): $(TOOLS_DIR)/go.mod # Build code-gen from tools folder.
cd $(TOOLS_DIR); GO111MODULE=on GOFLAGS=-mod=vendor GOWORK=off go build -tags=tools -o $(BIN_DIR)/codegen github.com/openshift/api/tools/codegen/cmd


$(STATICCHECK): $(TOOLS_DIR)/go.mod # Build staticcheck from tools folder.
cd $(TOOLS_DIR); GO111MODULE=on GOFLAGS=-mod=vendor GOWORK=off go build -tags=tools -o $(BIN_DIR)/staticcheck honnef.co/go/tools/cmd/staticcheck

Expand Down Expand Up @@ -100,12 +105,29 @@ product-cli:
api: hypershift-api cluster-api cluster-api-provider-aws cluster-api-provider-ibmcloud cluster-api-provider-kubevirt cluster-api-provider-agent cluster-api-provider-azure cluster-api-provider-openstack api-docs

.PHONY: hypershift-api
hypershift-api: $(CONTROLLER_GEN)
hypershift-api: $(CONTROLLER_GEN) $(CODE_GEN)
# Clean up autogenerated files.
rm -rf ./api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests
rm -rf ./api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests.yaml
rm -rf cmd/install/assets/hypershift-operator/*

$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./api/..."
rm -rf cmd/install/assets/hypershift-operator/*.yaml
$(CONTROLLER_GEN) $(CRD_OPTIONS) paths="./api/..." output:crd:artifacts:config=cmd/install/assets/hypershift-operator
# TODO: remove when we complete the switch to the new CPO approach.
mv cmd/install/assets/hypershift-operator/hypershift.openshift.io_controlplanecomponents.yaml support/controlplane-component/crds

# These consolidate with the 3 steps used to generate CRDs by openshift/api.
$(CODE_GEN) empty-partial-schemas --base-dir ./api/hypershift/v1beta1
$(CODE_GEN) schemapatch --base-dir ./api/hypershift/v1beta1
$(CODE_GEN) crd-manifest-merge --manifest-merge:payload-manifest-path ./api/hypershift/v1beta1/featuregates --base-dir ./api/hypershift/v1beta1

# Move final CRDs to the install folder.
mv ./api/hypershift/v1beta1/zz_generated.crd-manifests cmd/install/assets/hypershift-operator/

# Generate additional CRDs.
$(CONTROLLER_GEN) $(CRD_OPTIONS) paths="./api/scheduling/..." output:crd:artifacts:config=cmd/install/assets/hypershift-operator
$(CONTROLLER_GEN) $(CRD_OPTIONS) paths="./api/certificates/..." output:crd:artifacts:config=cmd/install/assets/hypershift-operator

# TODO: Create a feature gate and install controlplanecomponents in TechPreviewNoUpgrde featureSet.
# TODO: remove when we complete the switch to the new CPO approach.
mv ./cmd/install/assets/hypershift-operator/zz_generated.crd-manifests/controlplanecomponents-CustomNoUpgrade.crd.yaml support/controlplane-component/crds/hypershift.openshift.io_controlplanecomponents.yaml

.PHONY: cluster-api
cluster-api: $(CONTROLLER_GEN)
Expand Down
2 changes: 1 addition & 1 deletion api/hypershift/v1alpha1/endpointservice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ type AWSEndpointService struct {
Status AWSEndpointServiceStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
// AWSEndpointServiceList contains a list of AWSEndpointService
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type AWSEndpointServiceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand Down
3 changes: 1 addition & 2 deletions api/hypershift/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
package v1alpha1

import (
"github.com/openshift/hypershift/api/hypershift"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: hypershift.GroupName, Version: "v1alpha1"}
GroupVersion = schema.GroupVersion{Group: "hypershift.openshift.io", Version: "v1alpha1"}
SchemeGroupVersion = GroupVersion

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
Expand Down
2 changes: 1 addition & 1 deletion api/hypershift/v1alpha1/hostedcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2213,8 +2213,8 @@ type HostedCluster struct {
Status HostedClusterStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
// HostedClusterList contains a list of HostedCluster
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type HostedClusterList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand Down
3 changes: 1 addition & 2 deletions api/hypershift/v1alpha1/nodepool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ type NodePoolStatus struct {
}

// NodePoolList contains a list of NodePools.
//
// +kubebuilder:object:root=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type NodePoolList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand Down
156 changes: 156 additions & 0 deletions api/hypershift/v1alpha1/zz_generated.featuregated-crd-manifests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
awsendpointservices.hypershift.openshift.io:
Annotations: {}
ApprovedPRNumber: ""
CRDName: awsendpointservices.hypershift.openshift.io
Capability: ""
Category: ""
FeatureGates: []
FilenameOperatorName: ""
FilenameOperatorOrdering: ""
FilenameRunLevel: ""
GroupName: hypershift.openshift.io
HasStatus: true
KindName: AWSEndpointService
Labels: {}
PluralName: awsendpointservices
PrinterColumns: []
Scope: Namespaced
ShortNames: null
TopLevelFeatureGates: []
Version: v1alpha1

hostedclusters.hypershift.openshift.io:
Annotations: {}
ApprovedPRNumber: ""
CRDName: hostedclusters.hypershift.openshift.io
Capability: ""
Category: ""
FeatureGates:
- DynamicResourceAllocation
- ExternalOIDC
- NetworkDiagnosticsConfig
FilenameOperatorName: ""
FilenameOperatorOrdering: ""
FilenameRunLevel: ""
GroupName: hypershift.openshift.io
HasStatus: true
KindName: HostedCluster
Labels: {}
PluralName: hostedclusters
PrinterColumns:
- description: Version
jsonPath: .status.version.history[?(@.state=="Completed")].version
name: Version
type: string
- description: KubeConfig Secret
jsonPath: .status.kubeconfig.name
name: KubeConfig
type: string
- description: Progress
jsonPath: .status.version.history[?(@.state!="")].state
name: Progress
type: string
- description: Available
jsonPath: .status.conditions[?(@.type=="Available")].status
name: Available
type: string
- description: Progressing
jsonPath: .status.conditions[?(@.type=="Progressing")].status
name: Progressing
type: string
- description: Message
jsonPath: .status.conditions[?(@.type=="Available")].message
name: Message
type: string
Scope: Namespaced
ShortNames:
- hc
- hcs
TopLevelFeatureGates: []
Version: v1alpha1

hostedcontrolplanes.hypershift.openshift.io:
Annotations: {}
ApprovedPRNumber: ""
CRDName: hostedcontrolplanes.hypershift.openshift.io
Capability: ""
Category: cluster-api
FeatureGates:
- DynamicResourceAllocation
- ExternalOIDC
- NetworkDiagnosticsConfig
FilenameOperatorName: ""
FilenameOperatorOrdering: ""
FilenameRunLevel: ""
GroupName: hypershift.openshift.io
HasStatus: true
KindName: HostedControlPlane
Labels: {}
PluralName: hostedcontrolplanes
PrinterColumns: []
Scope: Namespaced
ShortNames:
- hcp
- hcps
TopLevelFeatureGates: []
Version: v1alpha1

nodepools.hypershift.openshift.io:
Annotations: {}
ApprovedPRNumber: ""
CRDName: nodepools.hypershift.openshift.io
Capability: ""
Category: ""
FeatureGates: []
FilenameOperatorName: ""
FilenameOperatorOrdering: ""
FilenameRunLevel: ""
GroupName: hypershift.openshift.io
HasStatus: true
KindName: NodePool
Labels: {}
PluralName: nodepools
PrinterColumns:
- description: Cluster
jsonPath: .spec.clusterName
name: Cluster
type: string
- description: Desired Nodes
jsonPath: .spec.replicas
name: Desired Nodes
type: integer
- description: Available Nodes
jsonPath: .status.replicas
name: Current Nodes
type: integer
- description: Autoscaling Enabled
jsonPath: .status.conditions[?(@.type=="AutoscalingEnabled")].status
name: Autoscaling
type: string
- description: Node Autorepair Enabled
jsonPath: .status.conditions[?(@.type=="AutorepairEnabled")].status
name: Autorepair
type: string
- description: Current version
jsonPath: .status.version
name: Version
type: string
- description: UpdatingVersion in progress
jsonPath: .status.conditions[?(@.type=="UpdatingVersion")].status
name: UpdatingVersion
type: string
- description: UpdatingConfig in progress
jsonPath: .status.conditions[?(@.type=="UpdatingConfig")].status
name: UpdatingConfig
type: string
- description: Message
jsonPath: .status.conditions[?(@.type=="Ready")].message
name: Message
type: string
Scope: Namespaced
ShortNames:
- np
- nps
TopLevelFeatureGates: []
Version: v1alpha1

Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ type CertificateSigningRequestApprovalSpec struct{}
// CertificateSigningRequestApprovalStatus defines the observed state of CertificateSigningRequestApproval
type CertificateSigningRequestApprovalStatus struct{}

// +kubebuilder:object:root=true

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// CertificateSigningRequestApprovalList contains a list of CertificateSigningRequestApprovals.
type CertificateSigningRequestApprovalList struct {
metav1.TypeMeta `json:",inline"`
Expand Down
3 changes: 2 additions & 1 deletion api/hypershift/v1beta1/controlplanecomponent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ type ControlPlaneComponentStatus struct {
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.conditions[?(@.type==\"Available\")].message",description="Message"
// +kubebuilder:printcolumn:name="ProgressingMessage",type="string",priority=1,JSONPath=".status.conditions[?(@.type==\"Progressing\")].message",description="ProgressingMessage"
// ControlPlaneComponent specifies the state of a ControlPlane Component
// +openshift:enable:FeatureGate=ControlPlaneV2
type ControlPlaneComponent struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -86,7 +87,7 @@ type ControlPlaneComponent struct {
Status ControlPlaneComponentStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ControlPlaneComponentList contains a list of ControlPlaneComponent
type ControlPlaneComponentList struct {
metav1.TypeMeta `json:",inline"`
Expand Down
2 changes: 1 addition & 1 deletion api/hypershift/v1beta1/endpointservice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ type AWSEndpointService struct {
Status AWSEndpointServiceStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
// AWSEndpointServiceList contains a list of AWSEndpointService
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type AWSEndpointServiceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"apiVersion": "config.openshift.io/v1",
"kind": "FeatureGate",
"metadata": {
"annotations": {
"include.release.openshift.io/ibm-cloud-managed": "false-except-for-the-config-operator"
},
"creationTimestamp": null,
"name": "cluster"
},
"spec": {
"featureSet": ""
},
"status": {
"featureGates": [
{
"disabled": [
{
"name": "OpenStack"
}
],
"enabled": [
# We enable all OCP feature gates only so the CRD contains the fields.
# Each HostedCluster can configure their specific feature gate CR at creation time via spec.configuration.
{
"name": "ExternalOIDC"
},
{
"name": "DynamicResourceAllocation"
},
{
"name": "NetworkDiagnosticsConfig"
}
],
"version": ""
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"apiVersion": "config.openshift.io/v1",
"kind": "FeatureGate",
"metadata": {
"annotations": {
"include.release.openshift.io/ibm-cloud-managed": "false-except-for-the-config-operator"
},
"creationTimestamp": null,
"name": "cluster"
},
"spec": {
"featureSet": "TechPreviewNoUpgrade"
},
"status": {
"featureGates": [
{
"disabled": [],
"enabled": [
{
"name": "ExternalOIDC"
},
{
"name": "DynamicResourceAllocation"
},
{
"name": "NetworkDiagnosticsConfig"
},
{
"name": "OpenStack"
}
],
"version": ""
}
]
}
}
Loading

0 comments on commit 3f0c674

Please sign in to comment.