-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
1,511 additions
and
88 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,47 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! | ||
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. | ||
|
||
// AzureNetworkInterfaceSpec defines the desired state of AzureNetworkInterface | ||
type AzureNetworkInterfaceSpec struct { | ||
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster | ||
// Important: Run "make" to regenerate code after modifying this file | ||
Location string `json:"location"` | ||
ResourceGroup string `json:"resourceGroup"` | ||
VNetName string `json:"vnetName"` | ||
SubnetName string `json:"subnetName"` | ||
PublicIPAddressName string `json:"publicIPAddressName"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
|
||
// AzureNetworkInterface is the Schema for the azurenetworkinterfaces API | ||
type AzureNetworkInterface struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec AzureNetworkInterfaceSpec `json:"spec,omitempty"` | ||
Status ASOStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// AzureNetworkInterfaceList contains a list of AzureNetworkInterface | ||
type AzureNetworkInterfaceList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []AzureNetworkInterface `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&AzureNetworkInterface{}, &AzureNetworkInterfaceList{}) | ||
} |
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,71 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"golang.org/x/net/context" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/types" | ||
) | ||
|
||
// These tests are written in BDD-style using Ginkgo framework. Refer to | ||
// http://onsi.github.io/ginkgo to learn more. | ||
|
||
var _ = Describe("AzureNetworkInterface", func() { | ||
var ( | ||
key types.NamespacedName | ||
created, fetched *AzureNetworkInterface | ||
) | ||
|
||
BeforeEach(func() { | ||
// Add any setup steps that needs to be executed before each test | ||
}) | ||
|
||
AfterEach(func() { | ||
// Add any teardown steps that needs to be executed after each test | ||
}) | ||
|
||
// Add Tests for OpenAPI validation (or additonal CRD features) specified in | ||
// your API definition. | ||
// Avoid adding tests for vanilla CRUD operations because they would | ||
// test Kubernetes API server, which isn't the goal here. | ||
Context("Create API", func() { | ||
|
||
It("should create an object successfully", func() { | ||
|
||
key = types.NamespacedName{ | ||
Name: "foo", | ||
Namespace: "default", | ||
} | ||
created = &AzureNetworkInterface{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "foo", | ||
Namespace: "default", | ||
}, | ||
Spec: AzureNetworkInterfaceSpec{ | ||
Location: "westus", | ||
ResourceGroup: "foo-nic", | ||
VNetName: "test", | ||
SubnetName: "test", | ||
PublicIPAddressName: "test", | ||
}} | ||
|
||
By("creating an API obj") | ||
Expect(k8sClient.Create(context.TODO(), created)).To(Succeed()) | ||
|
||
fetched = &AzureNetworkInterface{} | ||
Expect(k8sClient.Get(context.TODO(), key, fetched)).To(Succeed()) | ||
Expect(fetched).To(Equal(created)) | ||
|
||
By("deleting the created object") | ||
Expect(k8sClient.Delete(context.TODO(), created)).To(Succeed()) | ||
Expect(k8sClient.Get(context.TODO(), key, created)).ToNot(Succeed()) | ||
}) | ||
|
||
}) | ||
|
||
}) |
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,48 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! | ||
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. | ||
|
||
// AzurePublicIPAddressSpec defines the desired state of AzurePublicIPAddress | ||
type AzurePublicIPAddressSpec struct { | ||
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster | ||
// Important: Run "make" to regenerate code after modifying this file | ||
Location string `json:"location"` | ||
ResourceGroup string `json:"resourceGroup"` | ||
PublicIPAllocationMethod string `json:"publicIPAllocationMethod"` | ||
IdleTimeoutInMinutes int `json:"idleTimeoutInMinutes"` | ||
PublicIPAddressVersion string `json:"publicIPAddressVersion"` | ||
SkuName string `json:"skuName"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
|
||
// AzurePublicIPAddress is the Schema for the azurepublicipaddresses API | ||
type AzurePublicIPAddress struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec AzurePublicIPAddressSpec `json:"spec,omitempty"` | ||
Status ASOStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// AzurePublicIPAddressList contains a list of AzurePublicIPAddress | ||
type AzurePublicIPAddressList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []AzurePublicIPAddress `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&AzurePublicIPAddress{}, &AzurePublicIPAddressList{}) | ||
} |
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 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"golang.org/x/net/context" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/types" | ||
) | ||
|
||
// These tests are written in BDD-style using Ginkgo framework. Refer to | ||
// http://onsi.github.io/ginkgo to learn more. | ||
|
||
var _ = Describe("AzurePublicIPAddress", func() { | ||
var ( | ||
key types.NamespacedName | ||
created, fetched *AzurePublicIPAddress | ||
) | ||
|
||
BeforeEach(func() { | ||
// Add any setup steps that needs to be executed before each test | ||
}) | ||
|
||
AfterEach(func() { | ||
// Add any teardown steps that needs to be executed after each test | ||
}) | ||
|
||
// Add Tests for OpenAPI validation (or additonal CRD features) specified in | ||
// your API definition. | ||
// Avoid adding tests for vanilla CRUD operations because they would | ||
// test Kubernetes API server, which isn't the goal here. | ||
Context("Create API", func() { | ||
|
||
It("should create an object successfully", func() { | ||
|
||
key = types.NamespacedName{ | ||
Name: "foo", | ||
Namespace: "default", | ||
} | ||
created = &AzurePublicIPAddress{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "foo", | ||
Namespace: "default", | ||
}, | ||
Spec: AzurePublicIPAddressSpec{ | ||
Location: "westus", | ||
ResourceGroup: "foo-pip", | ||
PublicIPAllocationMethod: "Static", | ||
IdleTimeoutInMinutes: 3, | ||
PublicIPAddressVersion: "IPv4", | ||
SkuName: "Basic", | ||
}} | ||
|
||
By("creating an API obj") | ||
Expect(k8sClient.Create(context.TODO(), created)).To(Succeed()) | ||
|
||
fetched = &AzurePublicIPAddress{} | ||
Expect(k8sClient.Get(context.TODO(), key, fetched)).To(Succeed()) | ||
Expect(fetched).To(Equal(created)) | ||
|
||
By("deleting the created object") | ||
Expect(k8sClient.Delete(context.TODO(), created)).To(Succeed()) | ||
Expect(k8sClient.Get(context.TODO(), key, created)).ToNot(Succeed()) | ||
}) | ||
|
||
}) | ||
|
||
}) |
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
8 changes: 8 additions & 0 deletions
8
config/crd/patches/cainjection_in_azurenetworkinterfaces.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,8 @@ | ||
# The following patch adds a directive for certmanager to inject CA into the CRD | ||
# CRD conversion requires k8s 1.13 or later. | ||
apiVersion: apiextensions.k8s.io/v1beta1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
certmanager.k8s.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) | ||
name: azurenetworkinterfaces.azure.microsoft.com |
8 changes: 8 additions & 0 deletions
8
config/crd/patches/cainjection_in_azurepublicipaddresses.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,8 @@ | ||
# The following patch adds a directive for certmanager to inject CA into the CRD | ||
# CRD conversion requires k8s 1.13 or later. | ||
apiVersion: apiextensions.k8s.io/v1beta1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
certmanager.k8s.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) | ||
name: azurepublicipaddresses.azure.microsoft.com |
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,17 @@ | ||
# The following patch enables conversion webhook for CRD | ||
# CRD conversion requires k8s 1.13 or later. | ||
apiVersion: apiextensions.k8s.io/v1beta1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: azurenetworkinterfaces.azure.microsoft.com | ||
spec: | ||
conversion: | ||
strategy: Webhook | ||
webhookClientConfig: | ||
# this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, | ||
# but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) | ||
caBundle: Cg== | ||
service: | ||
namespace: system | ||
name: webhook-service | ||
path: /convert |
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,17 @@ | ||
# The following patch enables conversion webhook for CRD | ||
# CRD conversion requires k8s 1.13 or later. | ||
apiVersion: apiextensions.k8s.io/v1beta1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: azurepublicipaddresses.azure.microsoft.com | ||
spec: | ||
conversion: | ||
strategy: Webhook | ||
webhookClientConfig: | ||
# this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, | ||
# but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) | ||
caBundle: Cg== | ||
service: | ||
namespace: system | ||
name: webhook-service | ||
path: /convert |
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,10 @@ | ||
apiVersion: azure.microsoft.com/v1alpha1 | ||
kind: AzureNetworkInterface | ||
metadata: | ||
name: azurenetworkinterface-sample18 | ||
spec: | ||
location: westus | ||
resourceGroup: resourcegroup-azure-operators | ||
vnetName: vnet-sample-hpf-1 | ||
subnetName: test2 | ||
publicIPAddressName: azurepublicipaddress-sample-7 |
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,11 @@ | ||
apiVersion: azure.microsoft.com/v1alpha1 | ||
kind: AzurePublicIPAddress | ||
metadata: | ||
name: azurepublicipaddress-sample11 | ||
spec: | ||
location: westus | ||
resourceGroup: resourcegroup-azure-operators | ||
publicIPAllocationMethod: "Static" | ||
idleTimeoutInMinutes: 10 | ||
publicIPAddressVersion: "IPv4" | ||
skuName: "Basic" |
Oops, something went wrong.