-
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
12 changed files
with
306 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
package v1alpha1 | ||
|
||
func (*MySQLServer) Hub() {} |
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,20 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
logf "sigs.k8s.io/controller-runtime/pkg/log" | ||
) | ||
|
||
// log is for logging in this package. | ||
var mysqlserverlog = logf.Log.WithName("mysqlserver-resource") | ||
|
||
func (r *MySQLServer) SetupWebhookWithManager(mgr ctrl.Manager) error { | ||
return ctrl.NewWebhookManagedBy(mgr). | ||
For(r). | ||
Complete() | ||
} | ||
|
||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! |
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,57 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
package v1alpha2 | ||
|
||
import ( | ||
"github.com/Azure/azure-service-operator/api/v1alpha1" | ||
"sigs.k8s.io/controller-runtime/pkg/conversion" | ||
) | ||
|
||
func (src *MySQLServer) ConvertTo(dstRaw conversion.Hub) error { | ||
dst := dstRaw.(*v1alpha1.MySQLServer) | ||
|
||
// ObjectMeta | ||
dst.ObjectMeta = src.ObjectMeta | ||
|
||
// Spec | ||
dst.Spec.ResourceGroup = src.Spec.ResourceGroup | ||
dst.Spec.Location = src.Spec.Location | ||
dst.Spec.Sku = src.Spec.Sku | ||
dst.Spec.ServerVersion = src.Spec.ServerVersion | ||
dst.Spec.SSLEnforcement = src.Spec.SSLEnforcement | ||
dst.Spec.CreateMode = src.Spec.CreateMode | ||
dst.Spec.ReplicaProperties = src.Spec.ReplicaProperties | ||
dst.Spec.KeyVaultToStoreSecrets = src.Spec.KeyVaultToStoreSecrets | ||
|
||
// New Spec | ||
//dst.Spec.StorageProfile = nil | ||
|
||
// Status | ||
dst.Status = src.Status | ||
|
||
return nil | ||
} | ||
|
||
func (dst *MySQLServer) ConvertFrom(srcRaw conversion.Hub) error { | ||
src := srcRaw.(*v1alpha1.MySQLServer) | ||
|
||
// ObjectMeta | ||
dst.ObjectMeta = src.ObjectMeta | ||
|
||
// Spec | ||
dst.Spec.ResourceGroup = src.Spec.ResourceGroup | ||
dst.Spec.Location = src.Spec.Location | ||
dst.Spec.Sku = src.Spec.Sku | ||
dst.Spec.ServerVersion = src.Spec.ServerVersion | ||
dst.Spec.SSLEnforcement = src.Spec.SSLEnforcement | ||
dst.Spec.CreateMode = src.Spec.CreateMode | ||
dst.Spec.ReplicaProperties = src.Spec.ReplicaProperties | ||
dst.Spec.KeyVaultToStoreSecrets = src.Spec.KeyVaultToStoreSecrets | ||
|
||
// Status | ||
dst.Status = src.Status | ||
|
||
return nil | ||
|
||
} |
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,104 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
package v1alpha2 | ||
|
||
import ( | ||
"github.com/Azure/azure-sdk-for-go/services/mysql/mgmt/2017-12-01/mysql" | ||
"github.com/Azure/azure-service-operator/api/v1alpha1" | ||
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. | ||
|
||
type StorageProfile struct { | ||
// BackupRetentionDays - Backup retention days for the server. | ||
BackupRetentionDays *int32 `json:"backupRetentionDays,omitempty"` | ||
// GeoRedundantBackup - Enable Geo-redundant or not for server backup. Possible values include: 'Enabled', 'Disabled' | ||
GeoRedundantBackup mysql.GeoRedundantBackup `json:"geoRedundantBackup,omitempty"` | ||
// StorageMB - Max storage allowed for a server. | ||
StorageMB *int32 `json:"storageMB,omitempty"` | ||
// StorageAutogrow - Enable Storage Auto Grow. Possible values include: 'StorageAutogrowEnabled', 'StorageAutogrowDisabled' | ||
StorageAutogrow mysql.StorageAutogrow `json:"storageAutogrow,omitempty"` | ||
} | ||
|
||
// MySQLServerSpec defines the desired state of MySQLServer | ||
type MySQLServerSpec struct { | ||
Location string `json:"location"` | ||
ResourceGroup string `json:"resourceGroup,omitempty"` | ||
Sku v1alpha1.AzureDBsSQLSku `json:"sku,omitempty"` | ||
ServerVersion v1alpha1.ServerVersion `json:"serverVersion,omitempty"` | ||
SSLEnforcement v1alpha1.SslEnforcementEnum `json:"sslEnforcement,omitempty"` | ||
CreateMode string `json:"createMode,omitempty"` | ||
ReplicaProperties v1alpha1.ReplicaProperties `json:"replicaProperties,omitempty"` | ||
StorageProfile *StorageProfile `json:"storageProfile,omitempty"` | ||
KeyVaultToStoreSecrets string `json:"keyVaultToStoreSecrets,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
|
||
// MySQLServer is the Schema for the mysqlservers API | ||
// +kubebuilder:printcolumn:name="Provisioned",type="string",JSONPath=".status.provisioned" | ||
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.message" | ||
type MySQLServer struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec MySQLServerSpec `json:"spec,omitempty"` | ||
Status v1alpha1.ASOStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// MySQLServerList contains a list of MySQLServer | ||
type MySQLServerList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []MySQLServer `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&MySQLServer{}, &MySQLServerList{}) | ||
} | ||
|
||
func NewDefaultMySQLServer(name, resourceGroup, location string) *MySQLServer { | ||
return &MySQLServer{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: name, | ||
Namespace: "default", | ||
}, | ||
Spec: MySQLServerSpec{ | ||
Location: location, | ||
ResourceGroup: resourceGroup, | ||
Sku: v1alpha1.AzureDBsSQLSku{ | ||
Name: "GP_Gen5_4", | ||
Tier: v1alpha1.SkuTier("GeneralPurpose"), | ||
Family: "Gen5", | ||
Size: "51200", | ||
Capacity: 4, | ||
}, | ||
ServerVersion: v1alpha1.ServerVersion("8.0"), | ||
SSLEnforcement: v1alpha1.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: v1alpha1.ReplicaProperties{ | ||
SourceServerId: sourceserverid, | ||
}, | ||
}, | ||
} | ||
} |
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,56 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: controller-manager | ||
namespace: system | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
# Change the value of image field below to your controller image URL | ||
- image: controller:latest | ||
name: manager | ||
env: | ||
- name: AZURE_CLIENT_ID | ||
valueFrom: | ||
secretKeyRef: | ||
name: azureoperatorsettings | ||
key: AZURE_CLIENT_ID | ||
optional: true | ||
- name: AZURE_CLIENT_SECRET | ||
valueFrom: | ||
secretKeyRef: | ||
name: azureoperatorsettings | ||
key: AZURE_CLIENT_SECRET | ||
optional: true | ||
- name: AZURE_TENANT_ID | ||
valueFrom: | ||
secretKeyRef: | ||
name: azureoperatorsettings | ||
key: AZURE_TENANT_ID | ||
- name: AZURE_SUBSCRIPTION_ID | ||
valueFrom: | ||
secretKeyRef: | ||
name: azureoperatorsettings | ||
key: AZURE_SUBSCRIPTION_ID | ||
- name: AZURE_USE_MI | ||
valueFrom: | ||
secretKeyRef: | ||
name: azureoperatorsettings | ||
key: AZURE_USE_MI | ||
optional: true | ||
- name: AZURE_OPERATOR_KEYVAULT | ||
valueFrom: | ||
secretKeyRef: | ||
name: azureoperatorsettings | ||
key: AZURE_OPERATOR_KEYVAULT | ||
optional: true | ||
- name: AZURE_CLOUD_ENV | ||
valueFrom: | ||
secretKeyRef: | ||
key: AZURE_CLOUD_ENV | ||
name: azureoperatorsettings | ||
optional: true | ||
#requeue after time in seconds" | ||
- name: REQUEUE_AFTER | ||
value: "30" |
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,24 @@ | ||
# permissions for end users to edit mysqlservers. | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: mysqlserver-editor-role | ||
rules: | ||
- apiGroups: | ||
- azure.microsoft.com | ||
resources: | ||
- mysqlservers | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
- apiGroups: | ||
- azure.microsoft.com | ||
resources: | ||
- mysqlservers/status | ||
verbs: | ||
- get |
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,20 @@ | ||
# permissions for end users to view mysqlservers. | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: mysqlserver-viewer-role | ||
rules: | ||
- apiGroups: | ||
- azure.microsoft.com | ||
resources: | ||
- mysqlservers | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- azure.microsoft.com | ||
resources: | ||
- mysqlservers/status | ||
verbs: | ||
- get |
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