# Deploy Your First Building Block

## Step Goals

After this part you will be able to:

- include your first Building Block,
- configure a Building Block the way you need and want it,
- deploy the Software Stack of a Building Block.

## Introduction

After you set up your Kubernetes cluster and control repository it is now time to deploy the first Building Block.

As the Building Blocks are heavily optimized for production-ready environments, their interdependencies come naturally. One of the core dependencies is the Observability Building Block. It ensures that following Building Blocks integrate automatically into your environment and can be added to your Monitoring and Logging seamlessly.

This Step will be explained by using the Bash shell in Unix like environments. We use a single window to work with. Please adapt to your needs accordingly.

As MetaKube Accelerator focuses on DevOps people, we expect you to have enough experience to work with the common tool set for administration tasks on Unix.

What's more, we will use "SysEleven" as Project and Company name, "showcase" as our control repository name as well as "development" as our environment. Please configure this accordingly.

## Integrate A Building Block Into Your Control Repository

If you haven't done it already, clone your control repository and add a suitable folder for the incoming building block:

```sh
# Make sure you are in a suitable directory for a new folder, clone your own control-repository
git clone git@code.syseleven.de:/syseleven/showcase

# When listing the files you should see the .gitlab-ci.yml you created on the previous step, e.g.
# -rw-r--r--   1 user  staff  1647  8 Feb 16:27 .gitlab-ci.yml

mkdir syseleven-kube-prometheus-stack
```

Add a `.gitlab-ci.yml` to this folder with the following content to include the JobDevelopment.yaml which includes the best practices for a development environment:

```yaml
include:
  - project: syseleven/building-blocks/helmfiles/kube-prometheus-stack
    file: JobDevelopment.yaml
    ref: {{ site.building_blocks.kube_prometheus_stack.version|e }}
```

Add a `values-kube-prometheus-stack.yaml` with the following content to specify all global settings:

```yaml
prometheus:
  prometheusSpec:
    retention: 10d
```

Now include environment-specific settings in `values-kube-prometheus-stack-development.yaml`:

```yaml
grafana:
  replicas: 1
  persistence:
    enabled: true
  adminPassword: $PASSWORD
  ingress:
    enabled: false

alertmanager:
  ingress:
    enabled: false

prometheus:
  prometheusSpec:
    resources:
      requests:
        memory: 500Mi
        cpu: 500m
      limits:
        memory: 2Gi
        cpu: "2"
    storageSpec:
      volumeClaimTemplate:
        spec:
          resources:
            requests:
              storage: 2Gi
```

After adding all these file your control repository should look like this:

```bash
/
└── syseleven-kube-prometheus-stack/
    ├── .gitlab-ci.yml
    ├── values-kube-prometheus-development.yaml
    └── values-kube-prometheus.yaml
.gitlab-ci.yml
```

Finally, you can include the `.gitlab-ci.yml` from your syseleven-kube-prometheus-stack to your CI/CD pipeline.

Your`.gitlab-ci.yml` in your root folder of your project workspace should now look like this:

```yaml
stages:
  - diff
  - deploy

include:
  - /syseleven-kube-prometheus-stack/.gitlab-ci.yml
```

Now you can commit your changes and your pipeline will start testing and deploying your Building Block.

Just execute

```sh
git add .
git commit -m "add kube-prometheus-stack as building block"
git push
```

and watch the output of your pipeline on [SysEleven Code](<https://code.syseleven.de>)!

## Further Steps?

- Show access to grafana/prometheus with port-forward
- Deploy nginx and cert-manager
- Enable ingress (this shows also how a BB config is updated)
