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

Initial fixes #775

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 21 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
**/.git
envsettings.ps1
envsettings.ps1.template
helpers.ps1
LICENSE
compose.yml
compose.tests.yml
build.ps1
azure-pipelines.yml
.gitignore
.drone.yml
readme.md
serviceaccount/*
chart/*
Dockerfile
Dockerfile.debug
Dockerfile.aarch64
Dockerfile.armhf
Dockerfile.debian
Dockerfile.local
Dockerfile.tests
6 changes: 3 additions & 3 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ workspace:

steps:
- name: unit-test
image: golang:1.20.1
image: golang:1.21.3
commands:
- make test

- name: build
image: golang:1.20.1
image: golang:1.21.3
commands:
- make install

- name: build-ui
image: node:9.11.1-alpine
image: node:16.20.2-alpine
commands:
- cd ui
- yarn
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/releasecharts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release Charts
on:
push:
tags:
- "chart-*"
jobs:
release:
# depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions
# see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Install Helm
uses: azure/setup-helm@v4.2.0
- name: Extract tag version
id: get_version
run: echo "version=${GITHUB_REF##*/chart-}" >> $GITHUB_ENV
- name: Update Chart.yaml version
run: |
sed -i "s/^version:.*/version: ${GITHUB_ENV_VERSION}/" chart/keel/Chart.yaml
env:
GITHUB_ENV_VERSION: ${{ env.version }}
- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.6.0
with:
charts_dir: chart
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ hack/deployment-rbac.yaml
hack/deployment-norbac-helm.yaml
.vscode
.idea/
tests.out
tests.out
envsettings.ps1
serviceaccount/*
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM golang:1.20.5
FROM golang:1.21.3
COPY . /go/src/github.com/keel-hq/keel
WORKDIR /go/src/github.com/keel-hq/keel
RUN make install

FROM node:9.11.1-alpine
FROM node:16.20.2-alpine
WORKDIR /app
COPY ui /app
RUN yarn
Expand Down
29 changes: 29 additions & 0 deletions Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM golang:1.21.3
COPY . /go/src/github.com/keel-hq/keel
WORKDIR /go/src/github.com/keel-hq/keel
RUN make install-debug

FROM node:16.20.2-alpine
WORKDIR /app
COPY ui /app
RUN yarn
RUN yarn run lint --no-fix
RUN yarn run build

FROM golang:1.21.3

RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates && \
rm -rf /var/lib/apt/lists/*

VOLUME /data
ENV XDG_DATA_HOME /data

COPY --from=0 /go/bin/keel /bin/keel
COPY --from=1 /app/dist /www
COPY --from=0 /go/bin/dlv /
#ENTRYPOINT ["/bin/keel"]
ENTRYPOINT ["/dlv", "--listen=:40000", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", "/bin/keel"]

EXPOSE 9300
EXPOSE 40000
11 changes: 11 additions & 0 deletions Dockerfile.tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM golang:1.21.3

# Install tparse and go-junit-report
RUN go install github.com/mfridman/tparse@latest && \
go install github.com/jstemmer/go-junit-report@latest

COPY . /go/src/github.com/keel-hq/keel

WORKDIR /go/src/github.com/keel-hq/keel

ENTRYPOINT ["tail", "-f", "/dev/null"]
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ install:
# CGO_ENABLED=0 GOOS=linux go install -ldflags "$(LDFLAGS)" github.com/keel-hq/keel/cmd/keel
GOOS=linux go install -ldflags "$(LDFLAGS)" github.com/keel-hq/keel/cmd/keel

install-debug:
@echo "++ Installing keel with debug flags"
go install github.com/go-delve/delve/cmd/dlv@latest
GOOS=linux go install -gcflags "all=-N -l" -ldflags "$(LDFLAGS)" github.com/keel-hq/keel/cmd/keel

image:
docker build -t keelhq/keel:alpha -f Dockerfile .

Expand Down
71 changes: 71 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
trigger:
branches:
include:
- '*'
tags:
include:
- '*'
pr:
branches:
exclude:
- '*'
resources:
- repo: self
variables:
tag: '$(Build.BuildId)'
vmImage: 'ubuntu-latest'
stages:
- stage: Build
displayName: Build
jobs:
- job: Build
timeoutInMinutes: 120
displayName: Build
pool:
vmImage: $(vmImageName)
name: Test-Rafael
steps:
- pwsh: .\build.ps1
name: build_images
displayName: 'Build images'
env:
REGISTRY_USER: $(REGISTRY_USER)
REGISTRY_PWD: $(REGISTRY_PWD)
REGISTRY_PATH: $(REGISTRY_PATH)
IMAGE_VERSION: $(Build.SourceBranchName)
- pwsh: .\build.ps1 -RunTests
name: run_tests
displayName: 'Run tests'
env:
REGISTRY_USER: $(REGISTRY_USER)
REGISTRY_PWD: $(REGISTRY_PWD)
REGISTRY_PATH: $(REGISTRY_PATH)
IMAGE_VERSION: $(Build.SourceBranchName)
TESTDIR: '$(System.DefaultWorkingDirectory)/Tests'
- task: PublishTestResults@2
name: publish_tests_results
displayName: 'Publish Test Results'
condition: and(not(canceled()), not(contains(variables['Build.SourceVersionMessage'], '[notest]')))
inputs:
testResultsFormat: 'JUnit' # 'JUnit' | 'NUnit' | 'VSTest' | 'XUnit' | 'CTest'. Alias: testRunner. Required. Test result format. Default: JUnit.
testResultsFiles: '**/*.xml' # string. Required. Test results files. Default: **/TEST-*.xml.
searchFolder: '$(System.DefaultWorkingDirectory)/Tests' # string. Search folder. Default: $(System.DefaultWorkingDirectory).
# mergeTestResults: true
failTaskOnFailedTests: true
failTaskOnFailureToPublishResults: true
failTaskOnMissingResultsFile: true
testRunTitle: Pester
# Advanced
#buildPlatform: # string. Alias: platform. Build Platform.
#buildConfiguration: # string. Alias: configuration. Build Configuration.
publishRunAttachments: true
- pwsh: .\build.ps1 -Push
name: push_containers
displayName: 'Push images'
# Only push if this is a tag, and the tests passed
condition: or(and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/')), contains(variables['Build.SourceVersionMessage'], '[push]'))
env:
REGISTRY_USER: $(REGISTRY_USER)
REGISTRY_PWD: $(REGISTRY_PWD)
REGISTRY_PATH: $(REGISTRY_PATH)
IMAGE_VERSION: $(Build.SourceBranchName)
114 changes: 114 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/usr/bin/powershell -Command

##################################################
# Main build script, this is used both for local
# development and in continuous integration
# to build and push the images
##################################################

param (
[switch]$Push = $false,
[switch]$RunTests = $false,
[switch]$StartContainers = $false,
[switch]$StartDebugContainers = $false
)

$global:ErrorActionPreference = 'Stop'

. .\helpers.ps1

$TESTDIR = $Env:TESTDIR;
if ([string]::IsNullOrWhiteSpace($TESTDIR)) {
$TESTDIR = Get-Location;
}

# If there is a local environment envsettings
# file, load it. In pipelines, these are all comming
# from environment variables.
if (Test-Path "envsettings.ps1") {
.\envsettings.ps1;
}

# Ensure we are in LINUX containers
if (-not(Test-Path $Env:ProgramFiles\Docker\Docker\DockerCli.exe)) {
Get-Command docker
Write-Warning "Docker cli not found at $Env:ProgramFiles\Docker\Docker\DockerCli.exe"
}
else {
Write-Warning "Switching to Linux Engine"
& $Env:ProgramFiles\Docker\Docker\DockerCli.exe -SwitchLinuxEngine
}

$Env:SERVICEACCOUNT = Join-Path (split-path -parent $MyInvocation.MyCommand.Definition) "serviceaccount"

# Define the array of environment variable names to check
$envVarsToCheck = @(
"IMAGE_VERSION",
"REGISTRY_PATH"
)

foreach ($envVarName in $envVarsToCheck) {
$envVarValue = [System.Environment]::GetEnvironmentVariable($envVarName)
if ([string]::IsNullOrWhiteSpace($envVarValue)) {
throw "Environment variable '$envVarName' is empty or not set. Rename envsettings.ps1.template to envsettings.ps1 and complete the environment variables or set them for the current environment."
}
}

$version = $ENV:IMAGE_VERSION;
$containerregistry = $ENV:REGISTRY_PATH;

Write-Host "Environment IMAGE_VERSION: $($version)"
Write-Host "Environment REGISTRY_PATH: $($containerregistry)"

if (-not $containerregistry.EndsWith('/')) {
# Add a slash to the end of $containerregistry
$containerregistry = "$containerregistry/"
}

# Image names
$Env:IMG_KEEL = "$($containerregistry)keel:$($version)";
$Env:IMG_KEEL_DEBUG = "$($containerregistry)keel-debug:$($version)";
$Env:IMG_KEEL_TESTS = "$($containerregistry)keel-tests:$($version)";

docker compose build
ThrowIfError

if ($StartContainers) {
docker compose up
ThrowIfError
}

if ($StartDebugContainers) {
docker compose -f compose.debug.yml up
ThrowIfError
}

if ($RunTests -eq $true) {
Write-Host "Running tests..."
docker compose -f compose.tests.yml up -d --build
ThrowIfError
$testResultsFile = "/go/src/github.com/keel-hq/keel/test_results.json"
$localResultsPath = Join-Path $TESTDIR "test_results.xml"
$containerName = "keel_tests"
docker exec $containerName sh -c "make test"
# This one is to export the results
docker exec $containerName sh -c "go test -v `$(go list ./... | grep -v /tests) -cover 2>&1 | go-junit-report > $testResultsFile"
docker cp "$($containerName):$($testResultsFile)" $localResultsPath
Write-Host "Test results copied to $localResultsPath"
docker compose -f compose.tests.yml down
}

if ($Push) {
if ($Env:REGISTRY_USER -and $Env:REGISTRY_PWD) {
Write-Output "Container registry credentials through environment provided."

# Identify the registry
$registryHost = $ENV:REGISTRY_SERVER;
Write-Output "Remote registry host: $($registryHost)";
docker login "$($registryHost)" -u="$($Env:REGISTRY_USER)" -p="$($Env:REGISTRY_PWD)"
ThrowIfError
}

docker push "$($Env:IMG_KEEL)"
}

25 changes: 0 additions & 25 deletions chart/deploy/index.yaml

This file was deleted.

Binary file removed chart/deploy/keel-custom-1.0.4.tgz
Binary file not shown.
4 changes: 2 additions & 2 deletions chart/keel/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
name: keel-custom
name: keel-chart
description: Open source, tool for automating Kubernetes deployment updates. This is a custom fork of the original Keel project.
version: 1.0.4
version: 1.0.5
appVersion: 0.19.1
keywords:
- kubernetes deployment
Expand Down
1 change: 1 addition & 0 deletions chart/keel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ The following table lists has the main configurable parameters (polling, trigger
| `persistence.enabled` | Enable/disable audit log persistence | `true` |
| `persistence.storageClass` | Storage Class for the Persistent Volume| `-` |
| `persistence.size` | Persistent Volume size | `1Gi` |
| `imagePullSecrets` | Image pull secrets | `[]` |

Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`.

Expand Down
4 changes: 4 additions & 0 deletions chart/keel/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ spec:
{{- end }}
spec:
serviceAccountName: {{ template "serviceAccount.name" . }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
{{- if .Values.extraContainers }}
{{ toYaml .Values.extraContainers | indent 8 }}
Expand Down
Loading