This repository has been archived by the owner on Oct 28, 2024. It is now read-only.
generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from charleszheng44/feature/nestedetcd
Add the scaffolding code for NestedEtcd
- Loading branch information
Showing
18 changed files
with
720 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
domain: cluster.x-k8s.io | ||
layout: go.kubebuilder.io/v3 | ||
projectName: cluster-api-provider-nested | ||
multigroup: true | ||
projectName: cluster-api-provider-nested | ||
repo: sigs.k8s.io/cluster-api-provider-nested | ||
resources: | ||
- group: controlplane | ||
kind: NestedControlPlane | ||
version: v1alpha4 | ||
- api: | ||
crdVersion: v1 | ||
group: controlplane | ||
kind: NestedEtcd | ||
version: v1alpha4 | ||
version: 3-alpha |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
Copyright 2021 The Kubernetes Authors. | ||
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 v1alpha4 | ||
|
||
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` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
Copyright 2021 The Kubernetes Authors. | ||
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 v1alpha4 | ||
|
||
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{}) | ||
} |
52 changes: 52 additions & 0 deletions
52
config/crd/bases/controlplane.cluster.x-k8s.io_nestedcontrolplanes.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.4.1-0.20201002000720-57250aac17f6 | ||
creationTimestamp: null | ||
name: nestedcontrolplanes.controlplane.cluster.x-k8s.io | ||
spec: | ||
group: controlplane.cluster.x-k8s.io | ||
names: | ||
kind: NestedControlPlane | ||
listKind: NestedControlPlaneList | ||
plural: nestedcontrolplanes | ||
singular: nestedcontrolplane | ||
scope: Namespaced | ||
versions: | ||
- name: v1alpha4 | ||
schema: | ||
openAPIV3Schema: | ||
description: NestedControlPlane is the Schema for the nestedcontrolplanes 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: NestedControlPlaneSpec defines the desired state of NestedControlPlane | ||
properties: | ||
foo: | ||
description: Foo is an example field of NestedControlPlane. Edit NestedControlPlane_types.go to remove/update | ||
type: string | ||
type: object | ||
status: | ||
description: NestedControlPlaneStatus defines the observed state of NestedControlPlane | ||
type: object | ||
type: object | ||
served: true | ||
storage: true | ||
subresources: | ||
status: {} | ||
status: | ||
acceptedNames: | ||
kind: "" | ||
plural: "" | ||
conditions: [] | ||
storedVersions: [] |
116 changes: 116 additions & 0 deletions
116
config/crd/bases/controlplane.cluster.x-k8s.io_nestedetcds.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
|
||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.4.1-0.20201002000720-57250aac17f6 | ||
creationTimestamp: null | ||
name: nestedetcds.controlplane.cluster.x-k8s.io | ||
spec: | ||
group: controlplane.cluster.x-k8s.io | ||
names: | ||
kind: NestedEtcd | ||
listKind: NestedEtcdList | ||
plural: nestedetcds | ||
singular: nestedetcd | ||
scope: Namespaced | ||
versions: | ||
- name: v1alpha4 | ||
schema: | ||
openAPIV3Schema: | ||
description: NestedEtcd is the Schema for the nestedetcds 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: NestedEtcdSpec defines the desired state of NestedEtcd | ||
properties: | ||
channel: | ||
description: 'Channel specifies a channel that can be used to resolve a specific addon, eg: stable It will be ignored if Version is specified' | ||
type: string | ||
patches: | ||
items: | ||
type: object | ||
type: array | ||
replicas: | ||
description: Replicas defines the number of replicas in the component's workload | ||
format: int32 | ||
type: integer | ||
resources: | ||
description: Resources defines the amount of computing resources that will be used by this component | ||
properties: | ||
limits: | ||
additionalProperties: | ||
anyOf: | ||
- type: integer | ||
- type: string | ||
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ | ||
x-kubernetes-int-or-string: true | ||
description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' | ||
type: object | ||
requests: | ||
additionalProperties: | ||
anyOf: | ||
- type: integer | ||
- type: string | ||
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ | ||
x-kubernetes-int-or-string: true | ||
description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/' | ||
type: object | ||
type: object | ||
version: | ||
description: Version specifies the exact addon version to be deployed, eg 1.2.3 It should not be specified if Channel is specified | ||
type: string | ||
type: object | ||
status: | ||
description: NestedEtcdStatus defines the observed state of NestedEtcd | ||
properties: | ||
addresses: | ||
description: EtcdDomain defines how to address the etcd instance | ||
items: | ||
description: EtcdAddress defines the observed addresses for etcd | ||
properties: | ||
hostname: | ||
description: Hostname of the etcd instance | ||
type: string | ||
ip: | ||
description: IP Address of the etcd instance. | ||
type: string | ||
port: | ||
description: Port of the etcd instance | ||
format: int32 | ||
type: integer | ||
type: object | ||
type: array | ||
errors: | ||
items: | ||
type: string | ||
type: array | ||
healthy: | ||
type: boolean | ||
phase: | ||
type: string | ||
ready: | ||
description: Ready is set if all resources have been created | ||
type: boolean | ||
required: | ||
- healthy | ||
type: object | ||
type: object | ||
served: true | ||
storage: true | ||
subresources: | ||
status: {} | ||
status: | ||
acceptedNames: | ||
kind: "" | ||
plural: "" | ||
conditions: [] | ||
storedVersions: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# 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: nestedetcds.controlplane.cluster.x-k8s.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# The following patch enables a conversion webhook for the CRD | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: nestedetcds.controlplane.cluster.x-k8s.io | ||
spec: | ||
conversion: | ||
strategy: Webhook | ||
webhook: | ||
clientConfig: | ||
service: | ||
namespace: system | ||
name: webhook-service | ||
path: /convert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# permissions for end users to edit nestedetcds. | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: nestedetcd-editor-role | ||
rules: | ||
- apiGroups: | ||
- controlplane.cluster.x-k8s.io | ||
resources: | ||
- nestedetcds | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
- apiGroups: | ||
- controlplane.cluster.x-k8s.io | ||
resources: | ||
- nestedetcds/status | ||
verbs: | ||
- get |
Oops, something went wrong.