This repository has been archived by the owner on Jun 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 173
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 #448 from yiqigao217/self-service-namespace
Create HierarchicalNamespace CRD
- Loading branch information
Showing
5 changed files
with
212 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
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" | ||
) | ||
|
||
// HNSState describes the state of a hierarchical namespace. The state could be | ||
// "missing", "ok" or "conflict". The definitions will be described below. | ||
type HNSState string | ||
|
||
// HNSStates, which are documented in the comment to HierarchicalNamespaceStatus.State. | ||
const ( | ||
Missing HNSState = "missing" | ||
Ok HNSState = "ok" | ||
Conflict HNSState = "conflict" | ||
) | ||
|
||
// HierarchicalNamespaceStatus defines the observed state of HierarchicalNamespace. | ||
type HierarchicalNamespaceStatus struct { | ||
// Describes the state of a hierarchical namespace. | ||
// | ||
// Currently, the supported values are: | ||
// | ||
// - "missing": the child namespace has not been created yet. This should be the default | ||
// state when the HNS is just created. | ||
// | ||
// - "ok": the child namespace exists. | ||
// | ||
// - "conflict": a namespace of the same name already exists. If the validation webhook | ||
// works properly, this should never happen since the HNS won't be created at the first place. | ||
State HNSState `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:resource:path=hierarchicalnamespaces,shortName=hns,scope=Namespaced | ||
|
||
// HierarchicalNamespace is the Schema for the self-service namespace API. | ||
// See details at http://bit.ly/hnc-self-serve-ux. | ||
type HierarchicalNamespace struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Status HierarchicalNamespaceStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// HierarchicalNamespaceList contains a list of HierarchicalNamespace. | ||
type HierarchicalNamespaceList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []HierarchicalNamespace `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&HierarchicalNamespace{}, &HierarchicalNamespaceList{}) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
incubator/hnc/config/crd/bases/hnc.x-k8s.io_hierarchicalnamespaces.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,61 @@ | ||
|
||
--- | ||
apiVersion: apiextensions.k8s.io/v1beta1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.2.4 | ||
creationTimestamp: null | ||
name: hierarchicalnamespaces.hnc.x-k8s.io | ||
spec: | ||
group: hnc.x-k8s.io | ||
names: | ||
kind: HierarchicalNamespace | ||
listKind: HierarchicalNamespaceList | ||
plural: hierarchicalnamespaces | ||
shortNames: | ||
- hns | ||
singular: hierarchicalnamespace | ||
scope: Namespaced | ||
validation: | ||
openAPIV3Schema: | ||
description: HierarchicalNamespace is the Schema for the self-service namespace | ||
API. See details at http://bit.ly/hnc-self-serve-ux. | ||
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/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/api-conventions.md#types-kinds' | ||
type: string | ||
metadata: | ||
type: object | ||
status: | ||
description: HierarchicalNamespaceStatus defines the observed state of HierarchicalNamespace. | ||
properties: | ||
status: | ||
description: "Describes the state of a hierarchical namespace. \n Currently, | ||
the supported values are: \n - \"missing\": the child namespace has | ||
not been created yet. This should be the default state when the HNS | ||
is just created. \n - \"ok\": the child namespace exists. \n - \"conflict\": | ||
a namespace of the same name already exists. If the validation webhook | ||
works properly, this should never happen since the HNS won't be created | ||
at the first place." | ||
type: string | ||
type: object | ||
type: object | ||
version: v1alpha1 | ||
versions: | ||
- name: v1alpha1 | ||
served: true | ||
storage: true | ||
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,5 @@ | ||
apiVersion: hnc.x-k8s.io/v1alpha1 | ||
kind: HierarchicalNamespace | ||
metadata: | ||
name: hns-sample | ||
spec: |