Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
Create HierarchicalNamespace CRD
Browse files Browse the repository at this point in the history
This CRD is created as the UX of the HNC self-service namespace. See
design at http://bit.ly/hnc-self-serve-ux.

Tested on a GKE cluster by "kubectl apply -f" the generated CRD yaml
file. The CRD was created with success.
  • Loading branch information
yiqigao217 committed Feb 24, 2020
1 parent 95218a0 commit 8a39dbb
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 5 deletions.
67 changes: 67 additions & 0 deletions incubator/hnc/api/v1alpha1/hierarchical_namespace.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
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"
)

// HNSStatus describes the status of a hierarchical namespace. The status could be
// "missing", "ok" or "conflict". The definitions will be described below.
type HNSStatus string

const (
// Missing means the child namespace has not been created yet. This should be the default
// status when the HNS is just created.
Missing HNSStatus = "missing"

// Ok means the child namespace exists.
Ok HNSStatus = "ok"

// Conflict means a namespace of the same name already exists.
Conflict HNSStatus = "conflict"
)

// HierarchicalNamespaceStatus defines the observed state of HierarchicalNamespace.
type HierarchicalNamespaceStatus struct {
// API version of the kind defined below. This is used to unambiguously identifies the kind.
Status HNSStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=hierarchicalnamespaces,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{})
}
73 changes: 73 additions & 0 deletions incubator/hnc/api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
name: hierarchicalnamespaces.hnc.x-k8s.io
spec:
group: hnc.x-k8s.io
names:
kind: HierarchicalNamespace
listKind: HierarchicalNamespaceList
plural: hierarchicalnamespaces
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: API version of the kind defined below. This is used to
unambiguously identifies the kind.
type: string
type: object
type: object
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.4
creationTimestamp: null
name: hierarchyconfigurations.hnc.x-k8s.io
spec:
Expand All @@ -14,7 +12,7 @@ spec:
listKind: HierarchyConfigurationList
plural: hierarchyconfigurations
singular: hierarchyconfiguration
scope: Namespaced
scope: ""
validation:
openAPIV3Schema:
description: Hierarchy is the Schema for the hierarchies API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.4
creationTimestamp: null
name: hncconfigurations.hnc.x-k8s.io
spec:
Expand Down

0 comments on commit 8a39dbb

Please sign in to comment.