-
Notifications
You must be signed in to change notification settings - Fork 5
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 #69 from onmetal/subnetip
Added subnetip resource
- Loading branch information
Showing
15 changed files
with
501 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
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,76 @@ | ||
/* | ||
Copyright 2021. | ||
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 ( | ||
common "github.com/onmetal/onmetal-api/apis/common/v1alpha1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"net" | ||
) | ||
|
||
// SubnetIPSpec defines the desired state of SubnetIP | ||
type SubnetIPSpec struct { | ||
// IP is the used IP in a given subnet | ||
IP net.IP `json:"ip"` | ||
// Subnet is the subnet of the IP | ||
Subnet common.ScopeReference `json:"subnet"` | ||
// Target is the resource the IP is assigned to | ||
Target common.KindReference `json:"target"` | ||
} | ||
|
||
// SubnetIPStatus defines the observed state of SubnetIP | ||
type SubnetIPStatus struct { | ||
common.StateFields `json:",inline"` | ||
} | ||
|
||
const ( | ||
SubnetIPStateAssigned = "Assigned" | ||
SubnetIPStateUnassigned = "Unassigned" | ||
SubnetIPStateInvalid = "Invalid" | ||
) | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
//+kubebuilder:printcolumn:name="IP",type=string,JSONPath=`.spec.ip` | ||
//+kubebuilder:printcolumn:name="Subnet",type=string,JSONPath=`.spec.subnet.name` | ||
//+kubebuilder:printcolumn:name="SubnetScope",type=string,JSONPath=`.spec.subnet.scope` | ||
//+kubebuilder:printcolumn:name="Target",type=string,JSONPath=`.spec.target.name` | ||
//+kubebuilder:printcolumn:name="TargetKind",type=string,JSONPath=`.spec.target.kind` | ||
//+kubebuilder:printcolumn:name="StateFields",type=string,JSONPath=`.status.state` | ||
//+kubebuilder:printcolumn:name="Age",type=string,JSONPath=`.metadata.CreationTimestamp` | ||
|
||
// SubnetIP is the Schema for the subnetips API | ||
type SubnetIP struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec SubnetIPSpec `json:"spec,omitempty"` | ||
Status SubnetIPStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// SubnetIPList contains a list of SubnetIP | ||
type SubnetIPList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []SubnetIP `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&SubnetIP{}, &SubnetIPList{}) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,124 @@ | ||
|
||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.4.1 | ||
creationTimestamp: null | ||
name: subnetips.network.onmetal.de | ||
spec: | ||
group: network.onmetal.de | ||
names: | ||
kind: SubnetIP | ||
listKind: SubnetIPList | ||
plural: subnetips | ||
singular: subnetip | ||
scope: Namespaced | ||
versions: | ||
- additionalPrinterColumns: | ||
- jsonPath: .spec.ip | ||
name: IP | ||
type: string | ||
- jsonPath: .spec.subnet.name | ||
name: Subnet | ||
type: string | ||
- jsonPath: .spec.subnet.scope | ||
name: SubnetScope | ||
type: string | ||
- jsonPath: .spec.target.name | ||
name: Target | ||
type: string | ||
- jsonPath: .spec.target.kind | ||
name: TargetKind | ||
type: string | ||
- jsonPath: .status.state | ||
name: StateFields | ||
type: string | ||
- jsonPath: .metadata.CreationTimestamp | ||
name: Age | ||
type: string | ||
name: v1alpha1 | ||
schema: | ||
openAPIV3Schema: | ||
description: SubnetIP is the Schema for the subnetips 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: SubnetIPSpec defines the desired state of SubnetIP | ||
properties: | ||
ip: | ||
description: IP is the used IP in a given subnet | ||
format: byte | ||
type: string | ||
subnet: | ||
description: Subnet is the subnet of the IP | ||
properties: | ||
name: | ||
description: Name is the name of the scope | ||
type: string | ||
scope: | ||
description: Scope is the absolute scope path | ||
type: string | ||
required: | ||
- name | ||
- scope | ||
type: object | ||
target: | ||
description: Target is the resource the IP is assigned to | ||
properties: | ||
apigroup: | ||
description: APIGroup is the API group of the object | ||
type: string | ||
kind: | ||
description: Kind is the kind of the object | ||
type: string | ||
name: | ||
description: Name is the name of the scope | ||
type: string | ||
scope: | ||
description: Scope is the absolute scope path | ||
type: string | ||
required: | ||
- apigroup | ||
- kind | ||
- name | ||
- scope | ||
type: object | ||
required: | ||
- ip | ||
- subnet | ||
- target | ||
type: object | ||
status: | ||
description: SubnetIPStatus defines the observed state of SubnetIP | ||
properties: | ||
message: | ||
description: Message contains a message for the corresponding state | ||
type: string | ||
state: | ||
description: State indicates the state of a resource | ||
type: string | ||
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: subnetips.network.onmetal.de |
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,16 @@ | ||
# The following patch enables a conversion webhook for the CRD | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: subnetips.network.onmetal.de | ||
spec: | ||
conversion: | ||
strategy: Webhook | ||
webhook: | ||
clientConfig: | ||
service: | ||
namespace: system | ||
name: webhook-service | ||
path: /convert | ||
conversionReviewVersions: | ||
- v1 |
Oops, something went wrong.