# Deployment to Kubernetes

## Prerequisites

* Install `kubectl` <https://kubernetes.io/docs/tasks/tools/>
* Install `kustomize` <https://kubectl.docs.kubernetes.io/installation/kustomize/>

## Frontend

### Staging

You may trigger staging release at any point of time from the `master` branch by:

```shell
cd podkrepi.bg/frontend
kubectl apply -k manifests/overlays/development
```

This will update the deployment using `ghcr.io/podkrepi-bg/frontend:master` image

### Production

#### **Create new release**

The following command will:

* Bump the version in `package.json`
* Tag the `latest` master branch
* \[`postversion`] Push local tags to the remote origin
* Update the image `newTag` version in `frontend/manifests/overlays/production/kustomization.yaml`
* Commit and push the manifest update

```
cd podkrepi.bg/frontend
kubectl apply -k manifests/overlays/production
```

#### **Apply manifests**

Once the image has been built by the GitHub Actions and is present in the Docker image repository you may trigger the actual deployment to the cluster.

<https://github.com/orgs/podkrepi-bg/packages/container/package/frontend>

```
cd podkrepi.bg/frontend
kubectl apply -k manifests/overlays/production
```

## Backend

### Staging

You may trigger staging release at any point of time from the `master` branch by:

```
cd podkrepi.bg/backend
kubectl apply -k manifests/overlays/development
```

This will update the deployment using `ghcr.io/podkrepi-bg/api:master` image

### Production

#### **Create new release**

The following command will:

* Bump the version in `package.json`
* Tag the `latest` master branch
* \[`postversion`] Push local tags to the remote origin
* Update the image `newTag` version in `backend/manifests/overlays/production/kustomization.yaml`
* Commit and push the manifest update

```
cd podkrepi.bg/backend
kubectl apply -k manifests/overlays/production
```

#### **Apply manifests**

Once the image has been built by the GitHub Actions and is present in the Docker image repository you may trigger the actual deployment to the cluster.

<https://github.com/orgs/podkrepi-bg/packages/container/package/api>

```
cd podkrepi.bg/backend
kubectl apply -k manifests/overlays/production
```

#### Manual deployment

If you want to set a specific version for the deployment image you can do that by editing `backend/manifests/overlays/production/kustomization.yaml`&#x20;

```yaml
images:
- name: ghcr.io/podkrepi-bg/api/migrations
  newTag: v0.3.3
- name: ghcr.io/podkrepi-bg/api
  newTag: v0.3.3
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.podkrepi.bg/development/infrastructure/deployment-to-kubernetes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
