Skip to content

Commit

Permalink
Added logo and release action
Browse files Browse the repository at this point in the history
  • Loading branch information
Skarlso committed Jul 25, 2023
1 parent 0bab148 commit 72ce8f4
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 8 deletions.
46 changes: 46 additions & 0 deletions .github/.workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Create release
on:
push:
tags:
- 'v*'

permissions:
contents: read
env:
REGISTRY: ghcr.io
DOCKERFILE: ${{ github.workspace }}/goreleaser.dockerfile

jobs:
release:
permissions:
contents: 'write'
id-token: 'write'
pull-requests: 'read'
repository-projects: 'write'
packages: 'write'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.GIT_CHECKOUT_KEY }}
- name: Prepare
id: prep
run: |
VERSION=sha-${GITHUB_SHA::8}
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF/refs\/tags\//}
fi
echo ::set-output name=BUILD_DATE::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
echo ::set-output name=VERSION::${VERSION}
- name: Generate manifests
run: |
mkdir -p output
kustomize build ./config/default > ./output/install.yaml
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
version: latest
args: release --release-notes=docs/release_notes/${{ steps.prep.outputs.VERSION }}.md --skip-validate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49 changes: 49 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
- go mod tidy
builds:
- main: main.go
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
goarch:
- amd64
archives:
- name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
release:
extra_files:
- glob: output/install.yaml
checksum:
name_template: 'checksums.txt'
extra_files:
- glob: output/install.yaml
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
# for more information on what this target does: https://goreleaser.com/errors/docker-build/
dockers:
- id: linux-build
image_templates:
- "{{ .Env.REGISTRY }}/skarlso/{{ .ProjectName }}:{{ .Tag }}"
- "{{ .Env.REGISTRY }}/skarlso/{{ .ProjectName }}:latest"
# GOOS of the built binary that should be used.
goos: linux
# GOARCH of the built binary that should be used.
goarch: amd64
dockerfile: "{{ .Env.DOCKERFILE }}"
build_flag_templates:
- "--platform=linux/amd64"
133 changes: 125 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,120 @@
# crd-bootstrap
// TODO(user): Add simple overview of use/purpose

## Description
// TODO(user): An in-depth paragraph about your project and overview of use
![logo](./hack/crd-bootstrap-logo.png)

## Getting Started
You’ll need a Kubernetes cluster to run against. You can use [KIND](https://sigs.k8s.io/kind) to get a local cluster for testing, or run against a remote cluster.
**Note:** Your controller will automatically use the current context in your kubeconfig file (i.e. whatever cluster `kubectl cluster-info` shows).
__NOTE__: This project is heavily in development phase.

### Running on the cluster
Welcome to CRD bootstrapper. The name explains what this controller does. It keeps CRDs in your cluster up-to-date.

Simple as that. There are three types of bootstrap options (the third is underway).

- URL (soon)
- ConfigMap
- GitHub release page

Let's look at each of them.

## URL

(soon)

In this CRD a simple URL can be used with a digest as version. It will fetch the content on every interval, calculate a
digest, and if it's different, apply it.

## ConfigMap

To install a set of CRDs from a ConfigMap, simply create a ConfigMap like the one under samples/config.
![configmap](./config/samples/config-map.yaml).

Next, apply a bootstrap CRD:

```yaml
apiVersion: delivery.crd-bootstrap/v1alpha1
kind: Bootstrap
metadata:
name: bootstrap-sample
namespace: crd-bootstrap-system
spec:
interval: 10s
source:
configMap:
name: crd-bootstrap-sample
namespace: crd-bootstrap-system
version:
semver: 1.0.0
```
And done. What this does, we'll get to under [But what does it do?](#but-what-does-it-do).
## GitHub
GitHub is largely the same, but
## But what does it do?
### Constant Version Reconciliation
The semver that we defined is a constraint. A semver constraint. It could be something like `>=v1`. And anything that
satisfies this constraint gets installed. It only rolls forward, to prevent accidental or intentional upstream version
rollbacks if a later version is removed.

Given the `interval` it checks every time if there is a newer version satisfying the constraint. The CRD keeps track of
the last applied version in its status. Once there is a new one, it applies it to the cluster and saves that version.

It also saves attempted versions. If a version is failed to apply, it will still record it as attempted version in its
status.

### Validation

Before applying a new CRD there are options to make sure that it doesn't break anything by defining a template to check
against. It would be awesome if it could list all Objects that belong to a CRD but that's just not possible because of various
security reasons.

To work around that, the user can define a `template` section in the Bootstrap object. It will use that template and
validate the CRD it's trying to apply to the cluster first against that template:

```yaml
apiVersion: delivery.crd-bootstrap/v1alpha1
kind: Bootstrap
metadata:
name: bootstrap-sample
namespace: crd-bootstrap-system
spec:
interval: 10s
template:
KrokEvent:
apiVersion: delivery.krok.app/v1alpha1
kind: KrokEvent
metadata:
name: krokevent-sample
spec:
thisfield: bla
source:
configMap:
name: crd-bootstrap-sample
namespace: crd-bootstrap-system
version:
semver: 1.0.0
```

The template is a map of `Kind`: `Template Yaml`. Here, we have a KrokEvent CRD kind. This fails validation because the
spec field doesn't have `thisfield` in it. A failed validation will immediately stop reconciliation of the bootstrap
object. User intervention is required to kick it off again to prevent messing up the cluster.

If it's desired to continue on failures, there is a setting for that. Simply set `continueOnValidationError: true` in the
Bootstrap's spec.

### Multiple CRDs in single file

A single Bootstrap CRD will point to a single file of ConfigMap. But that file, or ConfigMap may contain multiple CRDs.
Once a Bootstrap object is deleted it will remove all CRDs that belong to it and were applied by it.

For example, consider the GitHub example. Flux's `install.yaml` contains all their objects. And it contains Deployment
and Service objects too. Bootstrap doesn't care. It only installs the CRDs from that by using server-side-apply.

The status of the Bootstrap object will keep track of what CRDs it installed.

## Running on the cluster
1. Install Instances of Custom Resources:

```sh
Expand Down Expand Up @@ -42,7 +148,8 @@ make undeploy
```

## Contributing
// TODO(user): Add detailed information on how you would like others to contribute to this project

Contributions are always welcomed.

### How it works
This project aims to follow the Kubernetes [Operator pattern](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/).
Expand Down Expand Up @@ -76,6 +183,16 @@ make manifests

More information can be found via the [Kubebuilder Documentation](https://book.kubebuilder.io/introduction.html)

### Using Tilt

This project uses [tilt](https://tilt.dev/). For local development, create a kind cluster with:

```
kind create cluster
```

... and then simply execute `tilt up`. Hit space, and you should see everything preloaded.

## License

Copyright 2023.
Expand Down
1 change: 1 addition & 0 deletions config/samples/delivery_v1alpha1_bootstrap_configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ spec:
namespace: crd-bootstrap-system
version:
semver: 1.0.0
continueOnValidationError: true
6 changes: 6 additions & 0 deletions goreleaser.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY crd-bootstrap /manager
USER 65532:65532

ENTRYPOINT ["/manager"]
Binary file added hack/crd-bootstrap-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 72ce8f4

Please sign in to comment.