Skip to content

Commit

Permalink
Move NMState and NodeNetworkConfigurationPolicy APIs to v1 (#857)
Browse files Browse the repository at this point in the history
* Bump controller-tools to v0.6.0

Bump controller-tools to v0.6.0 as this supports the marker
"deprecatedversion" to deprecate older api resources.

Signed-off-by: Christoph Stäbler <[email protected]>

* Mark v1alpha1 api resources as deprecated

Signed-off-by: Christoph Stäbler <[email protected]>

* Promote NMState and NNCP apis to v1

Move NMState and NodeNetworkConfigurationPolicies from v1beta1 to v1 and
deprecate the coresponding v1beta1 api resources.

Signed-off-by: Christoph Stäbler <[email protected]>
  • Loading branch information
creydr authored Oct 25, 2021
1 parent b98a1cd commit 23236eb
Show file tree
Hide file tree
Showing 93 changed files with 1,315 additions and 262 deletions.
76 changes: 71 additions & 5 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,11 +1,77 @@
domain: nmstate.io
layout: go.kubebuilder.io/v2
layout:
- go.kubebuilder.io/v3
projectName: kubernetes-nmstate
repo: github.com/nmstate/kubernetes-nmstate
resources:
- group: nmstate.io
- api:
crdVersion: v1
controller: true
domain: nmstate.io
group: nmstate.io
kind: NMState
path: github.com/nmstate/kubernetes-nmstate/api/v1
version: v1
- api:
crdVersion: v1
controller: true
domain: nmstate.io
group: nmstate.io
kind: NodeNetworkConfigurationPolicy
path: github.com/nmstate/kubernetes-nmstate/api/v1
version: v1
- api:
crdVersion: v1
controller: true
domain: nmstate.io
group: nmstate.io
kind: NMState
path: github.com/nmstate/kubernetes-nmstate/api/v1beta1
version: v1beta1
- api:
crdVersion: v1
controller: true
domain: nmstate.io
group: nmstate.io
kind: NodeNetworkConfigurationEnactment
path: github.com/nmstate/kubernetes-nmstate/api/v1beta1
version: v1beta1
- api:
crdVersion: v1
controller: true
domain: nmstate.io
group: nmstate.io
kind: NodeNetworkConfigurationPolicy
path: github.com/nmstate/kubernetes-nmstate/api/v1beta1
version: v1beta1
- api:
crdVersion: v1
domain: nmstate.io
group: nmstate.io
kind: NodeNetworkState
path: github.com/nmstate/kubernetes-nmstate/api/v1beta1
version: v1beta1
version: 3-alpha
plugins:
go.sdk.operatorframework.io/v2-alpha: {}
- api:
crdVersion: v1
controller: true
domain: nmstate.io
group: nmstate.io
kind: NodeNetworkConfigurationEnactment
path: github.com/nmstate/kubernetes-nmstate/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
controller: true
domain: nmstate.io
group: nmstate.io
kind: NodeNetworkConfigurationPolicy
path: github.com/nmstate/kubernetes-nmstate/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
domain: nmstate.io
group: nmstate.io
kind: NodeNetworkState
path: github.com/nmstate/kubernetes-nmstate/api/v1alpha1
version: v1alpha1
version: "3"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ configuration on cluster nodes and to report back their current state.
Both the configuration and reporting is controlled via Kubernetes objects.

```yaml
apiVersion: nmstate.io/v1beta1
apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
name: br1-eth0
Expand Down
36 changes: 36 additions & 0 deletions api/v1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright The Kubernetes NMState 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 v1 contains API Schema definitions for the nmstate.io v1 API group
//+kubebuilder:object:generate=true
//+groupName=nmstate.io
package v1

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: "nmstate.io", Version: "v1"}

// 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
)
78 changes: 78 additions & 0 deletions api/v1/nmstate_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
Copyright The Kubernetes NMState 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 v1

import (
"github.com/nmstate/kubernetes-nmstate/api/shared"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// NMStateSpec defines the desired state of NMState
type NMStateSpec struct {
// NodeSelector is an optional selector that will be added to handler DaemonSet manifest
// for both workers and control-plane (https://github.com/nmstate/kubernetes-nmstate/blob/main/deploy/handler/operator.yaml).
// If NodeSelector is specified, the handler will run only on nodes that have each of the indicated key-value pairs
// as labels applied to the node.
// +optional
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
// Tolerations is an optional list of tolerations to be added to handler DaemonSet manifest
// If Tolerations is specified, the handler daemonset will be also scheduled on nodes with corresponding taints
// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
// InfraNodeSelector is an optional selector that will be added to webhook & certmanager Deployment manifests
// If InfraNodeSelector is specified, the webhook and certmanager will run only on nodes that have each of the indicated
// key-value pairs as labels applied to the node.
// +optional
InfraNodeSelector map[string]string `json:"infraNodeSelector,omitempty"`
// InfraTolerations is an optional list of tolerations to be added to webhook & certmanager Deployment manifests
// If InfraTolerations is specified, the handler daemonset will be able to be scheduled on nodes with corresponding taints
// +optional
InfraTolerations []corev1.Toleration `json:"infraTolerations,omitempty"`
}

// NMStateStatus defines the observed state of NMState
type NMStateStatus struct {
Conditions shared.ConditionList `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=nmstates,scope=Cluster
// +kubebuilder:storageversion
// +kubebuilder:subresource=status

// NMState is the Schema for the nmstates API
type NMState struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec NMStateSpec `json:"spec,omitempty"`
Status NMStateStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&NMState{}, &NMStateList{})
}
54 changes: 54 additions & 0 deletions api/v1/nodenetworkconfigurationpolicy_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
Copyright The Kubernetes NMState 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 v1

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

"github.com/nmstate/kubernetes-nmstate/api/shared"
)

// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// +kubebuilder:object:root=true

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

// +genclient
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=nodenetworkconfigurationpolicies,shortName=nncp,scope=Cluster
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.status==\"True\")].type",description="Status"
// +kubebuilder:storageversion

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

Spec shared.NodeNetworkConfigurationPolicySpec `json:"spec,omitempty"`
Status shared.NodeNetworkConfigurationPolicyStatus `json:"status,omitempty"`
}

func init() {
SchemeBuilder.Register(&NodeNetworkConfigurationPolicy{}, &NodeNetworkConfigurationPolicyList{})
}
Loading

0 comments on commit 23236eb

Please sign in to comment.