-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* kubebuilder init --domain azure --license none * kubebuilder create api --group service --version v1alpha1 --kind Storage * kubebuilder create api --group service --version v1alpha1 --kind CosmosDB * Add MIT License * Initial codes to support Azure Storage Account * Add development docs * Remove the storage account name from the spec * Sync additional resources for Azure storage account 1. Create a secret based on storage account credentials 2. Add the global config * Upgrade kubebuilder to 2.0.0-beta.0 and controller-runtime to v0.2.0-beta.4 * Copy pkg in Dockerfile * Update controller-gen and make manifests * Add prefix "Storage" for storage_types * feature: add redis cache service * Ignore the NotFound error when deleting resources * Requeue the request if the deployment is not complete * feature: add cosmosdb service * Refine the logic of updating additional resources and output * Deploy operator on a remote cluster * add a sample app deployment yaml * Generate assets for the templates * Requeue after 30 seconds to avoid too many requests Ignore the NotFound error when deleting cosmosdb * Fix a bug of missing capacity of rediscache template * fix: judge whether resources need to be updated With adding generation in status, we can judge whether resources need to be updated. Co-authored-by: Bin Xia <binxi@microsoft.com> * Add docs to run the demo * Update manager-role to operate secrets Workaround: the rule should be appended. But I don't know how for now. The workaround is to copy config/rbac/role.yaml and add the new rule. Should be fixed in future. * fix(Makefile): rename the target from "generate" to "generate-template" to avoid conflict * Refactoring data focused operators. Storage currently working though it needs cleanup * Added deepcopy generated code * CosmosDB deploy working * Detailing current implementation of CosmosDB Create parameters * Removing TestTags * Redis cache now deploys * Cleaned up code and removed references to v1alpha1 * Updating controllers logging calls Co-authored-by: Chris Risner <github@chrisrisner.com> Co-authored-by: Bin Xia <binxi@microsoft.com>
- Loading branch information
Showing
49 changed files
with
4,681 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export GO111MODULE=on |
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
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,136 @@ | ||
/* | ||
MIT License | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE | ||
*/ | ||
|
||
package v1 | ||
|
||
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. | ||
|
||
// CosmosDBSpec defines the desired state of CosmosDB | ||
type CosmosDBSpec struct { | ||
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster | ||
// Important: Run "make" to regenerate code after modifying this file | ||
|
||
// +kubebuilder:validation:MinLength=0 | ||
|
||
Location string `json:"location,omitempty"` | ||
ResourceGroupName string `json:"resourceGroup"` | ||
Kind CosmosDBKind `json:"kind,omitempty"` | ||
Properties CosmosDBProperties `json:"properties,omitempty"` | ||
} | ||
|
||
// CosmosDBKind enumerates the values for kind. | ||
// Only one of the following kinds may be specified. | ||
// If none of the following kinds is specified, the default one | ||
// is GlobalDocumentDBKind. | ||
// +kubebuilder:validation:Enum=GlobalDocumentDB;MongoDB | ||
type CosmosDBKind string | ||
|
||
const ( | ||
CosmosDBKindGlobalDocumentDB CosmosDBKind = "GlobalDocumentDB" | ||
CosmosDBKindMongoDB CosmosDBKind = "MongoDB" | ||
) | ||
|
||
// CosmosDBProperties the CosmosDBProperties of CosmosDB. | ||
type CosmosDBProperties struct { | ||
// CosmosDBDatabaseAccountOfferType - The offer type for the Cosmos DB database account. | ||
DatabaseAccountOfferType CosmosDBDatabaseAccountOfferType `json:"databaseAccountOfferType,omitempty"` | ||
//Locations []CosmosDBLocation `json:"locations,omitempty"` | ||
} | ||
|
||
// +kubebuilder:validation:Enum=Standard | ||
type CosmosDBDatabaseAccountOfferType string | ||
|
||
const ( | ||
CosmosDBDatabaseAccountOfferTypeStandard CosmosDBDatabaseAccountOfferType = "Standard" | ||
) | ||
|
||
/* | ||
type CosmosDBLocation struct { | ||
FailoverPriority int `json:"failoverPriority,omitempty"` | ||
LocationName string `json:"locationName,omitempty"` | ||
IsZoneRedundant bool `json:"isZoneRedundant,omitempty"` | ||
} | ||
*/ | ||
|
||
// CosmosDBStatus defines the observed state of CosmosDB | ||
type CosmosDBStatus struct { | ||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster | ||
// Important: Run "make" to regenerate code after modifying this file | ||
|
||
// DeploymentName string `json:"deploymentName,omitempty"` | ||
// ProvisioningState string `json:"provisioningState,omitempty"` | ||
// Generation int64 `json:"generation,omitempty"` | ||
Provisioning bool `json:"provisioning,omitempty"` | ||
Provisioned bool `json:"provisioned,omitempty"` | ||
} | ||
|
||
type CosmosDBOutput struct { | ||
CosmosDBName string `json:"cosmosDBName,omitempty"` | ||
PrimaryMasterKey string `json:"primaryMasterKey,omitempty"` | ||
//SecondaryMasterKey string `json:"secondaryMasterKey,omitempty"` | ||
//PrimaryReadonlyMasterKey string `json:"primaryReadonlyMasterKey,omitempty"` | ||
//SecondaryReadonlyMasterKey string `json:"secondaryReadonlyMasterKey,omitempty"` | ||
} | ||
|
||
// CosmosDBAdditionalResources holds the additional resources | ||
type CosmosDBAdditionalResources struct { | ||
Secrets []string `json:"secrets,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
|
||
// CosmosDB is the Schema for the cosmosdbs API | ||
type CosmosDB struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec CosmosDBSpec `json:"spec,omitempty"` | ||
Status CosmosDBStatus `json:"status,omitempty"` | ||
Output CosmosDBOutput `json:"output,omitempty"` | ||
AdditionalResources CosmosDBAdditionalResources `json:"additionalResources,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
|
||
// CosmosDBList contains a list of CosmosDB | ||
type CosmosDBList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []CosmosDB `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&CosmosDB{}, &CosmosDBList{}) | ||
} | ||
|
||
func (cosmosDB *CosmosDB) IsSubmitted() bool { | ||
return cosmosDB.Status.Provisioning || cosmosDB.Status.Provisioned | ||
} |
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,131 @@ | ||
/* | ||
MIT License | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE | ||
*/ | ||
|
||
package v1 | ||
|
||
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. | ||
|
||
// RedisCacheSpec defines the desired state of RedisCache | ||
type RedisCacheSpec struct { | ||
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster | ||
// Important: Run "make" to regenerate code after modifying this file | ||
|
||
// +kubebuilder:validation:MinLength=0 | ||
|
||
Location string `json:"location,omitempty"` | ||
ResourceGroupName string `json:"resourceGroup"` | ||
Properties RedisCacheProperties `json:"properties,omitempty"` | ||
} | ||
|
||
// RedisCacheProperties the properties of the Redis Cache. | ||
type RedisCacheProperties struct { | ||
Sku RedisCacheSku `json:"sku,omitempty"` | ||
|
||
EnableNonSslPort bool `json:"enableNonSslPort,omitempty"` | ||
} | ||
|
||
// RedisCacheSku the SKU of the Redis Cache. | ||
type RedisCacheSku struct { | ||
// Name - The SKU name. Required for account creation; optional for update. | ||
// Possible values include: 'StandardLRS', 'StandardGRS', 'StandardRAGRS', 'StandardZRS', 'PremiumLRS', 'PremiumZRS', 'StandardGZRS', 'StandardRAGZRS' | ||
Name RedisCacheSkuName `json:"name,omitempty"` | ||
|
||
Family RedisCacheSkuFamily `json:"family,omitempty"` | ||
|
||
Capacity int32 `json:"capacity,omitempty"` | ||
} | ||
|
||
type RedisCacheSkuName string | ||
|
||
const ( | ||
Basic RedisCacheSkuName = "Basic" | ||
Premium RedisCacheSkuName = "Premium" | ||
Standard RedisCacheSkuName = "Standard" | ||
) | ||
|
||
type RedisCacheSkuFamily string | ||
|
||
const ( | ||
C RedisCacheSkuFamily = "C" | ||
P RedisCacheSkuFamily = "P" | ||
) | ||
|
||
// RedisCacheStatus defines the observed state of RedisCache | ||
type RedisCacheStatus struct { | ||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster | ||
// Important: Run "make" to regenerate code after modifying this file | ||
|
||
// DeploymentName string `json:"deploymentName,omitempty"` | ||
// ProvisioningState string `json:"provisioningState,omitempty"` | ||
// Generation int64 `json:"generation,omitempty"` | ||
Provisioning bool `json:"provisioning,omitempty"` | ||
Provisioned bool `json:"provisioned,omitempty"` | ||
} | ||
|
||
type RedisCacheOutput struct { | ||
RedisCacheName string `json:"redisCacheName,omitempty"` | ||
PrimaryKey string `json:"primaryKey,omitempty"` | ||
SecondaryKey string `json:"secondaryKey,omitempty"` | ||
} | ||
|
||
// StorageAdditionalResources holds the additional resources | ||
type RedisCacheAdditionalResources struct { | ||
Secrets []string `json:"secrets,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
|
||
// RedisCache is the Schema for the rediscaches API | ||
type RedisCache struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec RedisCacheSpec `json:"spec,omitempty"` | ||
Status RedisCacheStatus `json:"status,omitempty"` | ||
Output RedisCacheOutput `json:"output,omitempty"` | ||
AdditionalResources RedisCacheAdditionalResources `json:"additionalResources,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// RedisCacheList contains a list of RedisCache | ||
type RedisCacheList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []RedisCache `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&RedisCache{}, &RedisCacheList{}) | ||
} | ||
|
||
func (redisCache *RedisCache) IsSubmitted() bool { | ||
return redisCache.Status.Provisioning || redisCache.Status.Provisioned | ||
} |
Oops, something went wrong.