Skip to content

Commit

Permalink
Upgrade Tier API version to v1beta1
Browse files Browse the repository at this point in the history
Signed-off-by: graysonwu <wgrayson@vmware.com>
  • Loading branch information
GraysonWu committed Jun 27, 2023
1 parent 5c55f17 commit 7defff1
Show file tree
Hide file tree
Showing 38 changed files with 987 additions and 89 deletions.
26 changes: 26 additions & 0 deletions build/charts/antrea/crds/tier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,32 @@ spec:
group: crd.antrea.io
versions:
- name: v1alpha1
served: true
storage: false
additionalPrinterColumns:
- name: Priority
type: integer
description: The Priority of this Tier relative to other Tiers.
jsonPath: .spec.priority
- name: Age
type: date
jsonPath: .metadata.creationTimestamp
schema:
openAPIV3Schema:
type: object
properties:
spec:
required:
- priority
type: object
properties:
priority:
type: integer
minimum: 0
maximum: 255
description:
type: string
- name: v1beta1
served: true
storage: true
additionalPrinterColumns:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ webhooks:
rules:
- operations: ["CREATE", "UPDATE", "DELETE"]
apiGroups: ["crd.antrea.io"]
apiVersions: ["v1alpha1"]
apiVersions: ["v1alpha1", "v1beta1"]
resources: ["tiers"]
scope: "Cluster"
admissionReviewVersions: ["v1", "v1beta1"]
Expand Down
27 changes: 27 additions & 0 deletions build/yamls/antrea-aks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2338,6 +2338,33 @@ spec:
group: crd.antrea.io
versions:
- name: v1alpha1
served: true
storage: false
deprecated: true
additionalPrinterColumns:
- name: Priority
type: integer
description: The Priority of this Tier relative to other Tiers.
jsonPath: .spec.priority
- name: Age
type: date
jsonPath: .metadata.creationTimestamp
schema:
openAPIV3Schema:
type: object
properties:
spec:
required:
- priority
type: object
properties:
priority:
type: integer
minimum: 0
maximum: 255
description:
type: string
- name: v1beta1
served: true
storage: true
additionalPrinterColumns:
Expand Down
27 changes: 27 additions & 0 deletions build/yamls/antrea-crds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2315,6 +2315,33 @@ spec:
group: crd.antrea.io
versions:
- name: v1alpha1
served: true
storage: false
deprecated: true
additionalPrinterColumns:
- name: Priority
type: integer
description: The Priority of this Tier relative to other Tiers.
jsonPath: .spec.priority
- name: Age
type: date
jsonPath: .metadata.creationTimestamp
schema:
openAPIV3Schema:
type: object
properties:
spec:
required:
- priority
type: object
properties:
priority:
type: integer
minimum: 0
maximum: 255
description:
type: string
- name: v1beta1
served: true
storage: true
additionalPrinterColumns:
Expand Down
27 changes: 27 additions & 0 deletions build/yamls/antrea-eks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2338,6 +2338,33 @@ spec:
group: crd.antrea.io
versions:
- name: v1alpha1
served: true
storage: false
deprecated: true
additionalPrinterColumns:
- name: Priority
type: integer
description: The Priority of this Tier relative to other Tiers.
jsonPath: .spec.priority
- name: Age
type: date
jsonPath: .metadata.creationTimestamp
schema:
openAPIV3Schema:
type: object
properties:
spec:
required:
- priority
type: object
properties:
priority:
type: integer
minimum: 0
maximum: 255
description:
type: string
- name: v1beta1
served: true
storage: true
additionalPrinterColumns:
Expand Down
27 changes: 27 additions & 0 deletions build/yamls/antrea-gke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2338,6 +2338,33 @@ spec:
group: crd.antrea.io
versions:
- name: v1alpha1
served: true
storage: false
deprecated: true
additionalPrinterColumns:
- name: Priority
type: integer
description: The Priority of this Tier relative to other Tiers.
jsonPath: .spec.priority
- name: Age
type: date
jsonPath: .metadata.creationTimestamp
schema:
openAPIV3Schema:
type: object
properties:
spec:
required:
- priority
type: object
properties:
priority:
type: integer
minimum: 0
maximum: 255
description:
type: string
- name: v1beta1
served: true
storage: true
additionalPrinterColumns:
Expand Down
27 changes: 27 additions & 0 deletions build/yamls/antrea-ipsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2338,6 +2338,33 @@ spec:
group: crd.antrea.io
versions:
- name: v1alpha1
served: true
storage: false
deprecated: true
additionalPrinterColumns:
- name: Priority
type: integer
description: The Priority of this Tier relative to other Tiers.
jsonPath: .spec.priority
- name: Age
type: date
jsonPath: .metadata.creationTimestamp
schema:
openAPIV3Schema:
type: object
properties:
spec:
required:
- priority
type: object
properties:
priority:
type: integer
minimum: 0
maximum: 255
description:
type: string
- name: v1beta1
served: true
storage: true
additionalPrinterColumns:
Expand Down
27 changes: 27 additions & 0 deletions build/yamls/antrea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2338,6 +2338,33 @@ spec:
group: crd.antrea.io
versions:
- name: v1alpha1
served: true
storage: false
deprecated: true
additionalPrinterColumns:
- name: Priority
type: integer
description: The Priority of this Tier relative to other Tiers.
jsonPath: .spec.priority
- name: Age
type: date
jsonPath: .metadata.creationTimestamp
schema:
openAPIV3Schema:
type: object
properties:
spec:
required:
- priority
type: object
properties:
priority:
type: integer
minimum: 0
maximum: 255
description:
type: string
- name: v1beta1
served: true
storage: true
additionalPrinterColumns:
Expand Down
2 changes: 1 addition & 1 deletion cmd/antrea-controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func run(o *Options) error {
acnpInformer := crdInformerFactory.Crd().V1alpha1().ClusterNetworkPolicies()
eeInformer := crdInformerFactory.Crd().V1alpha2().ExternalEntities()
annpInformer := crdInformerFactory.Crd().V1alpha1().NetworkPolicies()
tierInformer := crdInformerFactory.Crd().V1alpha1().Tiers()
tierInformer := crdInformerFactory.Crd().V1beta1().Tiers()
tfInformer := crdInformerFactory.Crd().V1alpha1().Traceflows()
cgInformer := crdInformerFactory.Crd().V1alpha3().ClusterGroups()
grpInformer := crdInformerFactory.Crd().V1alpha3().Groups()
Expand Down
2 changes: 1 addition & 1 deletion docs/antrea-network-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ as was the case initially.
An example Tier might look like this:

```yaml
apiVersion: crd.antrea.io/v1alpha1
apiVersion: crd.antrea.io/v1beta1
kind: Tier
metadata:
name: mytier
Expand Down
3 changes: 2 additions & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ These are the CRDs currently available in `crd.antrea.io`.
| `ExternalIPPool` | v1alpha2 | v1.2.0 | N/A | N/A |
| `Group` | v1alpha3 | v1.8.0 | N/A | N/A |
| `NetworkPolicy` | v1alpha1 | v1.0.0 | N/A | N/A |
| `Tier` | v1alpha1 | v1.0.0 | N/A | N/A |
| `Tier` | v1beta1 | v1.13.0 | N/A | N/A |
| `Traceflow` | v1alpha1 | v1.0.0 | N/A | N/A |

### Other API groups
Expand Down Expand Up @@ -70,6 +70,7 @@ These are the API group versions which are curently available when using Antrea.
| CRD | CRD version | Introduced in | Deprecated in | Removed in |
|---|---|---|---|---|
| `ClusterGroup` | v1alpha2 | v1.0.0 | v1.1.0 | v1.12.0 [^1] |
| `Tier` | v1alpha1 | v1.0.0 | v1.13.0 | v2.0.0 |

[^1]: The v1alpha2 version of the `ClusterGroup` CRD is no longer served by the
apiserver in v1.12 and is completely removed in v1.13.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
multiclusterv1alpha1 "antrea.io/antrea/multicluster/apis/multicluster/v1alpha1"
"antrea.io/antrea/multicluster/controllers/multicluster/common"
"antrea.io/antrea/pkg/apis/crd/v1alpha1"
"antrea.io/antrea/pkg/apis/crd/v1beta1"
)

const acnpImportFailed string = "ACNPImportFailed"
Expand Down Expand Up @@ -69,7 +70,7 @@ func (r *ResourceImportReconciler) handleResImpUpdateForClusterNetworkPolicy(ctx
}
}
acnpObj := getMCAntreaClusterPolicy(resImp)
tierObj, tierName := &v1alpha1.Tier{}, acnpObj.Spec.Tier
tierObj, tierName := &v1beta1.Tier{}, acnpObj.Spec.Tier
err = r.localClusterClient.Get(ctx, types.NamespacedName{Namespace: "", Name: tierName}, tierObj)
tierNotFound := apierrors.IsNotFound(err)
if err != nil && !tierNotFound {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"antrea.io/antrea/multicluster/controllers/multicluster/common"
"antrea.io/antrea/multicluster/controllers/multicluster/commonarea"
"antrea.io/antrea/pkg/apis/crd/v1alpha1"
"antrea.io/antrea/pkg/apis/crd/v1beta1"
)

var (
Expand All @@ -55,11 +56,11 @@ var (

allowAction = v1alpha1.RuleActionAllow
dropAction = v1alpha1.RuleActionDrop
securityOpsTier = &v1alpha1.Tier{
securityOpsTier = &v1beta1.Tier{
ObjectMeta: metav1.ObjectMeta{
Name: "securityops",
},
Spec: v1alpha1.TierSpec{
Spec: v1beta1.TierSpec{
Priority: int32(100),
Description: "[READ-ONLY]: System generated SecurityOps Tier",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (
"antrea.io/antrea/multicluster/controllers/multicluster/common"
"antrea.io/antrea/multicluster/controllers/multicluster/commonarea"
"antrea.io/antrea/pkg/apis/crd/v1alpha1"
"antrea.io/antrea/pkg/apis/crd/v1beta1"
)

var (
Expand Down Expand Up @@ -121,6 +122,7 @@ var (
func init() {
utilruntime.Must(mcsv1alpha1.AddToScheme(scheme))
utilruntime.Must(v1alpha1.AddToScheme(scheme))
utilruntime.Must(v1beta1.AddToScheme(scheme))
utilruntime.Must(k8smcsapi.AddToScheme(scheme))
utilruntime.Must(k8sscheme.AddToScheme(scheme))
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/crd/v1beta1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&AntreaControllerInfoList{},
&AntreaAgentInfo{},
&AntreaAgentInfoList{},
&Tier{},
&TierList{},
)

metav1.AddToGroupVersion(
Expand Down
33 changes: 33 additions & 0 deletions pkg/apis/crd/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,36 @@ type ControllerCondition struct {
// Human readable message indicating details
Message string `json:"message,omitempty"`
}

// +genclient
// +genclient:nonNamespaced
// +genclient:noStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type Tier struct {
metav1.TypeMeta `json:",inline"`
// Standard metadata of the object.
metav1.ObjectMeta `json:"metadata,omitempty"`

// Specification of the desired behavior of Tier.
Spec TierSpec `json:"spec"`
}

// TierSpec defines the desired state for Tier.
type TierSpec struct {
// Priority specfies the order of the Tier relative to other Tiers.
Priority int32 `json:"priority"`
// Description is an optional field to add more information regarding
// the purpose of this Tier.
Description string `json:"description,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type TierList struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ListMeta `json:"metadata,omitempty"`

Items []Tier `json:"items"`
}

0 comments on commit 7defff1

Please sign in to comment.