<commit_before># Service Catalog example

## Description

Imagine that we want to deploy a service to Kubernetes, which consists of:
- Running application instances
- Postgres database, SQS queue
- Load balancer

![Application diagram](img/Application_example.png?raw=true "Application diagram")

For provisioning resources in AWS we can use [Service Catalog](https://github.com/kubernetes-incubator/service-catalog).
It allows us to provision resources through [Open Service Broker API](https://github.com/openservicebrokerapi/servicebroker) 
and produce Kubernetes Secret objects which we can inject into the Pods using PodPresets.

The resulting graph of Kubernetes and Service Catalog objects consists of:
- Pods for running application instances
- PodPresets referencing Secrets and injecting them into Pods
- Service Catalog Instance and Binding objects
- Ingress and Service (don't confuse it with Service Catalog) objects for load balancing

![Kubernetes objects graph](img/Kubernetes_graph.png?raw=true "Kubernetes objects graph")

## Demo

The objects in this graph should be created in a particular order, in respect of dependencies between them (note: independent branches in the graph could be processed in parallel).
There is no built-in generic way of making sure that the objects are created in a particular order. And **Smith** project was designed to solve exactly this problem.

Smith Bundle declaring the graph described above (see [application.yaml](application.yaml)):

```yaml
apiVersion: smith.atlassian.com/v1
kind: Bundle
metadata:
  name: sampleapp
spec:
  resources:

  - name: instance1
    spec:
      apiVersion: servicecatalog.k8s.io/v1alpha1
      kind: Instance
      metadata:
        name: instance1
      spec:<commit_msg>Fix Service Catalog example docs<commit_after># Service Catalog example

## Description

Imagine that we want to deploy a service to Kubernetes, which consists of:
- Running application instances
- Postgres database, SQS queue
- Load balancer

![Application diagram](img/Application_example.png?raw=true "Application diagram")

For provisioning resources in AWS we can use [Service Catalog](https://github.com/kubernetes-incubator/service-catalog).
It allows us to provision resources through [Open Service Broker API](https://github.com/openservicebrokerapi/servicebroker) 
and produce Kubernetes Secret objects which we can inject into the Pods using PodPresets.

The resulting graph of Kubernetes and Service Catalog objects consists of:
- Pods for running application instances
- PodPresets referencing Secrets and injecting them into Pods
- Service Catalog Instance and Binding objects
- Ingress and Service (don't confuse it with Service Catalog) objects for load balancing

![Kubernetes objects graph](img/Kubernetes_graph.png?raw=true "Kubernetes objects graph")

## Problem

The objects in this graph should be created in particular order, in respect of dependencies between them (note: independent branches in the graph could be processed in parallel).
There is no built-in generic way in Kubernetes of making sure that the objects are created in a particular order. And **Smith** project was designed to solve exactly this problem.

## Demo

Smith Bundle declaring the graph described above (see [application.yaml](application.yaml)):

```yaml
apiVersion: smith.atlassian.com/v1
kind: Bundle
metadata:
  name: sampleapp
spec:
  resources:

  - name: instance1
    spec:
      apiVersion: servicecatalog.k8s.io/v1alpha1
      kind: Instance
      metadata:
        name: instance1
      spec:
{'fraction_non_alphanumeric': 0.06346531873069362, 'fraction_numerical': 0.003369839932603201, 'mean_word_length': 4.773095623987034, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2628366', 'n_tokens_mistral': 913, 'n_tokens_neox': 865, 'n_words': 411}