Skip to content

Commit

Permalink
Merge branch 'main' into instance-types
Browse files Browse the repository at this point in the history
  • Loading branch information
kvaps authored Oct 16, 2024
2 parents f81e343 + 1a47328 commit a851f4b
Show file tree
Hide file tree
Showing 21 changed files with 141 additions and 35 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Pre-Commit Checks

on: [push, pull_request]

jobs:
pre-commit:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install pre-commit
run: pip install pre-commit

- name: Run pre-commit hooks
run: |
git fetch origin main || git fetch origin master
base_commit=$(git rev-parse --verify origin/main || git rev-parse --verify origin/master || echo "")
if [ -z "$base_commit" ]; then
files=$(git ls-files '*.yaml' '*.md')
else
files=$(git diff --name-only "$base_commit" -- '*.yaml' '*.md')
fi
if [ -n "$files" ]; then
echo "$files" | xargs pre-commit run --files
else
echo "No YAML or Markdown files to lint"
fi
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
args: [--fix=lf]
- id: check-yaml
exclude: packages/apps/postgres/templates/init-script.yaml
args: [--unsafe]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.41.0
hooks:
- id: markdownlint
args: [--fix, --disable, MD013, MD041, --]
23 changes: 23 additions & 0 deletions hack/pre-checks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

YQ_VERSION="v4.35.1"
RED='\033[31m'
RESET='\033[0m'

check-yq-version() {
current_version=$(yq -V | grep -oP 'v[0-9]+\.[0-9]+\.[0-9]+')
if [ -z "$current_version" ]; then
echo "yq is not installed or version cannot be determined."
exit 1
fi
echo "Current yq version: $current_version"

if [ "$(printf '%s\n' "$YQ_VERSION" "$current_version" | sort -V | head -n1)" = "$YQ_VERSION" ]; then
echo "Greater than or equal to $YQ_VERSION"
else
echo -e "${RED}ERROR: yq version less than $YQ_VERSION${RESET}"
exit 1
fi
}

check-yq-version
4 changes: 2 additions & 2 deletions manifests/cozystack-installer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ spec:
serviceAccountName: cozystack
containers:
- name: cozystack
image: "ghcr.io/aenix-io/cozystack/cozystack:v0.16.4"
image: "ghcr.io/aenix-io/cozystack/cozystack:v0.16.5"
env:
- name: KUBERNETES_SERVICE_HOST
value: localhost
Expand All @@ -87,7 +87,7 @@ spec:
fieldRef:
fieldPath: metadata.name
- name: darkhttpd
image: "ghcr.io/aenix-io/cozystack/cozystack:v0.16.4"
image: "ghcr.io/aenix-io/cozystack/cozystack:v0.16.5"
command:
- /usr/bin/darkhttpd
- /cozystack/assets
Expand Down
9 changes: 9 additions & 0 deletions packages/apps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### How to test packages local

