Skip to content
This repository has been archived by the owner on Mar 29, 2024. It is now read-only.

Commit

Permalink
faster flux faster ci?
Browse files Browse the repository at this point in the history
  • Loading branch information
corang committed Oct 13, 2023
1 parent 877abbe commit 25b9998
Show file tree
Hide file tree
Showing 14 changed files with 4,250 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ jobs:
run: |
kubectl apply -f test/lb-annotation-aws/pepr-module-lb-annotate.yaml
- name: Install Pepr flux resources module
run: |
kubectl apply -f test/flux-resources-bump/pepr-module-flux-resources.yaml
build:
runs-on: ubuntu-latest
steps:
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ build/uds-bundle-software-factory: | build $(REGISTRY_TARGET) ## Build the softw
# Deploy Section
########################################################################

apply-pepr-flux-resources: | build/zarf ## Apply the pepr flux resources module
build/zarf tools kubectl apply -f test/flux-resources-bump/pepr-module-flux-resources.yaml

deploy: ## Deploy the software factory package
cd ./build && ./uds bundle deploy oci://$(REGISTRY)/uds-package$(BUNDLE_DEV_PREFIX)/software-factory-demo:$(BUNDLE_VERSION)-amd64 $(INSECURE) --oci-concurrency 12 --no-progress --confirm

Expand Down
30 changes: 30 additions & 0 deletions test/flux-resources-bump/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"env": {
"browser": false,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": [
"./tsconfig.json"
],
"ecmaVersion": 2022
},
"plugins": [
"@typescript-eslint"
],
"ignorePatterns": [
"node_modules",
"dist"
],
"root": true,
"rules": {
"@typescript-eslint/no-floating-promises": [
"error"
]
}
}
4 changes: 4 additions & 0 deletions test/flux-resources-bump/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore node_modules and Pepr build artifacts
node_modules
dist
insecure*
13 changes: 13 additions & 0 deletions test/flux-resources-bump/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"arrowParens": "avoid",
"bracketSameLine": false,
"bracketSpacing": true,
"embeddedLanguageFormatting": "auto",
"insertPragma": false,
"printWidth": 80,
"quoteProps": "as-needed",
"requirePragma": false,
"semi": true,
"tabWidth": 2,
"useTabs": false
}
21 changes: 21 additions & 0 deletions test/flux-resources-bump/.vscode/pepr.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"Create a new Pepr capability": {
"prefix": "create pepr capability",
"body": [
"import { Capability, a } from 'pepr';",
"",
"export const ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/} = new Capability({",
"\tname: '${TM_FILENAME_BASE}',",
"\tdescription: '${1:A brief description of this capability.}',",
"\tnamespaces: [${2:}],",
"});",
"",
"// Use the 'When' function to create a new action",
"const { When } = ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/};",
"",
"// When(a.<Kind>).Is<Event>().Then(change => change.<changes>",
"When(${3:})"
],
"description": "Creates a new Pepr capability with a specified description, optional namespaces, and adds a When statement for the specified value."
}
}
9 changes: 9 additions & 0 deletions test/flux-resources-bump/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"debug.javascript.terminalOptions": {
"enableTurboSourcemaps": true,
"resolveSourceMapLocations": [
"${workspaceFolder}/**",
"node_modules/pepr/**"
]
}
}
21 changes: 21 additions & 0 deletions test/flux-resources-bump/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Pepr Module

This is a Pepr Module. [Pepr](https://github.com/defenseunicorns/pepr) is a type-safe Kubernetes middleware system.

The `capabilities` directory contains all the capabilities for this module. By default,
a capability is a single typescript file in the format of `capability-name.ts` that is
imported in the root `pepr.ts` file as `import { HelloPepr } from "./capabilities/hello-pepr";`.
Because this is typescript, you can organize this however you choose, e.g. creating a sub-folder
per-capability or common logic in shared files or folders.

Example Structure:

```
Module Root
├── package.json
├── pepr.ts
└── capabilities
├── example-one.ts
├── example-three.ts
└── example-two.ts
```
45 changes: 45 additions & 0 deletions test/flux-resources-bump/capabilities/flux-resources-bump.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Capability, a } from "pepr";

export const BumpFluxResources = new Capability({
name: "annotate-lb",
description:
"Add annotation to all services of type loadbalancer so that they are provisioned with NLB instead of ELB",
namespaces: [],
});

const { When } = BumpFluxResources;

const fluxResourcesBurstable = {
requests: {
cpu: "1000m",
memory: "512Mi",
},
limits: {
cpu: "3000m",
memory: "3Gi",
},
};

When(a.Pod)
.IsCreated()
.InNamespace("flux-system")
.WithLabel("app", "source-controller")
.Mutate(pod => {
pod.Raw.spec.containers[0].resources = fluxResourcesBurstable;
});

When(a.Pod)
.IsCreated()
.InNamespace("flux-system")
.WithLabel("app", "helm-controller")
.Mutate(pod => {
pod.Raw.spec.containers[0].resources = fluxResourcesBurstable;
});

When(a.Pod)
.IsCreated()
.InNamespace("flux-system")
.WithLabel("app", "kustomize-controller")
.Mutate(pod => {
pod.Raw.spec.containers[0].resources = fluxResourcesBurstable;
});
Loading

0 comments on commit 25b9998

Please sign in to comment.