catalog

package
v0.7.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2016 License: Apache-2.0 Imports: 12 Imported by: 2

README

Dynamic Offering

New element in catalog can be added dynamicly with HTTP request and does not required any broker restarts:

  1. Add new service using PUT call on /v2/dynamicservice - exampled request is placed below
  2. Use CLI cf client to enable access to new created service:
cf enable-service-access dynamic-mongo
  1. New service is available in marketplace now. New instances can be spawn.

Exampled request

{
 "organization_guid": "fcb5307e-4995-4eeb-bfcd-08b3d3023bb5",
 "space_guid": "88d4676a-e374-4e36-9814-c269b85c5a0f",
 "parameters": null,
 "updateBroker": true,
 "dynamicService": {
   "serviceName": "dynamic-mongo",
   "planName": "dynamic-mongo",
   "isPlanFree": true,
   "containers": [
     {
       "name": "k-mongodb30",
       "image": "frodenas/mongodb:3.0",
       "ports": [
         {
           "containerPort": 27017,
           "protocol": "TCP"
         }
       ],
       "env": [
         { "name": "MANAGED_BY", "value":"TAP" },
         { "name": "MONGODB_PASSWORD",   "value": "user" },
         { "name": "MONGODB_USERNAME",   "value": "password" },
         { "name": "MONGODB_DBNAME",   "value": "test" }
       ],
       "resources": {},
       "imagePullPolicy": ""
     }
   ],
   "servicePorts": [
     {
       "name": "",
       "protocol": "TCP",
       "port": 27017,
       "targetPort": 0,
       "nodePort": 0
     }
   ],
   "credentialMappings": {
     "dbname": "$env_MONGODB_DBNAME",
     "hostname": "$hostname",
     "password": "$env_MONGODB_PASSWORD",
     "port": "$port_27017",
     "ports": {
       "27017/tcp": "$port_27017"
     },
     "uri": "mongodb://$env_MONGODB_USERNAME:$env_MONGODB_PASSWORD@$hostname:$port_27017/$env_MONGODB_DBNAME",
     "username": "$env_MONGODB_USERNAME"
   }
 }
}

Fields:

  • 'updateBroker' - will enforce cf borker-update
  • 'containers' - list of kubernetes containers - definition
  • 'servicePorts' - list of ports which will be assigned to kubernetes service - definition. This is a simple mapping, where 'port' value refers to 'containerPort' value
  • 'credentialMappings' - map of envs which will be serve to other apps. To put there container env value, following pattern has to be fulfill: 'env_ENV_NAME'. Service NodePort value also can be use. To access it use pattern: 'port_PORT_NUMBER'

Documentation

Overview

*

  • Copyright (c) 2016 Intel Corporation *
  • 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.

*

  • Copyright (c) 2016 Intel Corporation *
  • 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.

Index

Constants

This section is empty.

Variables

View Source
var CatalogPath string = "./catalogData/"
View Source
var TEMP_DYNAMIC_BLUEPRINTS = map[string]KubernetesBlueprint{}

Functions

func CheckIfServiceAlreadyExist

func CheckIfServiceAlreadyExist(serviceName string) bool

func CreateDynamicService

func CreateDynamicService(dynamicService DynamicService) (KubernetesBlueprint, PlanMetadata, ServiceMetadata, error)

func RegisterOfferingInCatalog

func RegisterOfferingInCatalog(service ServiceMetadata, blueprint KubernetesBlueprint)

func UnregisterOfferingFromCatalog

func UnregisterOfferingFromCatalog(service ServiceMetadata)

func WhatToCreateByServiceAndPlanId

func WhatToCreateByServiceAndPlanId(service_id, plan_id string) (ServiceMetadata, PlanMetadata, error)

Types

type DynamicService

type DynamicService struct {
	ServiceName        string                 `json:"serviceName"`
	PlanName           string                 `json:"planName"`
	IsPlanFree         bool                   `json:"isPlanFree"`
	Containers         []api.Container        `json:"containers"`
	ServicePorts       []api.ServicePort      `json:"servicePorts"`
	CredentialMappings map[string]interface{} `json:"credentialMappings"`
}

type KubernetesBlueprint

type KubernetesBlueprint struct {
	Id                        int
	SecretsJson               []string
	ReplicationControllerJson []string
	ServiceJson               []string
	ServiceAcccountJson       []string
	PersistentVolumeClaim     []string
	CredentialsMapping        string
	ReplicaTemplate           string
}

func GetKubernetesBlueprintByServiceAndPlan

func GetKubernetesBlueprintByServiceAndPlan(catalogPath string, svcMeta ServiceMetadata, planMeta PlanMetadata) (KubernetesBlueprint, error)

type KubernetesComponent

type KubernetesComponent struct {
	PersistentVolumeClaim  []*api.PersistentVolumeClaim
	ReplicationControllers []*api.ReplicationController
	Services               []*api.Service
	ServiceAccounts        []*api.ServiceAccount
	Secrets                []*api.Secret
}

func CreateKubernetesComponentFromBlueprint

func CreateKubernetesComponentFromBlueprint(blueprint KubernetesBlueprint) (*KubernetesComponent, error)

func GetParsedKubernetesComponent

func GetParsedKubernetesComponent(catalogPath, instanceId, org, space string, svcMeta ServiceMetadata, planMeta PlanMetadata) (*KubernetesComponent, error)

func ParseKubernetesComponent

func ParseKubernetesComponent(blueprint KubernetesBlueprint, instanceId, svcMetaId, planMetaId, org, space string) (*KubernetesComponent, error)

type PlanMetadata

type PlanMetadata struct {
	Id          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Free        bool   `json:"free"`
	InternalId  string `json:"-"`
}

func GetPlanMetadataByPlanIdInServiceMetadata

func GetPlanMetadataByPlanIdInServiceMetadata(svc_metadata ServiceMetadata, plan_id string) (PlanMetadata, error)

type ServiceMetadata

type ServiceMetadata struct {
	Id          string         `json:"id"`
	Name        string         `json:"name"`
	Description string         `json:"description"`
	Bindable    bool           `json:"bindable"`
	Tags        []string       `json:"tags"`
	Plans       []PlanMetadata `json:"plans"`
	InternalId  string         `json:"-"`
}

func GetServiceByName

func GetServiceByName(serviceName string) (ServiceMetadata, error)

func GetServiceMetadataByServiceId

func GetServiceMetadataByServiceId(service_id string) (ServiceMetadata, error)

type ServicesMetadata

type ServicesMetadata struct {
	Services []ServiceMetadata `json:"services"`
}
var GLOBAL_SERVICES_METADATA *ServicesMetadata

add mutex... or return a deep copy (prefered).

func GetAvailableServicesMetadata

func GetAvailableServicesMetadata() ServicesMetadata

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL