Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Azure/azure-service-operator
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarrod Skulavik committed Apr 21, 2020
2 parents 53b2093 + f664ca3 commit 7059679
Show file tree
Hide file tree
Showing 94 changed files with 2,712 additions and 714 deletions.
6 changes: 4 additions & 2 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repo: github.com/Azure/azure-service-operator
resources:
- group: azure
version: v1alpha1
kind: Storage
kind: StorageAccount
- group: azure
version: v1alpha1
kind: CosmosDB
Expand Down Expand Up @@ -86,4 +86,6 @@ resources:
- group: azure
version: v1alpha1
kind: MySQLFirewallRule

- group: azure
version: v1alpha1
kind: AzureVirtualMachine
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ This project maintains [releases of the Azure Service Operator](https://github.c
1. [Resource Group](/docs/resourcegroup/resourcegroup.md)
2. [EventHub](/docs/eventhub/eventhub.md)
3. [Azure SQL](/docs/azuresql/azuresql.md)
4. [Azure Keyvault](/docs/keyvault/keyvault.md)
5. [Azure Rediscache](/docs/rediscache/rediscache.md)
6. [Storage Account](/docs/storage/storageaccount.md)
7. [Blob container](/docs/storage/blobcontainer.md)
8. [Azure Database for PostgreSQL](/docs/postgresql/postgresql.md)
9. [Virtual Network](/docs/virtualnetwork/virtualnetwork.md)
10.[Application Insights](/docs/appinsights/appinsights.md)
11.[API Management](/docs/apimgmt/apimgmt.md)
12.[Cosmos DB](/docs/cosmosdb/cosmosdb.md)
4. [Azure Database for PostgreSQL](/docs/postgresql/postgresql.md)
5. [Azure Database for MySQL](/docs/mysql/mysql.md)
6. [Azure Keyvault](/docs/keyvault/keyvault.md)
7. [Azure Rediscache](/docs/rediscache/rediscache.md)
8. [Storage Account](/docs/storage/storageaccount.md)
9. [Blob container](/docs/storage/blobcontainer.md)
10. [Virtual Network](/docs/virtualnetwork/virtualnetwork.md)
11. [Application Insights](/docs/appinsights/appinsights.md)
12. [API Management](/docs/apimgmt/apimgmt.md)
13. [Cosmos DB](/docs/cosmosdb/cosmosdb.md)

For more information on deploying, troubleshooting & deleting resources, refer to [this](/docs/customresource.md) link

Expand Down
59 changes: 59 additions & 0 deletions api/v1alpha1/azurevirtualmachine_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// 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.

// AzureVirtualMachineSpec defines the desired state of AzureVirtualMachine
type AzureVirtualMachineSpec 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"`
OSType OSType `json:"osType"`
AdminUserName string `json:"adminUserName"`
SSHPublicKeyData string `json:"sshPublicKeyData,omitempty"`
NetworkInterfaceName string `json:"networkInterfaceName"`
PlatformImageURN string `json:"platformImageURN"`
}

type OSType string

const (
// Windows ...
Windows OSType = "Windows"
// Linux ...
Linux OSType = "Linux"
)

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

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

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

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&AzureVirtualMachine{}, &AzureVirtualMachineList{})
}
74 changes: 74 additions & 0 deletions api/v1alpha1/azurevirtualmachine_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("AzureVirtualMachine", func() {
var (
key types.NamespacedName
created, fetched *AzureVirtualMachine
)

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 = &AzureVirtualMachine{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Namespace: "default",
},
Spec: AzureVirtualMachineSpec{
Location: "westus",
ResourceGroup: "foo-vm",
VMSize: "test",
OSType: OSType("Linux"),
AdminUserName: "test",
SSHPublicKeyData: "test",
NetworkInterfaceName: "test",
PlatformImageURN: "w:x:y:z",
}}

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

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

})

})
25 changes: 19 additions & 6 deletions api/v1alpha1/cosmosdb_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ type CosmosDBSpec struct {

// +kubebuilder:validation:MinLength=0

Location string `json:"location,omitempty"`
ResourceGroup string `json:"resourceGroup"`
Kind CosmosDBKind `json:"kind,omitempty"`
Properties CosmosDBProperties `json:"properties,omitempty"`
Location string `json:"location,omitempty"`
ResourceGroup string `json:"resourceGroup"`
Kind CosmosDBKind `json:"kind,omitempty"`
Properties CosmosDBProperties `json:"properties,omitempty"`
VirtualNetworkRules *[]CosmosDBVirtualNetworkRule `json:"virtualNetworkRules,omitempty"`
KeyVaultToStoreSecrets string `json:"keyVaultToStoreSecrets,omitempty"`
}

