-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d9238c8
Showing
30 changed files
with
2,817 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Pull-Request Testing | ||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build docker image | ||
run: docker build . | ||
|
||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 2 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: 'go.mod' | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.61.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- release | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
packages: write | ||
|
||
name: Release | ||
|
||
jobs: | ||
release-please: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version: ${{steps.release.outputs.version }} | ||
release_created: ${{steps.release.outputs.release_created }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: googleapis/release-please-action@v4 | ||
id: release | ||
with: | ||
target-branch: 'release' | ||
|
||
release-container: | ||
runs-on: ubuntu-latest | ||
needs: release-please | ||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
TAG: ${{ needs.release-please.outputs.version }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v6 | ||
if: ${{needs.release-please.outputs.release_created == 'true'}} | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }} | ||
platforms: | | ||
linux/amd64 | ||
linux/arm64 | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
if: ${{ needs.release-please.outputs.release_created != 'true' }} | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=raw,value=latest-{{date 'YYYYMMDDHHmmss'}}-{{sha}} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v6 | ||
if: ${{ needs.release-please.outputs.release_created != 'true' }} | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
platforms: | | ||
linux/amd64 | ||
linux/arm64 | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
release-helm: | ||
runs-on: ubuntu-latest | ||
needs: release-please | ||
if: ${{needs.release-please.outputs.release_created == 'true'}} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # important parameter | ||
|
||
- name: Configure Git | ||
run: | | ||
git config user.name "$GITHUB_ACTOR" | ||
git config user.email "[email protected]" | ||
- name: Install Helm | ||
uses: azure/setup-helm@v4 | ||
env: | ||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
|
||
- name: Run chart-releaser | ||
uses: helm/[email protected] | ||
env: | ||
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
run: | ||
timeout: 30m | ||
|
||
linters: | ||
enable: | ||
- errcheck | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- staticcheck | ||
- unused | ||
- zerologlint | ||
|
||
issues: | ||
max-same-issues: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
".": "1.9.1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
FROM --platform=$BUILDPLATFORM golang:1.23-alpine3.20 AS builder | ||
# Define target arch variables so we can use them while crosscompiling, will be set automatically | ||
ARG TARGETARCH | ||
ENV CGO_ENABLED=0 \ | ||
GOOS=linux \ | ||
GOARCH=${TARGETARCH} | ||
|
||
WORKDIR /go/src/ | ||
|
||
# get dependencies | ||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
# copy code | ||
COPY . . | ||
|
||
# Build project | ||
RUN go build -ldflags "-s -w" -a -installsuffix cgo -o /radix-ingress-default-backend | ||
|
||
# Final stage, ref https://github.com/GoogleContainerTools/distroless/blob/main/base/README.md for distroless | ||
FROM gcr.io/distroless/static | ||
COPY www /www | ||
COPY mime.types /etc/ | ||
COPY --from=builder /radix-ingress-default-backend /radix-ingress-default-backend | ||
|
||
EXPOSE 8000 | ||
USER 1000 | ||
ENTRYPOINT ["/radix-ingress-default-backend"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Radix Ingress Defailt Backend | ||
|
||
Responds with the default backend based on namespace header | ||
|
||
## How we work | ||
|
||
Commits to the main branch must follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) and uses Release Please to create new versions. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: v2 | ||
name: ingress-deafult-backend | ||
icon: https://radix.equinor.com/images/logos/logo.svg | ||
description: Simple Prometheus Proxy to expose a simple metric | ||
version: 1.9.1 | ||
appVersion: 1.9.1 | ||
kubeVersion: '>=1.24.0' | ||
keywords: | ||
- radix | ||
home: radix.equinor.com | ||
sources: | ||
- https://github.com/equinor/ingress-deafult-backend | ||
maintainers: | ||
- name: Omnia Radix | ||
email: [email protected] |
58 changes: 58 additions & 0 deletions
58
charts/radix-ingress-deafult-backend/templates/_helpers.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "prometheus-proxy.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If release name contains chart name it will be used as a full name. | ||
*/}} | ||
{{- define "prometheus-proxy.fullname" -}} | ||
{{- if .Values.fullnameOverride }} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- $name := default .Chart.Name .Values.nameOverride }} | ||
{{- if contains $name .Release.Name }} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "prometheus-proxy.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "prometheus-proxy.labels" -}} | ||
helm.sh/chart: {{ include "prometheus-proxy.chart" . }} | ||
{{ include "prometheus-proxy.selectorLabels" . }} | ||
{{- if .Chart.Version }} | ||
app.kubernetes.io/version: {{ .Chart.Version | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "prometheus-proxy.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "prometheus-proxy.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "prometheus-proxy.serviceAccountName" -}} | ||
{{- default (include "prometheus-proxy.fullname" .) .Values.serviceAccount.name }} | ||
{{- end }} |
66 changes: 66 additions & 0 deletions
66
charts/radix-ingress-deafult-backend/templates/deployment.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ template "prometheus-proxy.fullname" . }} | ||
namespace: {{ .Release.Namespace | quote }} | ||
labels: | ||
{{- include "prometheus-proxy.labels" . | nindent 4 }} | ||
{{- with .Values.deploymentAnnotations }} | ||
annotations: | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
{{- include "prometheus-proxy.selectorLabels" . | nindent 6 }} | ||
template: | ||
metadata: | ||
labels: | ||
{{- include "prometheus-proxy.selectorLabels" . | nindent 8 }} | ||
{{- with .Values.podLabels }} | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
spec: | ||
securityContext: | ||
runAsNonRoot: true | ||
runAsUser: 1000 | ||
runAsGroup: 1000 | ||
fsGroup: 1000 | ||
supplementalGroups: | ||
- 1000 | ||
{{- with .Values.affinity }} | ||
affinity: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.nodeSelector }} | ||
nodeSelector: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.tolerations }} | ||
tolerations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
containers: | ||
- name: {{ .Chart.Name }} | ||
image: "{{ .Values.image.repository }}:{{ default .Chart.Version .Values.image.tag }}" | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
ports: | ||
- containerPort: 8000 | ||
name: http | ||
env: | ||
- name: LOG_PRETTY | ||
value: {{ .Values.logPretty | quote }} | ||
- name: LOG_LEVEL | ||
value: {{ .Values.logLevel | quote }} | ||
- name: PROMETHEUS | ||
value: {{ .Values.prometheusUrl | quote }} | ||
resources: | ||
{{- toYaml .Values.resources | nindent 12 }} | ||
securityContext: | ||
privileged: false | ||
readOnlyRootFilesystem: true | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: | ||
- ALL |
Oops, something went wrong.