Skip to content

Commit

Permalink
First code commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gitbluf committed Sep 20, 2023
1 parent f327dcb commit 6d48e06
Show file tree
Hide file tree
Showing 69 changed files with 13,032 additions and 42 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: E2e Deploy Module

on:
workflow_dispatch:
pull_request:
push:
branches:
- main

permissions:
contents: read

jobs:
e2e:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Install cli tools
run: make tools
- name: Run CUE test
run: make test
- name: Create cluster with kind
run: make kind
- name: Deploy deployment
run: make e2e
36 changes: 36 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release Deploy module
on:
push:
tags: ['*']

permissions:
contents: read # needed for checkout
packages: write # needed for GHCR access

jobs:
push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup CUE
uses: cue-lang/[email protected]
with:
version: v0.5.0
- name: Setup Timoni
uses: stefanprodan/timoni/actions/setup@main
with:
version: 0.11.1
- name: Test instance build
id: test
run: make test
- name: Push
id: push
env:
USER: ${{ github.actor }}
PASS: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
TAG: ${{ github.ref_name }}
run: make push
59 changes: 59 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Setting SHELL to bash allows bash commands to be executed by recipes.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec
DEFAULT=help

MODULE=deploy

.PHONY: help test build push tools

help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

tools: ## Install cue, kind, Timoni
brew bundle

get: ## Update Kubernetes API CUE definitions
@go mod init
@go get -u k8s.io/api/...
@go get -u k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
@cue get go k8s.io/api/core/v1
@cue get go k8s.io/api/apps/v1
@cue get go k8s.io/api/rbac/v1
@cue get go k8s.io/apimachinery/pkg/apis/meta/v1
@cue get go k8s.io/apimachinery/pkg/runtime
@cue get go k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
@rm go.mod go.sum

test: ## Build with test_tool.cue + test_values.cue
@cue cmd -t name=test -t namespace=test -t mv=0.0.1 -t kv=1.28.0 build .

gen: vet ## Print the CUE generated objects
@cue gen

kind: ## Create kind cluster
@kind create cluster --config ./test/kind.yaml

build: ## Build with timoni with ns+name provided as arg/flag
@timoni build -n testing test .


e2e: ## Run full flow + ep validate
@$(MAKE) apply
@tests/validate.sh
@$(MAKE) delete

apply: ## Apply the module with default values
@kubectl create ns test
@timoni apply -n test test-deploy ./ --timeout=1m

delete: ## Delete the module with default values
@timoni delete -n test test-deploy ./ --timeout=1m
@kubectl delete ns test

push: ## Push the module with timoni
@timoni mod push . \
oci://ghcr.io/${OWNER}/cue-modules/$(MODULE) \
--version ${TAG} \
--creds ${USER}:${PASS}
44 changes: 2 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,14 @@
# cue-kube-deploy

<!--- description -->

## Install

To create an instance using the default values:

```shell
timoni -n default apply cue-kube-deploy oci://<container-registry-url>
```

To change the [default configuration](#configuration),
create one or more `values.cue` files and apply them to the instance.

For example, create a file `my-values.cue` with the following content:

```cue
values: {
resources: requests: {
cpu: "100m"
memory: "128Mi"
}
}
```

And apply the values with:

```shell
timoni -n default apply cue-kube-deploy oci://ghcr.io/<container-registry-url> \
--values ./my-values.cue
```

## Uninstall

To uninstall an instance and delete all its Kubernetes resources:

```shell
timoni -n default delete cue-kube-deploy
```

## Configuration

### General values

| Key | Type | Default | Description |
|------------------------------|-----------------------------------------|----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------|
| `image: tag:` | `string` | `<latest version>` | Container image tag |
| `image: digest:` | `string` | `<latest digest>` | Container image digest, takes precedence over `tag` when specified |
| `image: repository:` | `string` | `cgr.dev/chainguard/nginx` | Container image repository |
| `image: repository:` | `string` | `nginx` | Container image repository |
| `image: pullPolicy:` | `string` | `IfNotPresent` | [Kubernetes image pull policy](https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy) |
| `metadata: labels:` | `{[ string]: string}` | `{}` | Common labels for all resources |
| `metadata: annotations:` | `{[ string]: string}` | `{}` | Common annotations for all resources |
Expand Down Expand Up @@ -80,5 +41,4 @@ values: {
seccompProfile: type: "RuntimeDefault"
}
}
```
# cue-kube-deploy
```
7 changes: 7 additions & 0 deletions cue.mod/gen/k8s.io/api/apps/v1/register_go_gen.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Code generated by cue get go. DO NOT EDIT.

//cue:generate cue get go k8s.io/api/apps/v1

package v1

#GroupName: "apps"
Loading

0 comments on commit 6d48e06

Please sign in to comment.