Skip to content

Commit

Permalink
Merge branch 'master' into bug-cosmos-secretname
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamMortlMicrosoft authored Apr 30, 2020
2 parents 7effdd2 + c9669c9 commit 0d21676
Show file tree
Hide file tree
Showing 45 changed files with 2,013 additions and 60 deletions.
6 changes: 6 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,9 @@ resources:
- group: azure
version: v1alpha1
kind: AzureVirtualMachine
- group: azure
version: v1alpha1
kind: AzureLoadBalancer
- group: azure
version: v1alpha1
kind: AzureVMScaleSet
52 changes: 52 additions & 0 deletions api/v1alpha1/azureloadbalancer_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// 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.

// AzureLoadBalancerSpec defines the desired state of AzureLoadBalancer
type AzureLoadBalancerSpec 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"`
PublicIPAddressName string `json:"publicIPAddressName"`
BackendAddressPoolName string `json:"backendAddressPoolName"`
InboundNatPoolName string `json:"inboundNatPoolName"`
FrontendPortRangeStart int `json:"frontendPortRangeStart"`
FrontendPortRangeEnd int `json:"frontendPortRangeEnd"`
BackendPort int `json:"backendPort"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status

// AzureLoadBalancer is the Schema for the azureloadbalancers API
// +kubebuilder:printcolumn:name="Provisioned",type="string",JSONPath=".status.provisioned"
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.message"
type AzureLoadBalancer struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec AzureLoadBalancerSpec `json:"spec,omitempty"`
Status ASOStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&AzureLoadBalancer{}, &AzureLoadBalancerList{})
}
74 changes: 74 additions & 0 deletions api/v1alpha1/azureloadbalancer_types_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// 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("AzureLoadBalancer", func() {
var (
key types.NamespacedName
created, fetched *AzureLoadBalancer
)

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 = &AzureLoadBalancer{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Namespace: "default",
},
Spec: AzureLoadBalancerSpec{
Location: "westus",
ResourceGroup: "testlb",
PublicIPAddressName: "test",
BackendAddressPoolName: "test",
InboundNatPoolName: "test",
FrontendPortRangeStart: 1000,
FrontendPortRangeEnd: 2000,
BackendPort: 3000,
}}

By("creating an API obj")
Expect(k8sClient.Create(context.TODO(), created)).To(Succeed())

fetched = &AzureLoadBalancer{}
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())
})

})

})
57 changes: 57 additions & 0 deletions api/v1alpha1/azurevmscaleset_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// 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.

// AzureVMScaleSetSpec defines the desired state of AzureVMScaleSet
type AzureVMScaleSetSpec 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"`
VMSize string `json:"vmSize"`
Capacity int `json:"capacity"`
OSType OSType `json:"osType"`
AdminUserName string `json:"adminUserName"`
SSHPublicKeyData string `json:"sshPublicKeyData,omitempty"`
PlatformImageURN string `json:"platformImageURN"`
VirtualNetworkName string `json:"virtualNetworkName"`
SubnetName string `json:"subnetName"`
LoadBalancerName string `json:"loadBalancerName"`
BackendAddressPoolName string `json:"backendAddressPoolName"`
InboundNatPoolName string `json:"inboundNatPoolName"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status

// AzureVMScaleSet is the Schema for the azurevmscalesets API
// +kubebuilder:printcolumn:name="Provisioned",type="string",JSONPath=".status.provisioned"
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.message"
type AzureVMScaleSet struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec AzureVMScaleSetSpec `json:"spec,omitempty"`
Status ASOStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&AzureVMScaleSet{}, &AzureVMScaleSetList{})
}
79 changes: 79 additions & 0 deletions api/v1alpha1/azurevmscaleset_types_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// 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("AzureVMScaleSet", func() {
var (
key types.NamespacedName
created, fetched *AzureVMScaleSet
)

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 = &AzureVMScaleSet{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Namespace: "default",
},
Spec: AzureVMScaleSetSpec{
Location: "westus",
ResourceGroup: "foo-vm",
VMSize: "test",
Capacity: 2,
OSType: OSType("Linux"),
AdminUserName: "test",
SSHPublicKeyData: "test",
PlatformImageURN: "w:x:y:z",
VirtualNetworkName: "test",
SubnetName: "test",
LoadBalancerName: "test",
BackendAddressPoolName: "test",
InboundNatPoolName: "test",
}}

By("creating an API obj")
Expect(k8sClient.Create(context.TODO(), created)).To(Succeed())

fetched = &AzureVMScaleSet{}
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())
})

})

})
2 changes: 2 additions & 0 deletions api/v1alpha1/postgresqlserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type PostgreSQLServerSpec struct {
ServerVersion ServerVersion `json:"serverVersion,omitempty"`
SSLEnforcement SslEnforcementEnum `json:"sslEnforcement,omitempty"`
KeyVaultToStoreSecrets string `json:"keyVaultToStoreSecrets,omitempty"`
CreateMode string `json:"createMode,omitempty"`
ReplicaProperties ReplicaProperties `json:"replicaProperties,omitempty"`
}

type AzureDBsSQLSku struct {
Expand Down
6 changes: 6 additions & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ resources:
- bases/azure.microsoft.com_azurenetworkinterfaces.yaml
- bases/azure.microsoft.com_mysqlvnetrules.yaml
- bases/azure.microsoft.com_azurevirtualmachines.yaml
- bases/azure.microsoft.com_azureloadbalancers.yaml
- bases/azure.microsoft.com_azurevmscalesets.yaml
# +kubebuilder:scaffold:crdkustomizeresource

#patches:
Expand Down Expand Up @@ -69,6 +71,8 @@ resources:
#- patches/webhook_in_azurenetworkinterfaces.yaml
#- patches/webhook_in_mysqlvnetrules.yaml
#- patches/webhook_in_azurevirtualmachines.yaml
#- patches/webhook_in_azureloadbalancers.yaml
#- patches/webhook_in_azurevmscalesets.yaml
# +kubebuilder:scaffold:crdkustomizewebhookpatch

# [CAINJECTION] patches here are for enabling the CA injection for each CRD
Expand Down Expand Up @@ -102,6 +106,8 @@ resources:
#- patches/cainjection_in_azurenetworkinterfaces.yaml
#- patches/cainjection_in_mysqlvnetrules.yaml
#- patches/cainjection_in_azurevirtualmachines.yaml
#- patches/cainjection_in_azureloadbalancers.yaml
#- patches/cainjection_in_azurevmscalesets.yaml
# +kubebuilder:scaffold:crdkustomizecainjectionpatch

# the following config is for teaching kustomize how to do kustomization for CRDs.
Expand Down
8 changes: 8 additions & 0 deletions config/crd/patches/cainjection_in_azureloadbalancers.yaml
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: azureloadbalancers.azure.microsoft.com
8 changes: 8 additions & 0 deletions config/crd/patches/cainjection_in_azurevmscalesets.yaml
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: azurevmscalesets.azure.microsoft.com
17 changes: 17 additions & 0 deletions config/crd/patches/webhook_in_azureloadbalancers.yaml
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: azureloadbalancers.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
17 changes: 17 additions & 0 deletions config/crd/patches/webhook_in_azurevmscalesets.yaml
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: azurevmscalesets.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
13 changes: 13 additions & 0 deletions config/samples/azure_v1alpha1_azureloadbalancer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: azure.microsoft.com/v1alpha1
kind: AzureLoadBalancer
metadata:
name: lb-sample-01
spec:
location: SouthCentralUS
resourceGroup: resourcegroup-azure-operators
publicIPAddressName: lb-pip-sample-01
backendAddressPoolName: test
inboundNatPoolName: test
frontendPortRangeStart: 1001
frontendPortRangeEnd: 2000
backendPort: 3000
10 changes: 5 additions & 5 deletions config/samples/azure_v1alpha1_azurenetworkinterface.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apiVersion: azure.microsoft.com/v1alpha1
kind: AzureNetworkInterface
metadata:
name: azurenetworkinterface-sample18
name: nic-sample-01
spec:
location: westus
location: SouthCentralUS
resourceGroup: resourcegroup-azure-operators
vnetName: vnet-sample-hpf-1
subnetName: test2
publicIPAddressName: azurepublicipaddress-sample-7
vnetName: vnet-sample-01
subnetName: test1
publicIPAddressName: nic-pip-sample-01
Loading

0 comments on commit 0d21676

Please sign in to comment.