Documentation ¶
Index ¶
- Constants
- func ClusterConfigDetails(db DB, clusterName string) (string, error)
- func CreateNamespace(clientset kubernetes.Interface, username string) error
- func DeleteNamespace(clientset kubernetes.Interface, username string) error
- func GetDB(host string, user string, port int, sslmode string, dbName string, ...) (*sqlx.DB, error)
- func ListClusterConfig(db DB) ([]string, error)
- func ListNamespaces(clientset kubernetes.Interface) (*v1.NamespaceList, error)
- func NamespaceExists(clientset kubernetes.Interface, namespace string) bool
- func RemoveClusterConfig(db DB, clusterName string) error
- func ServicePort(clientset kubernetes.Interface, name, username string) (int, error)
- func WriteClusterConfig(db DB, clusterName string, yamlStr string) error
- type Cluster
- func (c *Cluster) Apps(config *viper.Viper, clientset kubernetes.Interface, k8sDomain string) (map[string][]string, error)
- func (c *Cluster) Create(logger logrus.FieldLogger, clientset kubernetes.Interface) error
- func (c *Cluster) Delete(clientset kubernetes.Interface) error
- func (c *Cluster) Services(clientset kubernetes.Interface) ([]string, error)
- type ClusterAppConfig
- type ClusterConfig
- type Credentials
- type DB
- type Deployment
- type DeploymentReadiness
- type EnvVar
- type Job
- type JobReadiness
- type MemoryAndCPUResource
- type MockCredentials
- type OSCredentials
- type PersistentVolumeClaim
- type PortMap
- type Probe
- type Readiness
- type Resources
- type Service
- type Setup
- type VolumeMount
Constants ¶
const ( //ClientIDEnvVar defines the name of the environment variable ClientIDEnvVar = "MYSTACK_GOOGLE_CLIENT_ID" //ClientSecretEnvVar defines the name of the environment variable ClientSecretEnvVar = "MYSTACK_GOOGLE_CLIENT_SECRET" )
Variables ¶
This section is empty.
Functions ¶
func ClusterConfigDetails ¶
ClusterConfigDetails return the cluster config yaml
func CreateNamespace ¶
func CreateNamespace(clientset kubernetes.Interface, username string) error
CreateNamespace creates a namespace
func DeleteNamespace ¶
func DeleteNamespace(clientset kubernetes.Interface, username string) error
DeleteNamespace delete the namespace
func GetDB ¶
func GetDB( host string, user string, port int, sslmode string, dbName string, password string, maxIdleConns, maxOpenConns int, connectionTimeoutMS int, ) (*sqlx.DB, error)
GetDB Connection using the given properties
func ListClusterConfig ¶
ListClusterConfig return the list of saved cluster configs
func ListNamespaces ¶
func ListNamespaces(clientset kubernetes.Interface) (*v1.NamespaceList, error)
ListNamespaces returns a list of namespaces
func NamespaceExists ¶
func NamespaceExists(clientset kubernetes.Interface, namespace string) bool
NamespaceExists return true if namespace is already created
func RemoveClusterConfig ¶
RemoveClusterConfig writes cluster config on DB
func ServicePort ¶ added in v0.3.0
func ServicePort(clientset kubernetes.Interface, name, username string) (int, error)
ServicePort ...
Types ¶
type Cluster ¶
type Cluster struct { Namespace string Username string AppDeployments []*Deployment SvcDeployments []*Deployment K8sServices map[*Deployment]*Service Job, PostJob *Job PersistentVolumeClaims []*PersistentVolumeClaim DeploymentReadiness Readiness JobReadiness Readiness }
Cluster represents a k8s cluster for a user
func NewCluster ¶
func NewCluster( db DB, username, clusterName string, deploymentReadiness, jobReadiness Readiness, config *viper.Viper, ) (*Cluster, error)
NewCluster returns a new cluster ready to start
func (*Cluster) Apps ¶
func (c *Cluster) Apps( config *viper.Viper, clientset kubernetes.Interface, k8sDomain string, ) (map[string][]string, error)
Apps returns a list of cluster apps
func (*Cluster) Create ¶
func (c *Cluster) Create(logger logrus.FieldLogger, clientset kubernetes.Interface) error
Create creates namespace, deployments and services
type ClusterAppConfig ¶
type ClusterAppConfig struct { Image string `yaml:"image"` ImagePullPolicy string `yaml:"imagePullPolicy"` Command []string `yaml:"command"` Ports []string `yaml:"ports"` Environment []*EnvVar `yaml:"env,flow"` ReadinessProbe *Probe `yaml:"readinessProbe"` VolumeMount *VolumeMount `yaml:"volumeMount"` Links []string `yaml:"links"` Resources *Resources `yaml:"resources"` IsSocket bool `yaml:"isSocket"` }
ClusterAppConfig defines the configuration of an app and service
type ClusterConfig ¶
type ClusterConfig struct { Setup *Setup `yaml:"setup"` PostSetup *Setup `yaml:"postSetup"` Volumes []*PersistentVolumeClaim `yaml:"volumes"` Services map[string]*ClusterAppConfig `yaml:"services"` Apps map[string]*ClusterAppConfig `yaml:"apps"` }
ClusterConfig contains the elements of a config file
func LoadClusterConfig ¶
func LoadClusterConfig( db DB, clusterName string, ) ( *ClusterConfig, error, )
LoadClusterConfig reads DB and create map with cluster configuration
func ParseYaml ¶
func ParseYaml(yamlStr string) (*ClusterConfig, error)
ParseYaml convert string to maps
type Credentials ¶
Credentials is an interface with Get method to get ClientID and ClientSecret
type DB ¶
type DB interface { NamedExec(query string, arg interface{}) (sql.Result, error) Get(dest interface{}, query string, args ...interface{}) error Select(dest interface{}, query string, args ...interface{}) error }
DB is the mystack-controller db interface
type Deployment ¶
type Deployment struct { Name string Namespace string Username string Command []string Image string ImagePullPolicy string Ports []int Environment []*EnvVar ReadinessProbe *Probe Volume *VolumeMount Links []*Deployment Resources *Resources }
Deployment represents a deployment
func NewDeployment ¶
func NewDeployment( name, username, image string, ports []int, environment []*EnvVar, readinessProbe *Probe, volume *VolumeMount, command []string, resources *Resources, config *viper.Viper, ) *Deployment
NewDeployment is the deployment ctor
func (*Deployment) Delete ¶
func (d *Deployment) Delete(clientset kubernetes.Interface) error
Delete deletes deployment from cluster
func (*Deployment) Deploy ¶
func (d *Deployment) Deploy(clientset kubernetes.Interface) (*v1beta1.Deployment, error)
Deploy creates a deployment from yaml
type DeploymentReadiness ¶
type DeploymentReadiness struct{}
DeploymentReadiness implements Readiness interface
func (*DeploymentReadiness) WaitForCompletion ¶
func (dr *DeploymentReadiness) WaitForCompletion(clientset kubernetes.Interface, d interface{}) error
WaitForCompletion waits until job has completed its task
type JobReadiness ¶
type JobReadiness struct{}
JobReadiness implements Readiness interface
func (*JobReadiness) WaitForCompletion ¶
func (jr *JobReadiness) WaitForCompletion( clientset kubernetes.Interface, j interface{}, ) error
WaitForCompletion waits until job has completed its task
type MemoryAndCPUResource ¶ added in v0.4.3
MemoryAndCPUResource has information about CPU and memory to be allocated to a pod
type MockCredentials ¶
MockCredentials implements Credentials interface
func (*MockCredentials) GetID ¶
func (m *MockCredentials) GetID() string
GetID gets ID from environment variable
func (*MockCredentials) GetSecret ¶
func (m *MockCredentials) GetSecret() string
GetSecret gets secret from environment variable
type OSCredentials ¶
type OSCredentials struct{}
OSCredentials implements Credentials interface
func (*OSCredentials) GetID ¶
func (o *OSCredentials) GetID() string
GetID gets ID from environment variable
func (*OSCredentials) GetSecret ¶
func (o *OSCredentials) GetSecret() string
GetSecret gets secret from environment variable
type PersistentVolumeClaim ¶ added in v0.2.0
type PersistentVolumeClaim struct { Name string `yaml:"name"` Storage string `yaml:"storage"` Namespace string }
PersistentVolumeClaim gets volume configs from yaml
func NewPVC ¶ added in v0.2.0
func NewPVC(name, username, storage string) *PersistentVolumeClaim
NewPVC is the PersistentVolumeClaim constructor
func (*PersistentVolumeClaim) Delete ¶ added in v0.2.0
func (p *PersistentVolumeClaim) Delete(clientset kubernetes.Interface) error
Delete deletes persistent volume cluster
func (*PersistentVolumeClaim) Start ¶ added in v0.2.0
func (p *PersistentVolumeClaim) Start(clientset kubernetes.Interface) (*v1.PersistentVolumeClaim, error)
Start ...
type Probe ¶
type Probe struct { Command []string `yaml:"command"` PeriodSeconds int `yaml:"periodSeconds"` //This timeout is different from the kubernetes object api timeoutSecond. //This timeout represents the total wait time until stop deployment initiation and rollback TimeoutSeconds int `yaml:"startDeploymentTimeoutSeconds"` }
Probe refers to the Kubernetes readiness probe
type Readiness ¶
type Readiness interface {
WaitForCompletion(kubernetes.Interface, interface{}) error
}
Readiness is the interface that tell how much time to wait until the deployment is ready and its readiness probe reports Ready
type Resources ¶ added in v0.4.3
type Resources struct { Limits *MemoryAndCPUResource `yaml:"limits"` Requests *MemoryAndCPUResource `yaml:"requests"` }
Resources holds how much CPU and memory is allocated to the pod
type Service ¶
type Service struct { Name string Namespace string Ports []*PortMap IsMystackSvc bool SocketPorts string IsSocket bool }
Service represents a service
func NewService ¶
NewService is the service ctor
type Setup ¶
type Setup struct { Image string `yaml:"image"` ImagePullPolicy string `yaml:"imagePullPolicy"` Command []string `yaml:"command"` PeriodSeconds int `yaml:"periodSeconds"` Environment []*EnvVar `yaml:"env"` TimeoutSeconds int `yaml:"timeoutSeconds"` }
Setup has the job config to run and configure services
type VolumeMount ¶ added in v0.2.0
VolumeMount helps getting PersistentVolume from yaml