// CosmosDBKind enumerates the values for kind.
Expand All @@ -39,9 +41,12 @@ const (

// CosmosDBProperties the CosmosDBProperties of CosmosDB.
type CosmosDBProperties struct {
// CosmosDBDatabaseAccountOfferType - The offer type for the Cosmos DB database account.
// DatabaseAccountOfferType - The offer type for the Cosmos DB database account.
DatabaseAccountOfferType CosmosDBDatabaseAccountOfferType `json:"databaseAccountOfferType,omitempty"`
//Locations []CosmosDBLocation `json:"locations,omitempty"`
// IsVirtualNetworkFilterEnabled - Flag to indicate whether to enable/disable Virtual Network ACL rules.
IsVirtualNetworkFilterEnabled bool `json:"isVirtualNetworkFilterEnabled,omitempty"`
EnableMultipleWriteLocations bool `json:"enableMultipleWriteLocations,omitempty"`
MongoDBVersion string `json:"mongoDBVersion,omitempty"`
}

// +kubebuilder:validation:Enum=Standard
Expand Down Expand Up @@ -82,6 +87,14 @@ type CosmosDBList struct {
Items []CosmosDB `json:"items"`
}

//CosmosDBVirtualNetworkRule virtual Network ACL Rule object
type CosmosDBVirtualNetworkRule struct {
// ID - Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}.
SubnetID *string `json:"subnetID,omitempty"`
// IgnoreMissingVNetServiceEndpoint - Create firewall rule before the virtual network has vnet service endpoint enabled.
IgnoreMissingVNetServiceEndpoint *bool `json:"ignoreMissingVNetServiceEndpoint,omitempty"`
}

func init() {
SchemeBuilder.Register(&CosmosDB{}, &CosmosDBList{})
}
Expand Down
5 changes: 3 additions & 2 deletions api/v1alpha1/eventhub_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ type EventhubAuthorizationRule struct {
Rights []string `json:"rights,omitempty"`
}

type StorageAccount struct {
//EventHubStorageAccount contains details of the eventhub storage account
type EventHubStorageAccount struct {
// ResourceGroup - Name of the storage account resource group
// +kubebuilder:validation:Pattern=^[-\w\._\(\)]+$
ResourceGroup string `json:"resourceGroup,omitempty"`
Expand All @@ -54,7 +55,7 @@ type Destination struct {
// +kubebuilder:validation:Enum=EventHubArchive.AzureBlockBlob;EventHubArchive.AzureDataLake
Name string `json:"name,omitempty"`
// StorageAccount - Details of the storage account
StorageAccount StorageAccount `json:"storageAccount,omitempty"`
StorageAccount EventHubStorageAccount `json:"storageAccount,omitempty"`
}

//CaptureDescription defines the properties required for eventhub capture
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/eventhub_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ var _ = Describe("Eventhub", func() {
ArchiveNameFormat: "{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}",
BlobContainer: "foo-blob-container",
Name: "EventHubArchive.AzureBlockBlob",
StorageAccount: StorageAccount{
StorageAccount: EventHubStorageAccount{
ResourceGroup: "foo-resource-group",
AccountName: "fooaccountname",
},
Expand Down
30 changes: 27 additions & 3 deletions api/v1alpha1/mysqlserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ type MySQLServerSpec struct {
Sku AzureDBsSQLSku `json:"sku,omitempty"`
ServerVersion ServerVersion `json:"serverVersion,omitempty"`
SSLEnforcement SslEnforcementEnum `json:"sslEnforcement,omitempty"`
CreateMode string `json:"createMode,omitempty"`
ReplicaProperties ReplicaProperties `json:"replicaProperties,omitempty"`
KeyVaultToStoreSecrets string `json:"keyVaultToStoreSecrets,omitempty"`
}

Expand All @@ -41,6 +43,10 @@ type MySQLServerList struct {
Items []MySQLServer `json:"items"`
}

type ReplicaProperties struct {
SourceServerId string `json:"sourceServerId,omitempty"`
}

func init() {
SchemeBuilder.Register(&MySQLServer{}, &MySQLServerList{})
}
Expand All @@ -55,14 +61,32 @@ func NewDefaultMySQLServer(name, resourceGroup, location string) *MySQLServer {
Location: location,
ResourceGroup: resourceGroup,
Sku: AzureDBsSQLSku{
Name: "B_Gen5_2",
Tier: SkuTier("Basic"),
Name: "GP_Gen5_4",
Tier: SkuTier("GeneralPurpose"),
Family: "Gen5",
Size: "51200",
Capacity: 2,
Capacity: 4,
},
ServerVersion: ServerVersion("8.0"),
SSLEnforcement: SslEnforcementEnumEnabled,
CreateMode: "Default",
},
}
}

func NewReplicaMySQLServer(name, resourceGroup, location string, sourceserverid string) *MySQLServer {
return &MySQLServer{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: "default",
},
Spec: MySQLServerSpec{
Location: location,
ResourceGroup: resourceGroup,
CreateMode: "Replica",
ReplicaProperties: ReplicaProperties{
SourceServerId: sourceserverid,
},
},
}
}
Loading

0 comments on commit 7059679

Please sign in to comment.