Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(deploy): add helm chart #138

Merged
merged 33 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
06fe668
chore: wip
Alan-pad May 10, 2023
0698f6c
chore: wip
Alan-pad May 23, 2023
a1e9a61
chore: wip
Alan-pad May 25, 2023
4566ca7
chore: wip
corrieriluca Jul 11, 2023
55938e0
chore: wip
corrieriluca Jul 12, 2023
a6caf92
chore(manifests): update container entrypoints
corrieriluca Jul 13, 2023
023808d
chore(deploy): split redis URL in host + port
corrieriluca Jul 31, 2023
21ab2ce
fix(cli): make Redis flags global
corrieriluca Jul 31, 2023
4ee9b2a
fix(redis): rename port field
corrieriluca Jul 31, 2023
c424ddf
fix(runner): try log layer
corrieriluca Jul 31, 2023
7fd33d1
fix: trigger ci
corrieriluca Jul 31, 2023
1ca3d0a
fix(runner): fix get layer
corrieriluca Jul 31, 2023
ebe723e
fix(runner): fix logs layer/repo
corrieriluca Jul 31, 2023
681f79f
chore(deploy): fix RBAC for burrito-runner + ssh known hosts
corrieriluca Jul 31, 2023
de821ad
chore(deploy): add TODO on CM reloading
corrieriluca Jul 31, 2023
7ca7b15
chore(deploy): helm: add checksums for configmap
corrieriluca Aug 1, 2023
cee2f0e
chore(deploy): helm: use appVersion for image tag
corrieriluca Aug 1, 2023
d089fe8
ci(helm): add CI/CD for Helm chart
corrieriluca Aug 1, 2023
ebf0b35
ci(helm): test Helm rendering
corrieriluca Aug 1, 2023
5c963dd
ci(helm): make Helm render mandatory
corrieriluca Aug 1, 2023
026365f
fix(helm): appVersion references
corrieriluca Aug 1, 2023
fe75390
ci(helm): trigger on Helm chart files for PR
corrieriluca Aug 1, 2023
98716b1
docs(burrito): fix some typos and markdown lint
corrieriluca Aug 1, 2023
af60980
chore(manifests): update references to burrito namespace
corrieriluca Aug 1, 2023
8bf2e5b
fix(cmd): add --namespaces flag + update doc
corrieriluca Aug 1, 2023
21ea6a0
chore(manifests): use burrito NS for manifest install method
corrieriluca Aug 1, 2023
7967819
docs(burrito): describe 2 installation methods
corrieriluca Aug 1, 2023
cd16cb2
docs(burrito): describe multi-tenant architecture
corrieriluca Aug 1, 2023
e077546
fix(helm): update values-example
corrieriluca Aug 2, 2023
a6b078d
fix(helm): remove burrito-runner default SA
corrieriluca Aug 2, 2023
6cdc512
fix(helm): make tenants a empty array
corrieriluca Aug 2, 2023
3c41d37
ci(helm): remove ghcr logout
corrieriluca Aug 2, 2023
9539ea9
fix(helm): rename redis default hostname
corrieriluca Aug 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/helm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Helm CI/CD

on:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main
paths:
- 'deploy/charts/**'

env:
CHART_NAME: burrito
CHART_PATH: ./deploy/charts/burrito
CHART_REPO: ghcr.io/${{ github.repository_owner }}/charts

jobs:
helm-render:
name: Helm Render
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Helm Render
run: helm template ${{ env.CHART_PATH }}

helm-push:
name: Helm Push
runs-on: ubuntu-latest
needs: helm-render
steps:
- name: Checkout
uses: actions/checkout@v3

- name: GHCR Login
run: echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io -u ${{ github.repository_owner }} --password-stdin

- name: Compute versions
shell: bash
run: |
CURRENT_VERSION=$(yq $CHART_PATH/Chart.yaml --expression .version)
if [[ ${{ github.event_name }} == 'pull_request' || ${{ github.event_name }} == 'push' && ${{ github.ref_type }} == 'branch' ]]; then
echo "VERSION=$(echo $CURRENT_VERSION-${{ github.sha }})" >> $GITHUB_ENV
echo "APP_VERSION=${{ github.sha }}" >> $GITHUB_ENV
elif [[ ${{ github.event_name }} == 'push' && ${{ github.ref_type }} == 'tag' ]]; then
echo "VERSION=$(echo ${{ github.ref_name }} | sed 's/v//')" >> $GITHUB_ENV
echo "APP_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
else
echo "Unsupported event type"
exit 1
fi

- name: Helm Package
run: helm package ${{ env.CHART_PATH }} -u --version ${{ env.VERSION }} --app-version ${{ env.APP_VERSION }}