```bash
cd packages/core/installer
make image-cozystack REGISTRY=YOUR_CUSTOM_REGISTRY
make apply
kubectl delete pod dashboard-redis-master-0 -n cozy-dashboard
kubectl delete po -l app=source-controller -n cozy-fluxcd
```
2 changes: 1 addition & 1 deletion packages/apps/kubernetes/images/cluster-autoscaler.tag
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ghcr.io/aenix-io/cozystack/cluster-autoscaler:0.12.0@sha256:7f617de5a24de790a15d9e97c6287ff2b390922e6e74c7a665cbf498f634514d
ghcr.io/aenix-io/cozystack/cluster-autoscaler:0.12.1@sha256:7f617de5a24de790a15d9e97c6287ff2b390922e6e74c7a665cbf498f634514d
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ghcr.io/aenix-io/cozystack/kubevirt-cloud-provider:0.12.0@sha256:df4a937b6fb2b345110174227170691d48189ffe1900c3f848cd5085990a58df
ghcr.io/aenix-io/cozystack/kubevirt-cloud-provider:0.12.1@sha256:ca606d6039ed43a48d4dfd98a91fd3cec120f08c1e221cd4e99ea94239389742
2 changes: 1 addition & 1 deletion packages/apps/kubernetes/images/kubevirt-csi-driver.tag
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ghcr.io/aenix-io/cozystack/kubevirt-csi-driver:0.12.0@sha256:86029548078960feecca116087b2135230d676b83c503f292eb50e1199be2790
ghcr.io/aenix-io/cozystack/kubevirt-csi-driver:0.12.1@sha256:86029548078960feecca116087b2135230d676b83c503f292eb50e1199be2790
2 changes: 1 addition & 1 deletion packages/apps/kubernetes/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ spec:
timeout: 30s
- type: Ready
status: "False"
timeout: 30s
timeout: 300s
{{- end }}
---
{{- /*
Expand Down
2 changes: 1 addition & 1 deletion packages/apps/postgres/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.7.0
version: 0.7.1

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
20 changes: 11 additions & 9 deletions packages/apps/postgres/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,34 @@ PostgreSQL is currently the leading choice among relational databases, known for

This managed service is controlled by the CloudNativePG operator, ensuring efficient management and seamless operation.

- Docs: https://cloudnative-pg.io/docs/
- Github: https://github.com/cloudnative-pg/cloudnative-pg
- Docs: <https://cloudnative-pg.io/docs/>
- Github: <https://github.com/cloudnative-pg/cloudnative-pg>

## HowTos

### How to switch master/slave replica

See:
- https://cloudnative-pg.io/documentation/1.15/rolling_update/#manual-updates-supervised

### How to restore backup:
- <https://cloudnative-pg.io/documentation/1.15/rolling_update/#manual-updates-supervised>

### How to restore backup

find snapshot:
```

```bash
restic -r s3:s3.example.org/postgres-backups/database_name snapshots
```

restore:
```

```bash
restic -r s3:s3.example.org/postgres-backups/database_name restore latest --target /tmp/
```

more details:
- https://itnext.io/restic-effective-backup-from-stdin-4bc1e8f083c1

- <https://itnext.io/restic-effective-backup-from-stdin-4bc1e8f083c1>

## Parameters

Expand Down Expand Up @@ -64,5 +68,3 @@ more details:
| `backup.s3AccessKey` | The access key for S3, used for authentication | `oobaiRus9pah8PhohL1ThaeTa4UVa7gu` |
| `backup.s3SecretKey` | The secret key for S3, used for authentication | `ju3eum4dekeich9ahM1te8waeGai0oog` |
| `backup.resticPassword` | The password for Restic backup encryption | `ChaXoveekoh6eigh4siesheeda2quai0` |


15 changes: 9 additions & 6 deletions packages/apps/postgres/templates/init-script.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ stringData:
init.sh: |
#!/bin/bash
set -e
until pg_isready ; do sleep 5; done
echo "== create users"
{{- if .Values.users }}
psql -v ON_ERROR_STOP=1 <<\EOT
Expand All @@ -60,7 +63,7 @@ stringData:
DROP USER $user;
EOT
done
echo "== create databases and roles"
{{- if .Values.databases }}
psql -v ON_ERROR_STOP=1 --echo-all <<\EOT
Expand Down Expand Up @@ -92,7 +95,7 @@ stringData:
FOR schema_record IN SELECT schema_name FROM information_schema.schemata WHERE schema_name NOT IN ('pg_catalog', 'information_schema') LOOP
-- Changing Schema Ownership
EXECUTE format('ALTER SCHEMA %I OWNER TO %I', schema_record.schema_name, '{{ $database }}_admin');
-- Add rights for the admin role
EXECUTE format('GRANT ALL ON SCHEMA %I TO %I', schema_record.schema_name, '{{ $database }}_admin');
EXECUTE format('GRANT ALL ON ALL TABLES IN SCHEMA %I TO %I', schema_record.schema_name, '{{ $database }}_admin');
Expand All @@ -101,7 +104,7 @@ stringData:
EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT ALL ON TABLES TO %I', schema_record.schema_name, '{{ $database }}_admin');
EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT ALL ON SEQUENCES TO %I', schema_record.schema_name, '{{ $database }}_admin');
EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT ALL ON FUNCTIONS TO %I', schema_record.schema_name, '{{ $database }}_admin');
-- Add rights for the readonly role
EXECUTE format('GRANT USAGE ON SCHEMA %I TO %I', schema_record.schema_name, '{{ $database }}_readonly');
EXECUTE format('GRANT SELECT ON ALL TABLES IN SCHEMA %I TO %I', schema_record.schema_name, '{{ $database }}_readonly');
Expand All @@ -119,9 +122,9 @@ stringData:
CREATE OR REPLACE FUNCTION auto_grant_schema_privileges()
RETURNS event_trigger LANGUAGE plpgsql AS $$
DECLARE
obj record;
obj record;
BEGIN
FOR obj IN SELECT * FROM pg_event_trigger_ddl_commands() WHERE command_tag = 'CREATE SCHEMA' LOOP
FOR obj IN SELECT * FROM pg_event_trigger_ddl_commands() WHERE command_tag = 'CREATE SCHEMA' LOOP
EXECUTE format('ALTER SCHEMA %I OWNER TO %I', obj.object_identity, '{{ $database }}_admin');
EXECUTE format('GRANT ALL ON SCHEMA %I TO %I', obj.object_identity, '{{ $database }}_admin');
EXECUTE format('GRANT USAGE ON SCHEMA %I TO %I', obj.object_identity, '{{ $database }}_readonly');
Expand All @@ -146,7 +149,7 @@ stringData:
EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT SELECT ON TABLES TO %I', obj.object_identity, '{{ $database }}_readonly');
EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT USAGE ON SEQUENCES TO %I', obj.object_identity, '{{ $database }}_readonly');
EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT EXECUTE ON FUNCTIONS TO %I', obj.object_identity, '{{ $database }}_readonly');
END LOOP;
END LOOP;
END;
$$;
Expand Down
6 changes: 4 additions & 2 deletions packages/apps/versions_map
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ kubernetes 0.9.0 9b6dd19
kubernetes 0.10.0 ac5c38b
kubernetes 0.11.0 4eaca42
kubernetes 0.11.1 4f430a90
kubernetes 0.12.0 31a45c4d
kubernetes 0.12.0 74649f8
kubernetes 0.12.1 28fca4e
kubernetes 0.13.0 HEAD
mysql 0.1.0 f642698
mysql 0.2.0 8b975ff0
Expand All @@ -53,7 +54,8 @@ postgres 0.4.1 5ca8823
postgres 0.5.0 c07c4bbd
postgres 0.6.0 2a4768a
postgres 0.6.2 54fd61c
postgres 0.7.0 HEAD
postgres 0.7.0 dc9d8bb
postgres 0.7.1 HEAD
rabbitmq 0.1.0 f642698
rabbitmq 0.2.0 5ca8823
rabbitmq 0.3.0 9e33dc0
Expand Down
5 changes: 4 additions & 1 deletion packages/core/installer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ TALOS_VERSION=$(shell awk '/^version:/ {print $$2}' images/talos/profiles/instal

include ../../../scripts/common-envs.mk

pre-checks:
../../../hack/pre-checks.sh

show:
helm template -n $(NAMESPACE) $(NAME) .

Expand All @@ -17,7 +20,7 @@ diff:
update:
hack/gen-profiles.sh

image: image-cozystack image-talos image-matchbox
image: pre-checks image-cozystack image-talos image-matchbox

image-cozystack:
make -C ../../.. repos
Expand Down
2 changes: 1 addition & 1 deletion packages/core/installer/values.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cozystack:
image: ghcr.io/aenix-io/cozystack/cozystack:v0.16.4@sha256:e2de79d1dd00a95a6876f6e4daf281eb27e8cc9d57fa2e9ea137192b544d38a7
image: ghcr.io/aenix-io/cozystack/cozystack:v0.16.5@sha256:5bd08ec86b8392d31a1df7cb496d7c861142771c323c302729f7728da9b49ae2
2 changes: 1 addition & 1 deletion packages/core/testing/values.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
e2e:
image: ghcr.io/aenix-io/cozystack/e2e-sandbox:v0.16.4@sha256:25b298d621ec79431d106184d59849bbae634588742583d111628126ad8615c5
image: ghcr.io/aenix-io/cozystack/e2e-sandbox:v0.16.5@sha256:25b298d621ec79431d106184d59849bbae634588742583d111628126ad8615c5
9 changes: 9 additions & 0 deletions packages/system/bucket/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{- $myNS := lookup "v1" "Namespace" "" .Release.Namespace }}
{{- $host := index $myNS.metadata.annotations "namespace.cozystack.io/host" }}
{{- $ingress := index $myNS.metadata.annotations "namespace.cozystack.io/ingress" }}
{{- $issuerType := (index $cozyConfig.data "clusterissuer") | default "http01" }}

apiVersion: networking.k8s.io/v1
kind: Ingress
Expand All @@ -13,8 +14,16 @@ metadata:
nginx.ingress.kubernetes.io/proxy-body-size: "0"
nginx.ingress.kubernetes.io/proxy-read-timeout: "99999"
nginx.ingress.kubernetes.io/proxy-send-timeout: "99999"
{{- if ne $issuerType "cloudflare" }}
acme.cert-manager.io/http01-ingress-class: {{ $ingress }}
{{- end }}
cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
ingressClassName: {{ $ingress }}
tls:
- hosts:
- "{{ .Values.bucketName }}.{{ $host }}"
secretName: {{ .Values.bucketName }}-ui-tls
rules:
- host: {{ .Values.bucketName }}.{{ $host }}
http:
Expand Down
6 changes: 3 additions & 3 deletions packages/system/dashboard/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ kubeapps:
image:
registry: ghcr.io/aenix-io/cozystack
repository: dashboard
tag: v0.16.4
tag: v0.16.5
digest: "sha256:4818712e9fc9c57cc321512760c3226af564a04e69d4b3ec9229ab91fd39abeb"
kubeappsapis:
image:
registry: ghcr.io/aenix-io/cozystack
repository: kubeapps-apis
tag: v0.16.4
digest: "sha256:55bc8e2495933112c7cb4bb9e3b1fcb8df46aa14e27fa007f78388a9757e3238"
tag: v0.16.5
digest: "sha256:126bb6955ff142e7e00e712c037f3e97bd39b360641fba0b8ca8bc083d5e8224"
2 changes: 1 addition & 1 deletion packages/system/kamaji/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kamaji:
deploy: false
image:
pullPolicy: IfNotPresent
tag: v0.16.4@sha256:95a9658cbbe1cbfbc42b9ab1df4f2a39342d7a8f1ff10a10b81b8656f3744c39
tag: v0.16.5@sha256:95a9658cbbe1cbfbc42b9ab1df4f2a39342d7a8f1ff10a10b81b8656f3744c39
repository: ghcr.io/aenix-io/cozystack/kamaji
resources:
limits:
Expand Down
2 changes: 1 addition & 1 deletion packages/system/kubeovn/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ global:
images:
kubeovn:
repository: kubeovn
tag: v1.13.0@sha256:d13ac4f916cd88d33d1d64c949978165272998d6594441a9dd4be5e6892caf4e
tag: v1.13.0@sha256:ba4e98866295db13d88b10984c230e1cb0db86782767c5b9aff452865cdd1012
10 changes: 7 additions & 3 deletions scripts/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,13 @@ fi
# Reconcile Helm repositories
kubectl annotate helmrepositories.source.toolkit.fluxcd.io -A -l cozystack.io/repository reconcile.fluxcd.io/requestedAt=$(date +"%Y-%m-%dT%H:%M:%SZ") --overwrite

# Unsuspend all system charts
kubectl get hr -A -l cozystack.io/system-app=true --no-headers | while read namespace name rest; do
kubectl patch hr -n "$namespace" "$name" -p '{"spec": {"suspend": null}}' --type=merge --field-manager=flux-client-side-apply
# Unsuspend all Cozystack managed charts
kubectl get hr -A -o go-template='{{ range .items }}{{ if .spec.suspend }}{{ .spec.chart.spec.sourceRef.namespace }}/{{ .spec.chart.spec.sourceRef.name }} {{ .metadata.namespace }} {{ .metadata.name }}{{ "\n" }}{{ end }}{{ end }}' | while read repo namespace name; do
case "$repo" in
cozy-system/cozystack-system|cozy-public/cozystack-extra|cozy-public/cozystack-apps)
kubectl patch hr -n "$namespace" "$name" -p '{"spec": {"suspend": null}}' --type=merge --field-manager=flux-client-side-apply
;;
esac
done

# Reconcile platform chart
Expand Down

0 comments on commit a851f4b

Please sign in to comment.