Skip to content

Commit

Permalink
add scaffolding code
Browse files Browse the repository at this point in the history
  • Loading branch information
charleszheng44 committed Dec 7, 2020
1 parent 00ca26f commit f3ac4d9
Show file tree
Hide file tree
Showing 112 changed files with 3,671 additions and 9 deletions.
17 changes: 16 additions & 1 deletion PROJECT
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
version: "2"
domain: x-k8s.io
layout: go.kubebuilder.io/v2
projectName: cluster-api-provider-nested
repo: sigs.k8s.io/cluster-api-provider-nested
resources:
- group: infrastructure
kind: NestedControlPlane
version: v1alpha1
- group: infrastructure
kind: NestedAPIServer
version: v1alpha1
- group: infrastructure
kind: NestedEtcd
version: v1alpha1
- group: infrastructure
kind: NestedControllerManager
version: v1alpha1
version: 3-alpha
36 changes: 36 additions & 0 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright 2020.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1alpha1 contains API Schema definitions for the infrastructure v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=infrastructure.x-k8s.io
package v1alpha1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "infrastructure.x-k8s.io", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
70 changes: 70 additions & 0 deletions api/v1alpha1/nestedapiserver_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
Copyright 2020.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
addonv1alpha1 "sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/apis/v1alpha1"
)

// NestedAPIServerSpec defines the desired state of NestedAPIServer
type NestedAPIServerSpec struct {
// NestedComponentSpec contains the common and user-specified information that are
// required for creating the component
// +optional
NestedComponentSpec `json:",inline"`
}

// NestedAPIServerStatus defines the observed state of NestedAPIServer
type NestedAPIServerStatus struct {
// Ready is set if all resources have been created
// +kubebuilder:default=false
Ready bool `json:"ready,omitempty"`

// APIServerService is the reference to the service that expose the APIServer
// +optional
APIServerService *corev1.ObjectReference `json:"apiserverService,omitempty"`

// CommonStatus allows addons status monitoring
addonv1alpha1.CommonStatus `json:",inline"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status

// NestedAPIServer is the Schema for the nestedapiservers API
type NestedAPIServer struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec NestedAPIServerSpec `json:"spec,omitempty"`
Status NestedAPIServerStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// NestedAPIServerList contains a list of NestedAPIServer
type NestedAPIServerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []NestedAPIServer `json:"items"`
}

func init() {
SchemeBuilder.Register(&NestedAPIServer{}, &NestedAPIServerList{})
}
40 changes: 40 additions & 0 deletions api/v1alpha1/nestedcomponentspec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
Copyright 2020.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
addonv1alpha1 "sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/apis/v1alpha1"
)

type NestedComponentSpec struct {
// NestedComponentSpec defines the common information for creating the component
// +optional
addonv1alpha1.CommonSpec `json:",inline"`

// PatchSpecs includes the user specifed settings
// +optional
addonv1alpha1.PatchSpec `json:",inline"`

// Resources defines the amount of computing resources that will be used by this component
// +optional
Resources corev1.ResourceRequirements `json:"resources,omitempty"`

// Replicas defines the number of replicas in the component's workload
// +optional
Replicas int32 `json:"replicas,omitempty"`
}
64 changes: 64 additions & 0 deletions api/v1alpha1/nestedcontrollermanager_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
Copyright 2020.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
addonv1alpha1 "sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/apis/v1alpha1"
)

// NestedControllerManagerSpec defines the desired state of NestedControllerManager
type NestedControllerManagerSpec struct {
// NestedComponentSpec contains the common and user-specified information that are
// required for creating the component
// +optional
NestedComponentSpec `json:",inline"`
}

// NestedControllerManagerStatus defines the observed state of NestedControllerManager
type NestedControllerManagerStatus struct {
// Ready is set if all resources have been created
Ready bool `json:"ready,omitempty"`

// CommonStatus allows addons status monitoring
addonv1alpha1.CommonStatus `json:",inline"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status

// NestedControllerManager is the Schema for the nestedcontrollermanagers API
type NestedControllerManager struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec NestedControllerManagerSpec `json:"spec,omitempty"`
Status NestedControllerManagerStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// NestedControllerManagerList contains a list of NestedControllerManager
type NestedControllerManagerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []NestedControllerManager `json:"items"`
}

func init() {
SchemeBuilder.Register(&NestedControllerManager{}, &NestedControllerManagerList{})
}
64 changes: 64 additions & 0 deletions api/v1alpha1/nestedcontrolplane_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
Copyright 2020.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// NestedControlPlaneSpec defines the desired state of NestedControlPlane
type NestedControlPlaneSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// Foo is an example field of NestedControlPlane. Edit NestedControlPlane_types.go to remove/update
Foo string `json:"foo,omitempty"`
}

// NestedControlPlaneStatus defines the observed state of NestedControlPlane
type NestedControlPlaneStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status

// NestedControlPlane is the Schema for the nestedcontrolplanes API
type NestedControlPlane struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec NestedControlPlaneSpec `json:"spec,omitempty"`
Status NestedControlPlaneStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// NestedControlPlaneList contains a list of NestedControlPlane
type NestedControlPlaneList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []NestedControlPlane `json:"items"`
}

func init() {
SchemeBuilder.Register(&NestedControlPlane{}, &NestedControlPlaneList{})
}
81 changes: 81 additions & 0 deletions api/v1alpha1/nestedetcd_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
Copyright 2020.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
addonv1alpha1 "sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/apis/v1alpha1"
)

// NestedEtcdSpec defines the desired state of NestedEtcd
type NestedEtcdSpec struct {
// NestedComponentSpec contains the common and user-specified information that are
// required for creating the component
// +optional
NestedComponentSpec `json:",inline"`
}

// NestedEtcdStatus defines the observed state of NestedEtcd
type NestedEtcdStatus struct {
// Ready is set if all resources have been created
Ready bool `json:"ready,omitempty"`

// EtcdDomain defines how to address the etcd instance
Addresses []NestedEtcdAddress `json:"addresses,omitempty"`

// CommonStatus allows addons status monitoring
addonv1alpha1.CommonStatus `json:",inline"`
}

// EtcdAddress defines the observed addresses for etcd
type NestedEtcdAddress struct {
// IP Address of the etcd instance.
// +optional
IP string `json:"ip,omitempty"`

// Hostname of the etcd instance
Hostname string `json:"hostname,omitempty"`

// Port of the etcd instance
// +optional
Port int32 `json:"port"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status

// NestedEtcd is the Schema for the nestedetcds API
type NestedEtcd struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec NestedEtcdSpec `json:"spec,omitempty"`
Status NestedEtcdStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// NestedEtcdList contains a list of NestedEtcd
type NestedEtcdList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []NestedEtcd `json:"items"`
}

func init() {
SchemeBuilder.Register(&NestedEtcd{}, &NestedEtcdList{})
}

0 comments on commit f3ac4d9

Please sign in to comment.