- name: Helm Push
run: helm push ./${{ env.CHART_NAME }}-${{ env.VERSION }}.tgz oci://ghcr.io/${{ github.repository_owner }}/charts
15 changes: 13 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
runs-on: ubuntu-latest
environment: production
steps:

- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Fetch all tags
run: git fetch --force --tags

Expand All @@ -44,15 +44,26 @@ jobs:
version:
runs-on: ubuntu-latest
environment: production
env:
CHART_PATH: ./deploy/charts/burrito
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main
- name: Bump version

- name: Bump VERSION file
run: |
echo ${{ github.ref_name }} > VERSION

- name: Bump Helm Chart versions
run: |
export CHART_VERSION=$(echo ${{ github.ref_name }} | sed 's/v//g')
export APP_VERSION=${{ github.ref_name }}
yq -i '.version = env(CHART_VERSION)' $CHART_PATH/Chart.yaml
yq -i '.appVersion = env(APP_VERSION)' $CHART_PATH/Chart.yaml

- name: Commit version to repository
uses: stefanzweifel/git-auto-commit-action@v4
with:
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@
[`terraform`](https://www.terraform.io/) is a tremendous tool to manage your infrastructure in IaC.
But, it does not come up with an out-of the box solution for managing [state drift](https://developer.hashicorp.com/terraform/tutorials/state/resource-drift).

Also, writing a CI/CD pipeline for terraform can be painful and depends on the tool you are using.
Also, writing a CI/CD pipeline for Terraform can be painful and depends on the tool you are using.

Finally, currently, there is no easy way to navigate your terraform state to truly understand the modifications it undergoes when running `terraform apply`.
Finally, currently, there is no easy way to navigate your Terraform state to truly understand the modifications it undergoes when running `terraform apply`.

`burrito` aims to tackle those issues by:

- Planning continuously your terraform code and run applies if needed
- Offering an out of the box PR/MR integration so you do not have to write CI/CD pipelines for terraform ever again (not implemented yet)
- Planning continuously your Terraform code and run applies if needed
- Offering an out of the box PR/MR integration so you do not have to write CI/CD pipelines for Terraform ever again
- Showing your state's modifications in a simple Web UI (not implemented yet)

## Demo
## Demo

![demo](./docs/assets/demo/demo.gif)

## Documenation
## Documentation

To learn more about burrito [go to the complete documentation](https://padok-team.github.io/burrito/).

Expand Down
2 changes: 1 addition & 1 deletion cmd/controllers/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func buildControllersStartCmd(app *burrito.App) *cobra.Command {
defaultWaitActionTimer, _ := time.ParseDuration("1m")
defaultFailureGracePeriod, _ := time.ParseDuration("15s")

cmd.Flags().StringSliceVar(&app.Config.Controller.Namespaces, "namespaces", []string{"burrito-system"}, "list of namespaces to watch")
cmd.Flags().StringSliceVar(&app.Config.Controller.Types, "types", []string{"layer", "repository", "pullrequest"}, "list of controllers to start")

cmd.Flags().DurationVar(&app.Config.Controller.Timers.DriftDetection, "drift-detection-period", defaultDriftDetectionTimer, "period between two plans. Must end with s, m or h.")
cmd.Flags().DurationVar(&app.Config.Controller.Timers.OnError, "on-error-period", defaultOnErrorTimer, "period between two runners launch when an error occurred in the controllers. Must end with s, m or h.")
cmd.Flags().DurationVar(&app.Config.Controller.Timers.WaitAction, "wait-action-period", defaultWaitActionTimer, "period between two runners when a layer is locked. Must end with s, m or h.")
Expand Down
7 changes: 4 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ func buildBurritoCmd(app *burrito.App) *cobra.Command {
},
}

cmd.Flags().StringVar(&app.Config.Redis.URL, "redis-url", "burrito-redis:6379", "the redis URL to connect to")
cmd.Flags().StringVar(&app.Config.Redis.Password, "redis-password", "", "the redis password")
cmd.Flags().IntVar(&app.Config.Redis.Database, "redis-database", 0, "the redis database")
cmd.PersistentFlags().StringVar(&app.Config.Redis.Hostname, "redis-host", "burrito-redis.burrito-system", "the redis host to connect to")
cmd.PersistentFlags().IntVar(&app.Config.Redis.ServerPort, "redis-port", 6379, "the port of the redis to connect to")
cmd.PersistentFlags().StringVar(&app.Config.Redis.Password, "redis-password", "", "the redis password")
cmd.PersistentFlags().IntVar(&app.Config.Redis.Database, "redis-database", 0, "the redis database")

cmd.AddCommand(controllers.BuildControllersCmd(app))
cmd.AddCommand(runner.BuildRunnerCmd(app))
Expand Down
23 changes: 23 additions & 0 deletions deploy/charts/burrito/.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/
6 changes: 6 additions & 0 deletions deploy/charts/burrito/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: burrito
description: A Helm chart for handling a complete burrito deployment
type: application
version: 0.1.0
appVersion: "v0.1.0"
37 changes: 37 additions & 0 deletions deploy/charts/burrito/templates/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{- if .Values.config.create }}

{{- $config := .Values.config.burrito }}

{{/*
Tenant Namespaces
*/}}
{{- $tenantNamespaces := list }}
{{- range $tenant := .Values.tenants }}
{{- $tenantNamespaces = append $tenantNamespaces $tenant.namespace.name }}
{{- end }}
{{- $_ := set $config.controller "namespaces" (default $tenantNamespaces $config.controller.namespaces) }}

{{/*
Redis Hostname
*/}}
{{- if .Values.redis.enabled }}
{{- $_ := set $config.redis "hostname" (printf "%s.%s" "burrito-redis" .Release.Namespace) }}
{{- end }}

apiVersion: v1
kind: ConfigMap
metadata:
name: burrito-config
labels:
app.kubernetes.io/name: burrito-config
{{- toYaml .Values.global.metadata.labels | nindent 4 }}
{{- with (mergeOverwrite (deepCopy .Values.global.metadata.annotations) .Values.config.annotations) }}
annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
data:
config.yaml: |-
{{- toYaml $config | nindent 4 }}
{{- end }}
121 changes: 121 additions & 0 deletions deploy/charts/burrito/templates/controllers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{{ $configChecksum := (include (print $.Template.BasePath "/config.yaml") . | sha256sum) }}
{{ $sshKnownHostsChecksum := (include (print $.Template.BasePath "/ssh-known-hosts.yaml") . | sha256sum) }}

{{- with mergeOverwrite (deepCopy .Values.global) .Values.controllers }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: burrito-controllers
annotations:
{{- toYaml .metadata.annotations | nindent 4 }}
labels:
{{- toYaml .metadata.labels | nindent 4 }}
spec:
{{- if not .deployment.autoscaling.enabled }}
replicas: {{ .deployment.replicas }}
{{- end }}
selector:
matchLabels:
{{- toYaml .metadata.labels | nindent 6 }}
template:
metadata:
annotations:
checksum/burrito-config: {{ $configChecksum }}
checksum/burrito-ssh-known-hosts: {{ $sshKnownHostsChecksum }}
{{- toYaml .deployment.podAnnotations | nindent 8 }}
labels:
{{- toYaml .metadata.labels | nindent 8 }}
spec:
{{- with .deployment.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: burrito-controllers
securityContext:
{{- toYaml .deployment.podSecurityContext | nindent 8 }}
containers:
- name: burrito
command:
{{- toYaml .deployment.command | nindent 12 }}
args:
{{- toYaml .deployment.args | nindent 12 }}
securityContext:
{{- toYaml .deployment.securityContext | nindent 12 }}
image: "{{ .deployment.image.repository }}:{{ .deployment.image.tag | default $.Chart.AppVersion }}"
imagePullPolicy: {{ .deployment.image.pullPolicy }}
ports:
{{- toYaml .deployment.ports | nindent 12 }}
livenessProbe:
{{- toYaml .deployment.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .deployment.readinessProbe | nindent 12 }}
resources:
{{- toYaml .deployment.resources | nindent 12 }}
env:
{{- toYaml .deployment.env | nindent 12 }}
envFrom:
{{- toYaml .deployment.envFrom | nindent 12 }}
volumeMounts:
- name: burrito-config
mountPath: /etc/burrito
readOnly: true
{{- with .deployment.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .deployment.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .deployment.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: burrito-config
configMap:
name: burrito-config
{{- if .service.enabled }}
---
apiVersion: v1
kind: Service
metadata:
name: burrito-controllers
labels:
{{- toYaml .metadata.labels | nindent 4}}
annotations:
{{- toYaml .metadata.annotations | nindent 4}}
spec:
type: {{ .type }}
ports:
{{- toYaml .service.ports | nindent 4 }}
selector:
{{- toYaml .metadata.labels | nindent 4 }}
{{- end }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: burrito-controllers
labels:
{{- toYaml .metadata.labels | nindent 4 }}
annotations:
{{- toYaml .metadata.annotations | nindent 4 }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: burrito-controllers
labels:
{{- toYaml .metadata.labels | nindent 4 }}
annotations:
{{- toYaml .metadata.annotations | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: burrito-controllers
subjects:
- kind: ServiceAccount
name: burrito-controllers
namespace: {{ $.Release.Namespace }}
{{- end }}
Loading