Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jkleinlercher committed Oct 8, 2024
0 parents commit faf2968
Show file tree
Hide file tree
Showing 32 changed files with 1,409 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/branch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Create branches for kargo

on:
push:
branches:
- 'main'

jobs:
create_a_branch:
runs-on: ubuntu-latest
permissions:
actions: write
contents: write
steps:
- name: checkout
uses: actions/checkout@v4
- name: Create stages/qa branch
uses: peterjgrainger/action-create-branch@v3.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: 'stages/qa'
- name: Create stages/test branch
uses: peterjgrainger/action-create-branch@v3.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: 'stages/test'
- name: Create stages/prod branch
uses: peterjgrainger/action-create-branch@v3.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: 'stages/prod'
23 changes: 23 additions & 0 deletions .helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
5 changes: 5 additions & 0 deletions Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v2
name: podtato-head
description: Deploys the podtato-head app
version: 0.2.7
appVersion: 0.2.7
142 changes: 142 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Deliver with Helm

Here's how to deliver podtato-head using [Helm](https://helm.sh).

## Prerequisites

- Install Helm ([official instructions](https://helm.sh/docs/intro/install/))

## Deliver

You must clone this repo and install from a local copy of the chart:

```
git clone https://github.com/podtato-head/podtato-head.git && cd podtato-head
helm install podtato-head ./delivery/chart
```

This will install the chart in this directory with release name `podtato-head`.

> NOTE: You can instruct helm to wait for the resources to be ready before
marking the release as successful by adding the `--wait` option to the previous
command.

The installation can be customized by changing the following parameters via
`--set` or a custom `values.yaml` file specified with `--values`:

| Parameter | Description | Default |
| ------------------------------- | ----------------------------------------------------------------| -----------------------------|
| `replicaCount` | Number of replicas of the container | `1` |
| `images.repositoryDirname` | Prefix for image repos | `ghcr.io/podtato-head` |
| `images.pullPolicy` | Podtato Head Container pull policy | `IfNotPresent` |
| `images.pullSecrets` | Podtato Head Pod pull secret | `[]` |
| `<service>.repositoryBasename` | Leaf part of name of image repo for <service> | `entry`, `hat`, etc. |
| `<service>.tag` | Tag of image repo for <service> | `0.1.0` |
| `<service>.serviceType` | Service type for <service> | `LoadBalancer` for main |
| `<service>.servicePort` | Service port for <service> | `9000`-`9005` |
| `<service>.env` | Add "env:" entries on Deployments (ex: PODTATO_PART_NUMBER) | `[]` |
| `serviceAccount.create` | Whether or not to create dedicated service account | `true` |
| `serviceAccount.name` | Name of the service account to use | `default` |
| `serviceAccount.annotations` | Annotations to add to a created service account | `{}` |
| `podAnnotations` | Map of annotations to add to the pods | `{}` |
| `ingress.enabled` | Enables Ingress | `false` |
| `ingress.className` | IngressClass that will be be used (Kubernetes 1.18+) | `""` |
| `ingress.annotations` | Ingress annotations | `{}` |
| `ingress.hosts` | Ingress accepted hostnames | `[]` |
| `ingress.tls` | Ingress TLS configuration | `[]` |
| `autoscaling.enabled` | Enable horizontal pod autoscaler | `false` |
| `autoscaling.targetCPUUtilizationPercentage` | Target CPU utilization | `80` |
| `autoscaling.targetMemoryUtilizationPercentage` | Target Memory utilization | `80` |
| `autoscaling.minReplicas` | Min replicas for autoscaling | `1` |
| `autoscaling.maxReplicas` | Max replicas for autoscaling | `100` |
| `tolerations` | List of node taints to tolerate | `[]` |
| `resources` | Resource requests and limits | `{}` |
| `nodeSelector` | Labels for pod assignment | `{}` |

## Test

Verify the release succeeded:

```
helm list
kubectl get pods
kubectl get services
```

### Test the API endpoint

To connect to the API you'll first need to determine the correct address and
port.

If using a LoadBalancer-type service for `entry`, get the IP address of the load balancer
and use port 9000:

```
ADDR=$(kubectl get service podtato-head-entry -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
PORT=9000
```

If using a NodePort-type service, get the address of a node and the service's
NodePort as follows:

```
NODE_NAME=$(kubectl get nodes --output json | jq -r '.items[].metadata.name' | head -n 1)
ADDR=$(kubectl get nodes ${NODE_NAME} -o jsonpath={.status.addresses[0].address})
PORT=$(kubectl get services podtato-head-entry -ojsonpath='{.spec.ports[0].nodePort}')
```

If using a ClusterIP-type service, run `kubectl port-forward` in the background
and connect through that:

> NOTE: Find and kill the port-forward process afterwards using `ps` and `kill`.
```
# Choose below the IP address of your machine you want to use to access application
ADDR=127.0.0.1
# Choose below the port of your machine you want to use to access application
PORT=9000
kubectl port-forward --address ${ADDR} svc/podtato-head-entry ${PORT}:9000 &
```

Now test the API itself with curl and/or a browser:

```
curl http://${ADDR}:${PORT}/
xdg-open http://${ADDR}:${PORT}/
```

## Update

To update the application version, you can choose one of the following methods :

- update `<service>.tag` in `values.yaml` for each service and run `helm upgrade podtato-head ./delivery/chart`
- run `helm upgrade podtato-head ./delivery/chart --set entry.tag=0.1.1 --set leftLeg.tag=0.1.1 ...`

A new revision is then installed.

> NOTE : to ensure idempotency between the first installation and the following updates, you should use the following command :
```
helm upgrade --install podtato-head ./delivery/chart
```

## Rollback

To rollback to a previous revision, run :

```
# Check revision history
helm history podtato-head
# Rollback to the revision 1
helm rollback podtato-head 1
# Check the revision
helm status podtato-head
```

## Uninstall

```
helm uninstall podtato-head
```
28 changes: 28 additions & 0 deletions app-stages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
teamName: team-a
appName: kcd-demo
repoUrl: https://github.com/suxess-it/team-a-kcd-demo
createAppNamespace: true
stages:
- name: "test"
requestedFreight:
- origin:
kind: Warehouse
name: warehouse-{{ .Values.appName }}
sources:
direct: true
- name: "qa"
requestedFreight:
- origin:
kind: Warehouse
name: warehouse-{{ .Values.appName }}
sources:
stages:
- test
- name: "prod"
requestedFreight:
- origin:
kind: Warehouse
name: warehouse-{{ .Values.appName }}
sources:
stages:
- qa
Loading

0 comments on commit faf2968

Please sign in to comment.