github.com/alibaba/sealer@v0.8.6-0.20220430115802-37a2bdaa8173/types/api/v1/config_types.go (about)

     1  /*
     2  Copyright 2021 Alibaba Group.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  /*
    18  Application config file:
    19  
    20  Clusterfile:
    21  
    22  apiVersion: sealer.aliyun.com/v1alpha1
    23  kind: Cluster
    24  metadata:
    25    name: my-cluster
    26  spec:
    27    image: registry.cn-qingdao.aliyuncs.com/sealer-app/my-SAAS-all-inone:latest
    28    provider: BAREMETAL
    29  ---
    30  apiVersion: sealer.aliyun.com/v1alpha1
    31  kind: Config
    32  metadata:
    33    name: mysql-config
    34  spec:
    35    path: etc/mysql-config.yaml
    36    data: |
    37         mysql-user: root
    38         mysql-passwd: xxx
    39  ...
    40  ---
    41  apiVersion: sealer.aliyun.com/v1alpha1
    42  kind: Config
    43  metadata:
    44    name: redis-config
    45  spec:
    46    path: etc/redis-config.yaml
    47    data: |
    48         redis-user: root
    49         redis-passwd: xxx
    50  ...
    51  
    52  When apply this Clusterfile, sealer will generate some values file for application config. Named etc/mysql-config.yaml etc/redis-config.yaml.
    53  
    54  So if you want to use those config, Kubefile is like this:
    55  
    56  FROM kuberentes:v1.19.9
    57  CMD helm install mysql -f etc/mysql-config.yaml
    58  CMD helm install mysql -f etc/redis-config.yaml
    59  */
    60  
    61  package v1
    62  
    63  import (
    64  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    65  )
    66  
    67  // ConfigSpec defines the desired state of Config
    68  type ConfigSpec struct {
    69  	Strategy string `json:"strategy,omitempty"`
    70  	Process  string `json:"process,omitempty"`
    71  	Data     string `json:"data,omitempty"`
    72  	Path     string `json:"path,omitempty"`
    73  }
    74  
    75  // ConfigStatus defines the observed state of Config
    76  type ConfigStatus struct {
    77  	// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
    78  	// Important: Run "make" to regenerate code after modifying this file
    79  }
    80  
    81  // +kubebuilder:object:root=true
    82  // +kubebuilder:subresource:status
    83  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    84  
    85  // Config is the Schema for the configs API
    86  type Config struct {
    87  	metav1.TypeMeta   `json:",inline"`
    88  	metav1.ObjectMeta `json:"metadata,omitempty"`
    89  
    90  	Spec   ConfigSpec   `json:"spec,omitempty"`
    91  	Status ConfigStatus `json:"status,omitempty"`
    92  }
    93  
    94  // +kubebuilder:object:root=true
    95  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    96  
    97  // ConfigList contains a list of Config
    98  type ConfigList struct {
    99  	metav1.TypeMeta `json:",inline"`
   100  	metav1.ListMeta `json:"metadata,omitempty"`
   101  	Items           []Config `json:"items"`
   102  }
   103  
   104  func init() {
   105  	SchemeBuilder.Register(&Config{}, &ConfigList{})
   106  }