Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr 22 merge #158

Merged
merged 38 commits into from
Aug 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9db6907
kubebuilder init --domain azure --license none
bingosummer Jul 19, 2019
045d9dd
kubebuilder create api --group service --version v1alpha1 --kind Storage
bingosummer Jul 19, 2019
4e3a723
kubebuilder create api --group service --version v1alpha1 --kind Cosm…
bingosummer Jul 19, 2019
57fb60b
Add MIT License
bingosummer Jul 19, 2019
f7f7016
Initial codes to support Azure Storage Account
bingosummer Jul 19, 2019
66dc93d
Add development docs
bingosummer Jul 19, 2019
110fa99
Remove the storage account name from the spec
bingosummer Jul 20, 2019
78e9d7b
Sync additional resources for Azure storage account
bingosummer Jul 20, 2019
b29b4c0
Upgrade kubebuilder to 2.0.0-beta.0 and controller-runtime to v0.2.0-…
bingosummer Jul 21, 2019
4e5abd4
Copy pkg in Dockerfile
bingosummer Jul 21, 2019
ca57fb6
Update controller-gen and make manifests
bingosummer Jul 22, 2019
56e410c
Add prefix "Storage" for storage_types
bingosummer Jul 22, 2019
96ef76a
feature: add redis cache service
ZeroMagic Jul 22, 2019
cd63089
Ignore the NotFound error when deleting resources
bingosummer Jul 23, 2019
15b9ec1
Requeue the request if the deployment is not complete
bingosummer Jul 22, 2019
6fc89ab
feature: add cosmosdb service
zhongyi-zhang Jul 23, 2019
c80fa00
Refine the logic of updating additional resources and output
bingosummer Jul 23, 2019
edd2cca
Deploy operator on a remote cluster
bingosummer Jul 23, 2019
425f873
add a sample app deployment yaml
zhongyi-zhang Jul 24, 2019
22097d9
Generate assets for the templates
bingosummer Jul 24, 2019
95fb61c
Requeue after 30 seconds to avoid too many requests
bingosummer Jul 24, 2019
205d045
Fix a bug of missing capacity of rediscache template
ZeroMagic Jul 24, 2019
9af1ae1
fix: judge whether resources need to be updated
ZeroMagic Jul 23, 2019
e4bfa74
Add docs to run the demo
bingosummer Jul 24, 2019
3753397
Update manager-role to operate secrets
bingosummer Jul 24, 2019
073ed3f
fix(Makefile): rename the target from "generate" to "generate-templat…
bingosummer Aug 6, 2019
1963592
merge-zilla
frodopwns Aug 18, 2019
cd22c7c
Manual merge after bringing WIP up to date with latest Master
ChrisRisner Aug 27, 2019
b48a318
Merged updates
ChrisRisner Aug 27, 2019
218234f
Refactoring data focused operators. Storage currently working though…
ChrisRisner Aug 28, 2019
a4c320a
Added deepcopy generated code
ChrisRisner Aug 28, 2019
438936f
CosmosDB deploy working
ChrisRisner Aug 28, 2019
540b66d
Detailing current implementation of CosmosDB Create parameters
ChrisRisner Aug 28, 2019
357f8fa
Removing TestTags
ChrisRisner Aug 28, 2019
604255b
Redis cache now deploys
ChrisRisner Aug 28, 2019
9c4d2e9
Cleaned up code and removed references to v1alpha1
ChrisRisner Aug 28, 2019
f6c3ea2
Merge branch 'master' into pr-22-merge
ChrisRisner Aug 28, 2019
11a20aa
Updating controllers logging calls
ChrisRisner Aug 29, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export GO111MODULE=on
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ default.etcd

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

bin/
vendor/
coverage.txt
report.xml
cover.html
Expand Down
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# Image URL to use all building/pushing image targets


# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif

IMG ?= controller:latest
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true"
Expand Down Expand Up @@ -70,6 +79,9 @@ docker-build:
docker-push:
docker push ${IMG}

# Build and Push the docker image
build-and-push: docker-build docker-push

# find or download controller-gen
# download controller-gen if necessary
controller-gen:
Expand All @@ -80,6 +92,14 @@ else
CONTROLLER_GEN=$(shell which controller-gen)
endif

.PHONY: install-bindata
install-bindata:
go get -u github.com/jteeuwen/go-bindata/...

.PHONE:
generate-template:
go-bindata -pkg template -prefix pkg/template/assets/ -o pkg/template/templates.go pkg/template/assets/

create-kindcluster:
ifeq (,$(shell kind get clusters))
@echo "no kind cluster"
Expand Down
9 changes: 9 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ version: "2"
domain: microsoft.com
repo: github.com/Azure/azure-service-operator
resources:
- group: service
version: v1
kind: Storage
- group: service
version: v1
kind: CosmosDB
- group: service
version: v1
kind: RedisCache
- group: azure
version: v1
kind: Eventhub
Expand Down
136 changes: 136 additions & 0 deletions api/v1/cosmosdb_types.go
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
}
131 changes: 131 additions & 0 deletions api/v1/rediscache_types.go
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
}
Loading