-
Notifications
You must be signed in to change notification settings - Fork 1
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
22 changed files
with
2,908 additions
and
0 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,131 @@ | ||
// Copyright © 2021 Alibaba Group Holding Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package v1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
type SSH struct { | ||
Encrypted bool `json:"encrypted,omitempty"` | ||
User string `json:"user,omitempty"` | ||
Passwd string `json:"passwd,omitempty"` | ||
Pk string `json:"pk,omitempty"` | ||
PkPasswd string `json:"pkPasswd,omitempty"` | ||
Port string `json:"port,omitempty"` | ||
} | ||
|
||
type Network struct { | ||
PodCIDR string `json:"podCIDR,omitempty"` | ||
SvcCIDR string `json:"svcCIDR,omitempty"` | ||
} | ||
|
||
type Hosts struct { | ||
CPU string `json:"cpu,omitempty"` | ||
Memory string `json:"memory,omitempty"` | ||
Count string `json:"count,omitempty"` | ||
SystemDisk string `json:"systemDisk,omitempty"` | ||
DataDisks []string `json:"dataDisks,omitempty"` | ||
IPList []string `json:"ipList,omitempty"` | ||
} | ||
|
||
// 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. | ||
|
||
// ClusterSpec defines the desired state of Cluster | ||
type ClusterSpec struct { | ||
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster | ||
// Important: Run "make" to regenerate code after modifying this file | ||
|
||
// Foo is an example field of Cluster. Edit Cluster_types.go to remove/update | ||
Image string `json:"image,omitempty"` | ||
Env []string `json:"env,omitempty"` | ||
Provider string `json:"provider,omitempty"` | ||
SSH SSH `json:"ssh,omitempty"` | ||
Network Network `json:"network,omitempty"` | ||
CertSANS []string `json:"certSANS,omitempty"` | ||
Masters Hosts `json:"masters,omitempty"` | ||
Nodes Hosts `json:"nodes,omitempty"` | ||
} | ||
|
||
// ClusterStatus defines the observed state of Cluster | ||
type ClusterStatus struct { | ||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster | ||
// Important: Run "make" to regenerate code after modifying this file | ||
// TODO save cluster status info | ||
|
||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// Cluster is the Schema for the clusters API | ||
type Cluster struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec ClusterSpec `json:"spec,omitempty"` | ||
Status ClusterStatus `json:"status,omitempty"` | ||
} | ||
|
||
//func (cluster *Cluster) GetClusterEIP() string { | ||
// return cluster.Annotations[common.Eip] | ||
//} | ||
// | ||
//func (cluster *Cluster) GetClusterMaster0IP() string { | ||
// return cluster.Annotations[common.Master0InternalIP] | ||
//} | ||
// | ||
//func (cluster *Cluster) GetEipID() string { | ||
// return cluster.Annotations[common.EipID] | ||
//} | ||
// | ||
//func (cluster *Cluster) GetMaster0ID() string { | ||
// return cluster.Annotations[common.Master0ID] | ||
//} | ||
// | ||
//func (cluster *Cluster) GetVpcID() string { | ||
// return cluster.Annotations[common.VpcID] | ||
//} | ||
// | ||
//func (cluster *Cluster) GetVSwitchID() string { | ||
// return cluster.Annotations[common.VSwitchID] | ||
//} | ||
|
||
func (in *Cluster) GetAnnotationsByKey(key string) string { | ||
return in.Annotations[key] | ||
} | ||
|
||
func (in *Cluster) SetAnnotations(key, value string) { | ||
if in.Annotations == nil { | ||
in.Annotations = make(map[string]string) | ||
} | ||
in.Annotations[key] = value | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// ClusterList contains a list of Cluster | ||
type ClusterList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []Cluster `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&Cluster{}, &ClusterList{}) | ||
} |
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,106 @@ | ||
/* | ||
Copyright 2021 Alibaba Group. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
/* | ||
Application config file: | ||
Clusterfile: | ||
apiVersion: sealer.aliyun.com/v1alpha1 | ||
kind: Cluster | ||
metadata: | ||
name: my-cluster | ||
spec: | ||
image: registry.cn-qingdao.aliyuncs.com/sealer-app/my-SAAS-all-inone:latest | ||
provider: BAREMETAL | ||
--- | ||
apiVersion: sealer.aliyun.com/v1alpha1 | ||
kind: Config | ||
metadata: | ||
name: mysql-config | ||
spec: | ||
path: etc/mysql-config.yaml | ||
data: | | ||
mysql-user: root | ||
mysql-passwd: xxx | ||
... | ||
--- | ||
apiVersion: sealer.aliyun.com/v1alpha1 | ||
kind: Config | ||
metadata: | ||
name: redis-config | ||
spec: | ||
path: etc/redis-config.yaml | ||
data: | | ||
redis-user: root | ||
redis-passwd: xxx | ||
... | ||
When apply this Clusterfile, sealer will generate some values file for application config. Named etc/mysql-config.yaml etc/redis-config.yaml. | ||
So if you want to use this config, Kubefile is like this: | ||
FROM kubernetes:v1.19.9 | ||
CMD helm install mysql -f etc/mysql-config.yaml | ||
CMD helm install mysql -f etc/redis-config.yaml | ||
*/ | ||
|
||
package v1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// ConfigSpec defines the desired state of Config | ||
type ConfigSpec struct { | ||
Strategy string `json:"strategy,omitempty"` | ||
Process string `json:"process,omitempty"` | ||
Data string `json:"data,omitempty"` | ||
Path string `json:"path,omitempty"` | ||
} | ||
|
||
// ConfigStatus defines the observed state of Config | ||
type ConfigStatus struct { | ||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster | ||
// Important: Run "make" to regenerate code after modifying this file | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// Config is the Schema for the configs API | ||
type Config struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec ConfigSpec `json:"spec,omitempty"` | ||
Status ConfigStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// ConfigList contains a list of Config | ||
type ConfigList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []Config `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&Config{}, &ConfigList{}) | ||
} |
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,19 @@ | ||
// Copyright © 2021 Alibaba Group Holding Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// +k8s:deepcopy-gen=package | ||
// +k8s:defaulter-gen=TypeMeta | ||
// +groupName=sealer.aliyun.com | ||
|
||
package v1 |
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,34 @@ | ||
// Copyright © 2021 Alibaba Group Holding Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// Package v1 contains API Schema definitions for the sealer v1 API group | ||
// +kubebuilder:object:generate=true | ||
// +groupName=sealer.aliyun.com | ||
package v1 | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"sigs.k8s.io/controller-runtime/pkg/scheme" | ||
) | ||
|
||
var ( | ||
// GroupVersion is group version used to register these objects | ||
GroupVersion = schema.GroupVersion{Group: "sealer.aliyun.com", Version: "v1"} | ||
|
||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme | ||
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} | ||
|
||
// AddToScheme adds the types in this group-version to the given scheme. | ||
AddToScheme = SchemeBuilder.AddToScheme | ||
) |
Oops, something went wrong.